From: "Benoît Monin" <benoit.monin@bootlin.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-i2c@vger.kernel.org, Jean Delvare <jdelvare@suse.de>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH i2c-tools v2 2/2] i2ctransfer: Add optional message modifier flags
Date: Fri, 16 Jan 2026 14:01:57 +0100 [thread overview]
Message-ID: <2768446.lGaqSPkdTl@benoit.monin> (raw)
In-Reply-To: <aWaCAV4preoIPcih@ninjato>
On Tuesday, 13 January 2026 at 18:33:53 CET, Wolfram Sang wrote:
[...]
> > " DATA are LENGTH bytes for a write message. They can be shortened by a suffix:\n"
> > " = (keep value constant until LENGTH)\n"
> > " + (increase value by 1 until LENGTH)\n"
> > @@ -202,12 +209,21 @@ int main(int argc, char *argv[])
> > case PARSE_GET_DESC:
> > flags = 0;
> >
> > - switch (*arg_ptr++) {
> > - case 'r': flags |= I2C_M_RD; break;
> > - case 'w': break;
> > - default:
> > - fprintf(stderr, "Error: Invalid direction\n");
> > - goto err_out_with_arg;
> > + for (int done = 0; !done; ) {
> > + switch (*arg_ptr++) {
> > + /* optional flags */
> > + case 'i': flags |= I2C_M_IGNORE_NAK; break;
> > + case 'n': flags |= I2C_M_NO_RD_ACK; break;
> > + case 'p': flags |= I2C_M_STOP; break;
> > + case 's': flags |= I2C_M_NOSTART; break;
> > + case 't': flags |= I2C_M_REV_DIR_ADDR; break;
>
> Brainstorming here: maybe a macro could help:
>
> case 'i': add_flag_if_supported(flags, I2C_M_IGNORE_NAK);
>
> ?
>
I am having a hard time coming up with something here. There is the
__is_defined() macro in the kernel source[1], it only returns 0 or 1, not
the value of the define.
Maybe defining as zero the flags that are undefined would be acceptable?
E.g.
#ifndef I2C_M_IGNORE_NAK
#define I2C_M_IGNORE_NAK 0
#endif
Or you have another idea?
[1]: https://elixir.bootlin.com/linux/v6.19-rc5/source/tools/include/linux/kconfig.h#L35
Thanks for the review!
--
Benoît
next prev parent reply other threads:[~2026-01-16 13:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-23 13:22 [PATCH i2c-tools v2 0/2] Add support for message modifier flags Benoît Monin
2025-12-23 13:22 ` [PATCH i2c-tools v2 1/2] i2cdetect: Display mangling and nostart support Benoît Monin
2026-01-13 17:22 ` Wolfram Sang
2025-12-23 13:22 ` [PATCH i2c-tools v2 2/2] i2ctransfer: Add optional message modifier flags Benoît Monin
2026-01-13 17:33 ` Wolfram Sang
2026-01-16 13:01 ` Benoît Monin [this message]
2026-01-20 15:06 ` Jean Delvare
2026-01-20 14:45 ` Jean Delvare
2026-01-13 17:21 ` [PATCH i2c-tools v2 0/2] Add support for " Wolfram Sang
2026-01-20 14:15 ` Jean Delvare
2026-01-21 10:00 ` Benoît Monin
2026-01-21 18:37 ` Jean Delvare
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=2768446.lGaqSPkdTl@benoit.monin \
--to=benoit.monin@bootlin.com \
--cc=jdelvare@suse.de \
--cc=linux-i2c@vger.kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=wsa+renesas@sang-engineering.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