* updated maddy (0.7.1 -> 0.8.1), untested
[t2sde.git] / package / contrib / openrgb / hotfix-i2c-bus.patch
blob8e32caa63ac7e8f6f6f43b140adb8ff90755028f
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/openrgb/hotfix-i2c-bus.patch
3 # Copyright (C) 2023 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 --- OpenRGB-release_0.8/i2c_smbus/i2c_smbus_linux.cpp.vanilla 2023-05-11 16:59:57.687538263 +0200
15 +++ OpenRGB-release_0.8/i2c_smbus/i2c_smbus_linux.cpp 2023-05-11 18:49:27.062012602 +0200
16 @@ -77,7 +77,7 @@
17 char driver_path[512];
18 struct dirent * ent;
19 int test_fd;
20 - int ret = true;
21 + int ret = false;
22 char path[1024];
23 char buff[100];
24 unsigned short pci_device, pci_vendor, pci_subsystem_device, pci_subsystem_vendor;
25 @@ -85,12 +85,12 @@
26 char *ptr;
28 // Start looking for I2C adapters in /sys/bus/i2c/devices/
29 - strcpy(driver_path, "/sys/bus/i2c/devices/");
30 + strcpy(driver_path, "/sys/class/i2c-adapter/");
31 dir = opendir(driver_path);
33 if(dir == NULL)
35 - return(false);
36 + return(ret);
39 // Loop through all entries in i2c-adapter list
40 @@ -99,7 +99,7 @@
41 if(ent == NULL)
43 closedir(dir);
44 - return(false);
45 + return(ret);
48 while(ent != NULL)
50 @@ -227,25 +228,19 @@
51 strcat(device_string, ent->d_name);
52 test_fd = open(device_string, O_RDWR);
54 - if (test_fd < 0)
55 + if (test_fd > 0)
57 - ent = readdir(dir);
58 - ret = false;
59 - }
61 - bus = new i2c_smbus_linux();
62 - strcpy(bus->device_name, device_string);
63 - bus->handle = test_fd;
64 - bus->pci_device = pci_device;
65 - bus->pci_vendor = pci_vendor;
66 - bus->pci_subsystem_device = pci_subsystem_device;
67 - bus->pci_subsystem_vendor = pci_subsystem_vendor;
68 - bus->port_id = port_id;
69 - ResourceManager::get()->RegisterI2CBus(bus);
70 - }
71 - else
72 - {
73 - ret = false;
74 + bus = new i2c_smbus_linux();
75 + strcpy(bus->device_name, device_string);
76 + bus->handle = test_fd;
77 + bus->pci_device = pci_device;
78 + bus->pci_vendor = pci_vendor;
79 + bus->pci_subsystem_device = pci_subsystem_device;
80 + bus->pci_subsystem_vendor = pci_subsystem_vendor;
81 + bus->port_id = port_id;
82 + ResourceManager::get()->RegisterI2CBus(bus);
83 + ret = true;
84 + }