Serial-port and hidraw add USB interface number for identifying multi-devices in one USB

Hi,

One USB may contain multiple devices. To identify such devices in one USB, it requires USB interface number. The PID/VID attributes in serial-port and hidraw interfaces are not sufficient for this device.

For instance, the two serial ports in one USB bus(Exar usb-serial). The first serial port in USB bInterfaceNumber 00. Second serial port in USB bInterfaceNumber 02. But with the same PID/VID.

The serial-port and hidraw interfaces in snapd need to support such case.

  1. Add usb-interface-number attribute in serial-port interface

interface: serial-port
usb-vendor: 0xabcd
usb-product: 0x1234
usb-interface-number: 0
path: /dev/serial-port-myserial

  1. Add usb-interface-number attribute in hidraw interface

interface: hidraw
usb-vendor: 0xabcd
usb-product: 0x1234
usb-interface-number: 0
path: /dev/hidraw-myhidraw

  1. Add ENV{ID_USB_INTERFACE_NUM} attribute in udev rule.

IMPORT{builtin}=“usb_id”
SUBSYSTEM==“tty”, SUBSYSTEMS==“usb”, ATTRS{idVendor}==“abcd”, ATTRS{idProduct}==“1234”, ENV{ID_USB_INTERFACE_NUM}==“00”, SYMLINK+=“hidraw-myhidraw”

Thoughts?

Thanks,
Darren

I have sent a pull request:

Looking forward your feedback.

Darren

Reviewed, thank you!