# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/openrgb/hotfix-i2c-bus.patch # Copyright (C) 2023 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License version 2 as used by the T2 SDE. # --- T2-COPYRIGHT-NOTE-END --- --- OpenRGB-release_0.8/i2c_smbus/i2c_smbus_linux.cpp.vanilla 2023-05-11 16:59:57.687538263 +0200 +++ OpenRGB-release_0.8/i2c_smbus/i2c_smbus_linux.cpp 2023-05-11 18:49:27.062012602 +0200 @@ -77,7 +77,7 @@ char driver_path[512]; struct dirent * ent; int test_fd; - int ret = true; + int ret = false; char path[1024]; char buff[100]; unsigned short pci_device, pci_vendor, pci_subsystem_device, pci_subsystem_vendor; @@ -85,12 +85,12 @@ char *ptr; // Start looking for I2C adapters in /sys/bus/i2c/devices/ - strcpy(driver_path, "/sys/bus/i2c/devices/"); + strcpy(driver_path, "/sys/class/i2c-adapter/"); dir = opendir(driver_path); if(dir == NULL) { - return(false); + return(ret); } // Loop through all entries in i2c-adapter list @@ -99,7 +99,7 @@ if(ent == NULL) { closedir(dir); - return(false); + return(ret); } while(ent != NULL) { @@ -227,25 +228,19 @@ strcat(device_string, ent->d_name); test_fd = open(device_string, O_RDWR); - if (test_fd < 0) + if (test_fd > 0) { - ent = readdir(dir); - ret = false; - } - - bus = new i2c_smbus_linux(); - strcpy(bus->device_name, device_string); - bus->handle = test_fd; - bus->pci_device = pci_device; - bus->pci_vendor = pci_vendor; - bus->pci_subsystem_device = pci_subsystem_device; - bus->pci_subsystem_vendor = pci_subsystem_vendor; - bus->port_id = port_id; - ResourceManager::get()->RegisterI2CBus(bus); - } - else - { - ret = false; + bus = new i2c_smbus_linux(); + strcpy(bus->device_name, device_string); + bus->handle = test_fd; + bus->pci_device = pci_device; + bus->pci_vendor = pci_vendor; + bus->pci_subsystem_device = pci_subsystem_device; + bus->pci_subsystem_vendor = pci_subsystem_vendor; + bus->port_id = port_id; + ResourceManager::get()->RegisterI2CBus(bus); + ret = true; + } } } }