From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: "Benoît Monin" <benoit.monin@bootlin.com>
Cc: linux-i2c@vger.kernel.org, Jean Delvare <jdelvare@suse.de>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH i2c-tools v3 2/2] i2ctransfer: Add optional message modifier flags
Date: Wed, 3 Jun 2026 09:33:37 +0200 [thread overview]
Message-ID: <ah_Y0bOyXRajpp8O@ninjato> (raw)
In-Reply-To: <20260127-msg-flags-v3-2-e7539945db2b@bootlin.com>
[-- Attachment #1: Type: text/plain, Size: 1919 bytes --]
Hi Benoît,
On Tue, Jan 27, 2026 at 10:25:58AM +0100, Benoît Monin wrote:
> Allow setting protocol mangling and repeated start elision flags of an i2c
> message with a set of optional command-line flags. These optional flags
> are parsed at the beginning of the DESC field up to a read or write flag.
>
> For example, to read one byte from address 0x50 followed by a stop, then
> write two bytes at 0x54 on bus 0, one would call i2ctransfer as follow:
>
> i2ctransfer 0 pr1@0x50 w2@0x54 0x10 0x20
>
> Since the new flags are optional, this patch preserves the compatibility
> of the i2ctransfer syntax.
>
> Handling of the message flags is done in add_flag_if_supported(). This
> function checks if the flag is defined at compile time and if the adapter
> supports the required functionality to handle the flag.
>
> Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
I don't have a controller supporting 'mangling' here at the moment, but
the code looks good and my regression tests went fine. There is one
thing about error handling, though:
> + for (ret = 0; *arg_ptr && !ret; arg_ptr++) {
> + ret = add_flag_if_supported(&flags, funcs, *arg_ptr);
> + if (ret < 0)
> + goto err_out_with_arg;
> + }
> + if (ret != 1) {
> + fprintf(stderr, "Error: Missing direction flag 'r' or 'w'\n");
> goto err_out_with_arg;
> }
This error message now only shows up if the 'rw'-flag is missing at the
end of the commandline:
# ./i2ctransfer -y 0 p
Error: Missing direction flag 'r' or 'w'
Error: faulty argument is 'p'
Otherwise it complains about '@' not being a flag:
# ./i2ctransfer -y 0 p@0x1a
Error: Unsupported flag '@'
Error: faulty argument is 'p@0x1a'
It would be nice if '@' would be recognized as a terminator for the
flags and would then complain about the missing direction flag, or?
Happy hacking,
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-06-03 7:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 9:25 [PATCH i2c-tools v3 0/2] Add support for message modifier flags Benoît Monin
2026-01-27 9:25 ` [PATCH i2c-tools v3 1/2] i2cdetect: Display mangling and nostart support Benoît Monin
2026-06-03 7:33 ` Wolfram Sang
2026-01-27 9:25 ` [PATCH i2c-tools v3 2/2] i2ctransfer: Add optional message modifier flags Benoît Monin
2026-06-03 7:33 ` Wolfram Sang [this message]
2026-06-04 16:00 ` Benoît Monin
2026-06-08 9:21 ` Wolfram Sang
2026-06-08 13:26 ` Benoît Monin
2026-02-17 12:13 ` [PATCH i2c-tools v3 0/2] Add support for " Jean Delvare
2026-03-23 9:12 ` Benoît Monin
2026-05-29 19:58 ` 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=ah_Y0bOyXRajpp8O@ninjato \
--to=wsa+renesas@sang-engineering.com \
--cc=benoit.monin@bootlin.com \
--cc=jdelvare@suse.de \
--cc=linux-i2c@vger.kernel.org \
--cc=thomas.petazzoni@bootlin.com \
/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