From: Sascha Hauer <sha@pengutronix.de>
To: Roland Hieber <rhi@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] commands: i2c_read: default to reading one byte
Date: Wed, 22 Nov 2023 16:23:32 +0100 [thread overview]
Message-ID: <20231122152332.GZ3359458@pengutronix.de> (raw)
In-Reply-To: <20231122110641.3683555-1-rhi@pengutronix.de>
On Wed, Nov 22, 2023 at 12:06:41PM +0100, Roland Hieber wrote:
> 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>
> ---
> commands/i2c.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/commands/i2c.c b/commands/i2c.c
> index 997d49a94916..3a708531ee0a 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
>
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2023-11-22 15:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 11:06 Roland Hieber
2023-11-22 15:23 ` Sascha Hauer [this message]
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=20231122152332.GZ3359458@pengutronix.de \
--to=sha@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=rhi@pengutronix.de \
/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