Iio slot to support dynamic iio device numbering

The order in which i2c sensors are probed by the kernel is not fixed and the
/dev/iio:device{X} number allocation is dynamic. When system reboots, the iio devices order would change.

On my system, there are three sensor devices:

hts221
lng2dm
lps22hb

The gadget snap exposed the three iio slots:

iio0:
    interface: iio 
    path: /dev/iio:device0
iio1:
    interface: iio 
    path: /dev/iio:device1
iio2:
    interface: iio 
    path: /dev/iio:device2

The snap should not connect all the iio slots which is insecure.
The iio slot needs a new attribute to identify the iio device number mapping.

Just like serial-port slot provides PID/VID attributes to identify the USB serial port device.
For iio slot, maybe we could have a “name” attribute to identify the sensor device. The “name” information can be obtained from sysfs:

/sys/bus/iio/devices/iio:device0/name

Thoughts?

Thanks,
Darren

We were actually discussing allowing the shipment of udev rules in the gadget snap to assign fixed naming to dynamically assigned devices yesterday at the Ubuntu Rally. @niemeyer i think the above is another example where this would be helpful …