From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: Brigham Campbell <me@brighamcampbell.com>
Cc: "Jean Delvare" <jdelvare@suse.de>,
linux-i2c@vger.kernel.org,
"Gero Schwäricke" <gero.schwaericke@sevenlab.de>
Subject: Re: [PATCH v5 1/2] i2c-tools: Allow passing device file paths
Date: Sun, 8 Nov 2026 14:09:37 +0100 [thread overview]
Message-ID: <avB0jS2RfBHgZ6Zi@shikoro> (raw)
In-Reply-To: <20260722-accept-device-path-v5-1-9c0bf9b4da26@brighamcampbell.com>
[-- Attachment #1: Type: text/plain, Size: 2016 bytes --]
Hi Brigham,
finally! Thanks to a long train travel :)
On Wed, Jul 22, 2026 at 02:52:40AM -0600, Brigham Campbell wrote:
> Make i2c-tools binaries accept a device file path or symlink directly.
> This is useful, for example, for use with stable symlinks generated by
> udev.
>
> In the case of conflict, the bus parameter is parsed with the following
> precedence in order to maintain backwards compatibility:
>
> number -> name -> device path
>
> Suggested-by: Gero Schwäricke <gero.schwaericke@sevenlab.de>
> Signed-off-by: Brigham Campbell <me@brighamcampbell.com>
Yes, I like how this turned out in the end. I think the code is easy to
understand. It seems to work well. It took a little time to find one
corner case in need to be dealt with ;) But it is simple enough...
> + i2cbus_ul = strtoul(i2cbus_arg, &end, 0);
> + if (!*end && *i2cbus_arg) {
> + if (i2cbus_ul > 0xFFFFF) {
> + fprintf(stderr, "Error: I2C bus out of range!\n");
> + return -2;
This fails if you use a name/path like "1111111111111". A diff like this
makes it work:
diff --git a/tools/i2cbusses.c b/tools/i2cbusses.c
index 40d863f..47ebffa 100644
--- a/tools/i2cbusses.c
+++ b/tools/i2cbusses.c
@@ -436,12 +436,7 @@ int open_i2c_dev(char *i2cbus_arg, char **filename, size_t size, int quiet)
char *end;
i2cbus_ul = strtoul(i2cbus_arg, &end, 0);
- if (!*end && *i2cbus_arg) {
- if (i2cbus_ul > 0xFFFFF) {
- fprintf(stderr, "Error: I2C bus out of range!\n");
- return -2;
- }
-
+ if (!*end && *i2cbus_arg && i2cbus_ul < 0x100000) {
return open_i2c_dev_by_nr(i2cbus_ul, *filename, size, quiet);
}
That should do it, or?
> + fprintf(stderr, "Error: Couldn't interpret `%s' as a bus number, "
> + "name, or device file path!\n", i2cbus_arg);
> +
I think this error message does its job very well. In my book, no need
to make it more fine-grained.
The rest (including patch 2) looks also good to me.
Thank you and happy hacking,
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-11-08 13:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 8:52 [PATCH v5 0/2] i2c-tools: Make tools accept bus path Brigham Campbell
2026-07-22 8:52 ` [PATCH v5 1/2] i2c-tools: Allow passing device file paths Brigham Campbell
2026-11-08 13:09 ` Wolfram Sang [this message]
2026-11-15 22:34 ` Wolfram Sang
2026-11-16 7:23 ` Brigham Campbell
2026-11-16 8:00 ` Wolfram Sang
2026-07-22 8:52 ` [PATCH v5 2/2] i2c-tools: Document device paths as I2CBUS arg Brigham Campbell
2026-09-07 21:18 ` [PATCH v5 0/2] i2c-tools: Make tools accept bus path Brigham Campbell
2026-09-27 16:02 ` Wolfram Sang
2026-10-04 2:57 ` Brigham Campbell
2026-11-16 8:04 ` 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=avB0jS2RfBHgZ6Zi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.