Skip to content

Conversation

@sandip4n
Copy link
Contributor

There are cases where detection of an interface fails due to lack of permissions when accessing /dev/i2c-*. In some instances, the current code will perform a double readdir() and skip what should have been the next interface to be enumerated. Also use this opportunity to clean up a few stray whitespaces.

There are cases where detection of an interface fails due to lack of permissions when accessing /dev/i2c-*. In some instances, the current code will perform a double readdir() and skip what should have been the next interface to be enumerated. E.g. consider a system with the following configuration $ ls -l /sys/bus/i2c/devices total 0 lrwxrwxrwx. 1 root 0 Sep 4 07:19 i2c-0 -> ../../../devices/platform/AMDI0010:03/i2c-0/ lrwxrwxrwx. 1 root 0 Sep 4 01:49 i2c-1 -> ../../../devices/pci0000:00/0000:00:08.1/0000:03:00.0/i2c-1/ lrwxrwxrwx. 1 root 0 Sep 4 01:50 i2c-10 -> ../../../devices/pci0000:00/0000:00:14.0/i2c-10/ lrwxrwxrwx. 1 root 0 Sep 4 01:49 i2c-2 -> ../../../devices/pci0000:00/0000:00:08.1/0000:03:00.0/i2c-2/ lrwxrwxrwx. 1 root 0 Sep 4 01:49 i2c-3 -> ../../../devices/pci0000:00/0000:00:08.1/0000:03:00.0/i2c-3/ lrwxrwxrwx. 1 root 0 Sep 4 01:49 i2c-4 -> ../../../devices/pci0000:00/0000:00:08.1/0000:03:00.0/i2c-4/ lrwxrwxrwx. 1 root 0 Sep 4 01:49 i2c-5 -> ../../../devices/pci0000:00/0000:00:08.1/0000:03:00.0/drm/card1/card1-eDP-1/i2c-5/ lrwxrwxrwx. 1 root 0 Sep 4 01:49 i2c-6 -> ../../../devices/pci0000:00/0000:00:08.1/0000:03:00.0/drm/card1/card1-DP-1/i2c-6/ lrwxrwxrwx. 1 root 0 Sep 4 01:49 i2c-7 -> ../../../devices/pci0000:00/0000:00:08.1/0000:03:00.0/drm/card1/card1-DP-2/i2c-7/ lrwxrwxrwx. 1 root 0 Sep 4 01:50 i2c-8 -> ../../../devices/pci0000:00/0000:00:14.0/i2c-8/ lrwxrwxrwx. 1 root 0 Sep 4 01:50 i2c-9 -> ../../../devices/pci0000:00/0000:00:14.0/i2c-9/ lrwxrwxrwx. 1 root 0 Sep 4 07:19 i2c-PNP0C50:0e -> ../../../devices/platform/AMDI0010:03/i2c-0/i2c-PNP0C50:0e/ $ openrgb --verbose --list-devices Before: ... Registering I2C interface: /dev/i2c-3 Device 1002:164C Subsystem: 1462:130C Registering I2C interface: /dev/i2c-10 Device 1022:790B Subsystem: 1462:130C Registering I2C interface: /dev/i2c-1 Device 1002:164C Subsystem: 1462:130C Registering I2C interface: /dev/i2c-8 Device 1022:790B Subsystem: 1462:130C [i2c_smbus_linux] Failed to read i2c device PCI device ID Registering I2C interface: /dev/i2c-6 Device 0000:0000 Subsystem: 0000:0000 Registering I2C interface: /dev/i2c-4 Device 1002:164C Subsystem: 1462:130C [i2c_smbus_linux] Failed to read i2c device PCI device ID Registering I2C interface: /dev/i2c-PNP0C50:0e Device 0000:0000 Subsystem: 0000:0000 Registering I2C interface: /dev/i2c-0 Device 0000:0000 Subsystem: 0000:0000 Registering I2C interface: /dev/i2c-9 Device 1022:790B Subsystem: 1462:130C [i2c_smbus_linux] Failed to read i2c device PCI device ID Registering I2C interface: /dev/i2c-7 Device 0000:0000 Subsystem: 0000:0000 [i2c_smbus_linux] Failed to read i2c device PCI device ID Registering I2C interface: /dev/i2c-5 Device 0000:0000 Subsystem: 0000:0000 ... After: ... Registering I2C interface: /dev/i2c-3 Device 1002:164C Subsystem: 1462:130C Registering I2C interface: /dev/i2c-10 Device 1022:790B Subsystem: 1462:130C Registering I2C interface: /dev/i2c-1 Device 1002:164C Subsystem: 1462:130C Registering I2C interface: /dev/i2c-8 Device 1022:790B Subsystem: 1462:130C [i2c_smbus_linux] Failed to read i2c device PCI device ID Registering I2C interface: /dev/i2c-6 Device 0000:0000 Subsystem: 0000:0000 Registering I2C interface: /dev/i2c-4 Device 1002:164C Subsystem: 1462:130C [i2c_smbus_linux] Failed to read i2c device PCI device ID Registering I2C interface: /dev/i2c-PNP0C50:0e Device 0000:0000 Subsystem: 0000:0000 Registering I2C interface: /dev/i2c-2 Device 1002:164C Subsystem: 1462:130C Registering I2C interface: /dev/i2c-0 Device 0000:0000 Subsystem: 0000:0000 Registering I2C interface: /dev/i2c-9 Device 1022:790B Subsystem: 1462:130C [i2c_smbus_linux] Failed to read i2c device PCI device ID Registering I2C interface: /dev/i2c-7 Device 0000:0000 Subsystem: 0000:0000 [i2c_smbus_linux] Failed to read i2c device PCI device ID Registering I2C interface: /dev/i2c-5 Device 0000:0000 Subsystem: 0000:0000 ... Signed-off-by: Sandipan Das <sandipan.osd@gmail.com>
Remove stray whitespaces in newlines. Signed-off-by: Sandipan Das <sandipan.osd@gmail.com>
@CalcProgrammer1 CalcProgrammer1 merged commit a934c4c into CalcProgrammer1:master Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants