diff options
author | Roland Hieber <rhi@pengutronix.de> | 2023-11-22 12:06:41 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-11-22 16:23:21 +0100 |
commit | 04637976c606ff697599a6c28ca12123a9188743 (patch) | |
tree | 4bba369c19dca786bfdffbfb978ebe64324d6ace /commands/i2c.c | |
parent | e649da890ed3c57a5b0ba2409e194398fdb3c5af (diff) | |
download | barebox-04637976c606ff697599a6c28ca12123a9188743.tar.gz barebox-04637976c606ff697599a6c28ca12123a9188743.tar.xz |
commands: i2c_read: default to reading one byte
The help text for i2c_read specifies that -c is optional:
Usage: i2c_read [-bacrwv]
However, using i2c_read without -c falls through in do_i2c_read():
if ((addr < 0) || (count < 1) || (addr > 0x7F))
return COMMAND_ERROR_USAGE;
Actually make -c optional by initialising the count to 1.
Signed-off-by: Roland Hieber <rhi@pengutronix.de>
Link: https://lore.barebox.org/20231122110641.3683555-1-rhi@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/i2c.c')
-rw-r--r-- | commands/i2c.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/commands/i2c.c b/commands/i2c.c index 997d49a949..3a708531ee 100644 --- a/commands/i2c.c +++ b/commands/i2c.c @@ -195,7 +195,7 @@ static int do_i2c_read(int argc, char *argv[]) struct i2c_adapter *adapter = NULL; struct i2c_client client; u8 *buf; - int count = -1, addr = -1, reg = -1, verbose = 0, ret, opt, bus = 0, wide = 0; + int count = 1, addr = -1, reg = -1, verbose = 0, ret, opt, bus = 0, wide = 0; while ((opt = getopt(argc, argv, "a:b:c:r:vw")) > 0) { switch (opt) { @@ -264,7 +264,7 @@ BAREBOX_CMD_HELP_OPT("-b BUS\t", "i2c bus number (default 0)") BAREBOX_CMD_HELP_OPT("-a ADDR\t", "i2c device address") BAREBOX_CMD_HELP_OPT("-r START", "start register (optional, master receive mode if none given)") BAREBOX_CMD_HELP_OPT("-w\t", "use word (16 bit) wide access") -BAREBOX_CMD_HELP_OPT("-c COUNT", "byte count") +BAREBOX_CMD_HELP_OPT("-c COUNT", "byte count (default 1)") BAREBOX_CMD_HELP_OPT("-v\t", "verbose") BAREBOX_CMD_HELP_END |