summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2022-05-24 11:29:24 +0200
committerJean Delvare <jdelvare@suse.de>2022-05-24 11:34:48 +0200
commit051304c49aa1e5a445238b4cf2594ea3ff7f2341 (patch)
tree54c5690bd37ac898db2d978f3c990e2f8259dc38
parentb295772910a0e01f017781fde7d4f05187580b20 (diff)
downloadi2c-tools-git-051304c49aa1e5a445238b4cf2594ea3ff7f2341.tar.gz
i2c-tools: Implement and document option -h
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> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
-rw-r--r--tools/i2cdetect.88
-rw-r--r--tools/i2cdetect.c5
-rw-r--r--tools/i2cdump.88
-rw-r--r--tools/i2cdump.c5
-rw-r--r--tools/i2cget.88
-rw-r--r--tools/i2cget.c5
-rw-r--r--tools/i2cset.88
-rw-r--r--tools/i2cset.c5
-rw-r--r--tools/i2ctransfer.88
-rw-r--r--tools/i2ctransfer.c5
10 files changed, 50 insertions, 15 deletions
diff --git a/tools/i2cdetect.8 b/tools/i2cdetect.8
index 09e22e4..5935b2b 100644
--- a/tools/i2cdetect.8
+++ b/tools/i2cdetect.8
@@ -1,4 +1,4 @@
-.TH I2CDETECT 8 "October 2017"
+.TH I2CDETECT 8 "May 2022"
.SH NAME
i2cdetect \- detect I2C chips
@@ -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 implemented by the adapter and exit.
.B "\-V"
Display the version and exit.
.TP
+.B "\-h"
+Display the help and exit.
+.TP
.B "\-l"
Output a list of installed busses.
diff --git a/tools/i2cdetect.c b/tools/i2cdetect.c
index 8f4f5f9..066ec82 100644
--- a/tools/i2cdetect.c
+++ b/tools/i2cdetect.c
@@ -209,7 +209,7 @@ int main(int argc, char *argv[])
int yes = 0, version = 0, list = 0;
/* handle (optional) flags first */
- while ((opt = getopt(argc, argv, "FValqry")) != -1) {
+ while ((opt = getopt(argc, argv, "FVahlqry")) != -1) {
switch (opt) {
case 'V': version = 1; break;
case 'y': yes = 1; break;
@@ -242,9 +242,10 @@ int main(int argc, char *argv[])
first = 0x00;
last = 0x7F;
break;
+ case 'h':
case '?':
help();
- exit(1);
+ exit(opt == '?');
}
}
diff --git a/tools/i2cdump.8 b/tools/i2cdump.8
index d8ed28d..6ede625 100644
--- a/tools/i2cdump.8
+++ b/tools/i2cdump.8
@@ -1,4 +1,4 @@
-.TH I2CDUMP 8 "June 2021"
+.TH I2CDUMP 8 "May 2022"
.SH NAME
i2cdump \- examine I2C registers
@@ -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
diff --git a/tools/i2cdump.c b/tools/i2cdump.c
index 1082211..d54a7e4 100644
--- a/tools/i2cdump.c
+++ b/tools/i2cdump.c
@@ -116,16 +116,17 @@ int main(int argc, char *argv[])
int first = 0x00, last = 0xff;
/* handle (optional) flags first */
- while ((opt = getopt(argc, argv, "Vafr:y")) != -1) {
+ while ((opt = getopt(argc, argv, "Vafhr:y")) != -1) {
switch (opt) {
case 'V': version = 1; break;
case 'f': force = 1; break;
case 'r': range = optarg; break;
case 'y': yes = 1; break;
case 'a': all_addrs = 1; break;
+ case 'h':
case '?':
help();
- exit(1);
+ exit(opt == '?');
}
}
diff --git a/tools/i2cget.8 b/tools/i2cget.8
index a836341..69586cc 100644
--- a/tools/i2cget.8
+++ b/tools/i2cget.8
@@ -1,4 +1,4 @@
-.TH I2CGET 8 "July 2021"
+.TH I2CGET 8 "May 2022"
.SH "NAME"
i2cget \- read from I2C/SMBus chip registers
@@ -13,6 +13,9 @@ i2cget \- read from I2C/SMBus chip registers
.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
diff --git a/tools/i2cget.c b/tools/i2cget.c
index 1d9fdff..2ac20f7 100644
--- a/tools/i2cget.c
+++ b/tools/i2cget.c
@@ -186,15 +186,16 @@ int main(int argc, char *argv[])
unsigned char block_data[I2C_SMBUS_BLOCK_MAX];
/* handle (optional) flags first */
- while ((opt = getopt(argc, argv, "Vafy")) != -1) {
+ while ((opt = getopt(argc, argv, "Vafhy")) != -1) {
switch (opt) {
case 'V': version = 1; break;
case 'f': force = 1; break;
case 'y': yes = 1; break;
case 'a': all_addrs = 1; break;
+ case 'h':
case '?':
help();
- exit(1);
+ exit(opt == '?');
}
}
diff --git a/tools/i2cset.8 b/tools/i2cset.8
index a23426e..e4e1870 100644
--- a/tools/i2cset.8
+++ b/tools/i2cset.8
@@ -1,4 +1,4 @@
-.TH I2CSET 8 "October 2017"
+.TH I2CSET 8 "May 2022"
.SH "NAME"
i2cset \- set I2C registers
@@ -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
diff --git a/tools/i2cset.c b/tools/i2cset.c
index aaac372..5bf48a1 100644
--- a/tools/i2cset.c
+++ b/tools/i2cset.c
@@ -168,7 +168,7 @@ int main(int argc, char *argv[])
int len;
/* handle (optional) flags first */
- while ((opt = getopt(argc, argv, "Vafm:ry")) != -1) {
+ while ((opt = getopt(argc, argv, "Vafhm:ry")) != -1) {
switch (opt) {
case 'V': version = 1; break;
case 'f': force = 1; break;
@@ -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 == '?');
}
}
diff --git a/tools/i2ctransfer.8 b/tools/i2ctransfer.8
index 1ca8b8c..c88ef64 100644
--- a/tools/i2ctransfer.8
+++ b/tools/i2ctransfer.8
@@ -1,4 +1,4 @@
-.TH i2ctransfer 8 "February 2017"
+.TH i2ctransfer 8 "May 2022"
.SH "NAME"
i2ctransfer \- send user-defined I2C messages in one transfer
@@ -16,6 +16,9 @@ i2ctransfer \- send user-defined I2C messages in one transfer
.br
.B i2ctransfer
.B -V
+.br
+.B i2ctransfer
+.B -h
.SH DESCRIPTION
.B i2ctransfer
@@ -63,6 +66,9 @@ It will print infos about all messages sent, i.e. not only for read messages but
.B -V
Display the version and exit.
.TP
+.B -h
+Display the help and exit.
+.TP
.B -a
Allow using addresses between 0x00 - 0x07 and 0x78 - 0x7f. Not recommended.
diff --git a/tools/i2ctransfer.c b/tools/i2ctransfer.c
index 716eac0..85b70c3 100644
--- a/tools/i2ctransfer.c
+++ b/tools/i2ctransfer.c
@@ -141,16 +141,17 @@ int main(int argc, char *argv[])
msgs[i].buf = NULL;
/* handle (optional) flags first */
- while ((opt = getopt(argc, argv, "Vafvy")) != -1) {
+ while ((opt = getopt(argc, argv, "Vafhvy")) != -1) {
switch (opt) {
case 'V': version = 1; break;
case 'v': verbose = 1; break;
case 'f': force = 1; break;
case 'y': yes = 1; break;
case 'a': all_addrs = 1; break;
+ case 'h':
case '?':
help();
- exit(1);
+ exit(opt == '?');
}
}