From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: "Gero Schwäricke" <gero.schwaericke@sevenlab.de>
Cc: Brigham Campbell <me@brighamcampbell.com>,
Jean Delvare <jdelvare@suse.de>,
linux-i2c@vger.kernel.org
Subject: Re: [PATCH v4 1/2] i2c-tools: Allow passing device file paths
Date: Sat, 11 Jul 2026 21:24:52 +0200 [thread overview]
Message-ID: <alKYhB6PKffxI2vt@shikoro> (raw)
In-Reply-To: <DJU1QIKM2DNQ.UOLEBWH0U0QQ@sevenlab.de>
[-- Attachment #1: Type: text/plain, Size: 1614 bytes --]
> code it's not understandable what's happening. Instead I would propose
> to inline `lookup_i2c_bus()` and then have the logic inside
> `open_i2c_dev()` be imparative like:
>
> 1. try to convert input to i2cbus bus number, if it worked
> `return open_i2c_dev_by_nr()` with the bus number, otherwise,
> 2. try `lookup_i2c_bus_by_name()`, if it worked we now have the bus
> number, so we `return open_i2c_dev_by_nr()` with it, otherwise,
> 3. try to open as path.
I like this approach.
> > - i2cbus = lookup_i2c_bus(argv[optind]);
> > - if (i2cbus < 0) {
> > - help();
> > - exit(1);
> > - }
> >
> > /* read address range if present */
> > if (argc == optind + 3 && mode != MODE_FUNC) {
> > @@ -321,7 +317,7 @@ int main(int argc, char *argv[])
> > exit(1);
> > }
> >
> > - file = open_i2c_dev(i2cbus, filename, sizeof(filename), 0);
> > + file = open_i2c_dev(argv[optind], &filename, sizeof(filename_buf), 0);
> > if (file < 0) {
> > exit(1);
> > }
>
> Removing this will change the error path, so a call that would
> previously fail in lookup_i2c_bus() may now fail somewhere else,
> changing error code and message. Same for all other tools.
You mean that help() is not printed in some cases then? The error code
is 1 in all cases, or am I missing something?
> @Jean Is that acceptable or against the targeted stability requirements
> of i2c-tools?
I am also curious about Jean's opinion here. In my book it is okay. If
not, we could also release the new version as 5.0, I'd say. Would even
match adding the DDR5 support nicely ;)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-07-11 19:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 4:27 [PATCH v4 0/2] i2c-tools: Make tools accept bus path Brigham Campbell
2026-07-06 4:27 ` [PATCH v4 1/2] i2c-tools: Allow passing device file paths Brigham Campbell
2026-07-09 12:18 ` Wolfram Sang
2026-07-09 12:40 ` Gero Schwäricke
2026-07-11 19:24 ` Wolfram Sang [this message]
2026-07-06 4:27 ` [PATCH v4 2/2] i2c-tools: Document device paths as I2CBUS arg Brigham Campbell
2026-07-11 19:43 ` 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=alKYhB6PKffxI2vt@shikoro \
--to=wsa+renesas@sang-engineering.com \
--cc=gero.schwaericke@sevenlab.de \
--cc=jdelvare@suse.de \
--cc=linux-i2c@vger.kernel.org \
--cc=me@brighamcampbell.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