public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: Linux I2C <linux-i2c@vger.kernel.org>
Subject: [PATCH 2/2] i2c-tools: Implement and document option -h
Date: Fri, 6 May 2022 16:11:44 +0200	[thread overview]
Message-ID: <20220506161144.59a20dac@endymion.delvare> (raw)
In-Reply-To: <20220506160652.61d61aa6@endymion.delvare>

Add an option -h to display the help of the tools. This is a common
practice so users may expect it to work.

Based on a preliminary patch from David Kerns.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
 tools/i2cdetect.8 |    6 ++++++
 tools/i2cdetect.c |    3 ++-
 tools/i2cdump.8   |    6 ++++++
 tools/i2cdump.c   |    3 ++-
 tools/i2cget.8    |    6 ++++++
 tools/i2cget.c    |    3 ++-
 tools/i2cset.8    |    6 ++++++
 tools/i2cset.c    |    3 ++-
 8 files changed, 32 insertions(+), 4 deletions(-)

--- i2c-tools.orig/tools/i2cdetect.8	2020-09-17 14:29:28.275299253 +0200
+++ i2c-tools/tools/i2cdetect.8	2022-05-06 16:00:21.370647957 +0200
@@ -18,6 +18,9 @@ i2cdetect \- detect I2C chips
 .I -V
 .br
 .B i2cdetect
+.I -h
+.br
+.B i2cdetect
 .I -l
 
 .SH DESCRIPTION
@@ -78,6 +81,9 @@ Display the list of functionalities impl
 .B "\-V"
 Display the version and exit.
 .TP
+.B "\-h"
+Display the help and exit.
+.TP
 .B "\-l"
 Output a list of installed busses.
 
--- i2c-tools.orig/tools/i2cdetect.c	2022-05-06 15:53:46.597938799 +0200
+++ i2c-tools/tools/i2cdetect.c	2022-05-06 16:00:48.922977347 +0200
@@ -242,9 +242,10 @@ int main(int argc, char *argv[])
 			first = 0x00;
 			last = 0x7F;
 			break;
+		case 'h':
 		case '?':
 			help();
-			exit(1);
+			exit(opt == '?');
 		}
 	}
 
--- i2c-tools.orig/tools/i2cdump.8	2021-07-22 16:39:29.619547310 +0200
+++ i2c-tools/tools/i2cdump.8	2022-05-06 15:59:58.930379681 +0200
@@ -14,6 +14,9 @@ i2cdump \- examine I2C registers
 .br
 .B i2cdump
 .B -V
+.br
+.B i2cdump
+.B -h
 
 .SH DESCRIPTION
 i2cdump is a small helper program to examine registers
@@ -24,6 +27,9 @@ visible through the I2C bus.
 .B -V
 Display the version and exit.
 .TP
+.B -h
+Display the help and exit.
+.TP
 .B -f
 Force access to the device even if it is already busy. By default, i2cdump
 will refuse to access a device which is already under the control of a
--- i2c-tools.orig/tools/i2cdump.c	2022-05-06 15:53:46.599938823 +0200
+++ i2c-tools/tools/i2cdump.c	2022-05-06 16:00:53.196028432 +0200
@@ -123,9 +123,10 @@ int main(int argc, char *argv[])
 		case 'r': range = optarg; break;
 		case 'y': yes = 1; break;
 		case 'a': all_addrs = 1; break;
+		case 'h':
 		case '?':
 			help();
-			exit(1);
+			exit(opt == '?');
 		}
 	}
 
--- i2c-tools.orig/tools/i2cget.8	2022-05-03 08:04:39.334978310 +0200
+++ i2c-tools/tools/i2cget.8	2022-05-06 15:58:15.488144365 +0200
@@ -13,6 +13,9 @@ i2cget \- read from I2C/SMBus chip regis
 .br
 .B i2cget
 .B -V
+.br
+.B i2cget
+.B -h
 
 .SH DESCRIPTION
 i2cget is a small helper program to read registers visible through the I2C
@@ -23,6 +26,9 @@ bus (or SMBus).
 .B -V
 Display the version and exit.
 .TP
+.B -h
+Display the help and exit.
+.TP
 .B -f
 Force access to the device even if it is already busy. By default, i2cget
 will refuse to access a device which is already under the control of a
--- i2c-tools.orig/tools/i2cget.c	2022-05-06 15:53:46.600938834 +0200
+++ i2c-tools/tools/i2cget.c	2022-05-06 16:00:55.894060687 +0200
@@ -192,9 +192,10 @@ int main(int argc, char *argv[])
 		case 'f': force = 1; break;
 		case 'y': yes = 1; break;
 		case 'a': all_addrs = 1; break;
+		case 'h':
 		case '?':
 			help();
-			exit(1);
+			exit(opt == '?');
 		}
 	}
 
--- i2c-tools.orig/tools/i2cset.8	2020-09-17 14:29:28.278299294 +0200
+++ i2c-tools/tools/i2cset.8	2022-05-06 15:58:41.228451225 +0200
@@ -18,6 +18,9 @@ i2cset \- set I2C registers
 .br
 .B i2cset
 .B -V
+.br
+.B i2cset
+.B -h
 
 .SH DESCRIPTION
 i2cset is a small helper program to set registers visible through the I2C
@@ -28,6 +31,9 @@ bus.
 .B -V
 Display the version and exit.
 .TP
+.B -h
+Display the help and exit.
+.TP
 .B -f
 Force access to the device even if it is already busy. By default, i2cset
 will refuse to access a device which is already under the control of a
--- i2c-tools.orig/tools/i2cset.c	2022-05-06 15:53:46.600938834 +0200
+++ i2c-tools/tools/i2cset.c	2022-05-06 16:00:43.398911306 +0200
@@ -176,9 +176,10 @@ int main(int argc, char *argv[])
 		case 'm': maskp = optarg; break;
 		case 'r': readback = 1; break;
 		case 'a': all_addrs = 1; break;
+		case 'h':
 		case '?':
 			help();
-			exit(1);
+			exit(opt == '?');
 		}
 	}
 

-- 
Jean Delvare
SUSE L3 Support

  reply	other threads:[~2022-05-06 14:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06 14:06 [PATCH 1/2] i2c-tools: Use getopt Jean Delvare
2022-05-06 14:11 ` Jean Delvare [this message]
2022-05-06 14:45 ` Wolfram Sang
2022-05-06 16:34   ` Jean Delvare
2022-05-07  7:36     ` Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220506161144.59a20dac@endymion.delvare \
    --to=jdelvare@suse.de \
    --cc=linux-i2c@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox