1

I have many instances of the same device (an I2C-based IIO sensor) with the same I2C address behind a couple of I2C multiplexers. I would like to symlink the iio:deviceX to a more meaningful name based on a deterministic path (e.g., device = 0x29, on mux = 0x70, on bus 1)

Unfortunately, it doesn't seem from udevadm info --attribute-walk --name=/dev/iio\:device0 that I can match against an I2C address based on these attributes:

  looking at device '/devices/pci0000:00/808622C1:00/i2c-0/i2c-5/i2c-PRP0001:02/iio:device0':
    KERNEL=="iio:device0"
    SUBSYSTEM=="iio"
    DRIVER==""
    ATTR{name}=="vl53l0x"
    ATTR{in_distance_raw}=="8190"
    ATTR{in_distance_scale}=="0.001000"

  looking at parent device '/devices/pci0000:00/808622C1:00/i2c-0/i2c-5/i2c-PRP0001:02':
    KERNELS=="i2c-PRP0001:02"
    SUBSYSTEMS=="i2c"
    DRIVERS=="vl53l0x-i2c"
    ATTRS{name}=="vl53l0x"

  looking at parent device '/devices/pci0000:00/808622C1:00/i2c-0/i2c-5':
    KERNELS=="i2c-5"
    SUBSYSTEMS=="i2c"
    DRIVERS==""
    ATTRS{name}=="i2c-0-mux (chan_id 0)"

  looking at parent device '/devices/pci0000:00/808622C1:00/i2c-0':
    KERNELS=="i2c-0"
    SUBSYSTEMS=="i2c"
    DRIVERS==""
    ATTRS{name}=="Synopsys DesignWare I2C adapter"

  looking at parent device '/devices/pci0000:00/808622C1:00':
    KERNELS=="808622C1:00"
    SUBSYSTEMS=="platform"
    DRIVERS=="i2c_designware"
    ATTRS{driver_override}=="(null)"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

How can I deterministically match against these sensors? I'm not even sure whether I can assume that the I2C multiplexers will always be initialized in the same order...

0andriy
  • 4,183
  • 1
  • 24
  • 37
mallwright
  • 1,670
  • 14
  • 31
  • Have you run `iio_info` and check if it has meaningful fields there? I'm pretty much sure `libiio` should have something that allows you to distinguish the devices. If not, I would suggest to cooperate with library maintainers to get what you want. – 0andriy Aug 31 '20 at 08:33

0 Answers0