Skip to contentSkip to conversation

Accept device-node path as alternative to bus number

RFC Gero Schwäricke 3 participants 7 messages Nov 10, 2025 – Feb 17 I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

I'm working with multiple hotpluggable I2C adapters and have the following proposal:

Allow all i2c-tools to accept a device-node path (e.g., /dev/i2c-5) as the i2cbus argument.

Example:

  # pre RFC:
  i2cget 5 0x48
  # post RFC:
  i2cget /dev/i2c-5 0x48

Motivation:

- Paths can be made stable via udev symlinks even when bus numbers vary between boots, hotplugging, or across machines.
- Scripts often already have a device node path. Accepting the path removes the need to parse out the numeric bus ID.

Backward compatibility:

- No behavior change for existing invocations.
- The first non-option argv is treated as today unless it begins with '/', in which case the tool treats it as a path and opens that exact node.

Sketch of changes:

- For each tool’s argument parsing, detect a leading '/' for the bus argument.
- If a path is given: use that path; skip bus resolution by number/name.
- Adjust control logic to work with paths instead of bus number.
- Update help/man text: add e.g., "i2cbus indicates ..., or a device node path like /dev/i2c-5."

Questions for maintainers:

1. Is accepting a device-node path an acceptable extension to the CLI?
2. Currently the bus number/name argument is parsed to an integer and then only stores as such in struct i2c_adap. When calling open_i2c_dev() the number is resolved to a /dev/i2c path. Is it acceptable to instead resolve a given number/name to a path during argument parsing and store the path in struct i2c_adap instead of the number?

Thank you,
Gero

#1 lore raw
Quoted 2 lines · Gero Schwäricke

I'm working with multiple hotpluggable I2C adapters and have the following proposal:

From my side, this all sounds reasonable. But we need Jean's opinion here, too.

#2 lore raw
Quoted 6 lines
Quoted 3 lines

I'm working with multiple hotpluggable I2C adapters and have the following proposal:

From my side, this all sounds reasonable. But we need Jean's opinion here, too.

Seems Jean is busy. So, from my side, let's go. I can apply it if all is well...

#3 lore raw

Hi Gero,

Quoted 9 lines · Wolfram Sang
Quoted 6 lines
Quoted 3 lines

I'm working with multiple hotpluggable I2C adapters and have the following proposal:

From my side, this all sounds reasonable. But we need Jean's opinion here, too.

Seems Jean is busy. So, from my side, let's go. I can apply it if all is well...

Did you have time to develop this?

Happy hacking,

Wolfram

#4 lore raw

Hi Wolfram,

Quoted 7 lines · Wolfram Sang

Hi Gero,

Quoted 4 lines · Wolfram Sang
Quoted 4 lines
Quoted 3 lines

I'm working with multiple hotpluggable I2C adapters and have the following proposal:

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

From my side, this all sounds reasonable. But we need Jean's opinion here, too.

Seems Jean is busy. So, from my side, let's go. I can apply it if all is well...

Did you have time to develop this?

thanks for following up on this and sorry for the late response, I'm currently occupied with other work, but I have this still on my TODO list. I intend to tackle this once I find some uninterrupted time.

Best,
Gero

Quoted 4 lines

Happy hacking,

Wolfram

#5 lore raw

Hi Gero,

Quoted 3 lines

thanks for following up on this and sorry for the late response, I'm currently occupied with other work, but I have this still on my TODO list. I intend to tackle this once I find some uninterrupted time.

Sure thing. Thanks for the heads up. I will stop pinging and just wait.

Happy hacking,

Wolfram

#6 lore raw
In reply to Wolfram Sang

Hi Gero, Wolfram,

Quoted 6 lines · Wolfram Sang
Quoted 2 lines · Gero Schwäricke

I'm working with multiple hotpluggable I2C adapters and have the following proposal:

From my side, this all sounds reasonable. But we need Jean's opinion here, too.

Sorry for the delay. The proposal sounds perfectly reasonable to me, and I'd be happy to see and review a candidate implementation thereof.

Please make sure that any piece of code which is common to all tools ends up in i2cbusses.c and does not get duplicated.

Thanks,

Signature · 2 lines
Jean Delvare
SUSE L3 Support