public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][i2c-tools] Accept device-node path as alternative to bus number
@ 2025-11-10 14:57 Gero Schwäricke
  2025-11-10 16:15 ` Wolfram Sang
  0 siblings, 1 reply; 7+ messages in thread
From: Gero Schwäricke @ 2025-11-10 14:57 UTC (permalink / raw)
  To: linux-i2c; +Cc: Jean Delvare

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-02-17 12:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-10 14:57 [RFC][i2c-tools] Accept device-node path as alternative to bus number Gero Schwäricke
2025-11-10 16:15 ` Wolfram Sang
2025-12-15 13:58   ` Wolfram Sang
2026-01-13 17:38     ` Wolfram Sang
2026-01-15 13:39       ` Gero Schwäricke
2026-01-15 14:16         ` Wolfram Sang
2026-02-17 12:19   ` Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox