diff options
author | David Chiu <dchiu@synaptics.com> | 2022-02-24 16:34:23 +0800 |
---|---|---|
committer | Vincent Huang <vincenthsw@gmail.com> | 2022-03-01 10:45:24 +0800 |
commit | e9115fa74a72e9a267ec6c08b8df8cd05d4f9085 (patch) | |
tree | 289161f4f73093076738e2ad5983d94babb227a4 | |
parent | 115762374d337c515587a02a387a845a4d6bdb6b (diff) | |
download | rmi4utils-e9115fa74a72e9a267ec6c08b8df8cd05d4f9085.tar.gz |
Parsing driver name instead of assigning one
-rwxr-xr-x | rmidevice/hiddevice.cpp | 30 | ||||
-rwxr-xr-x | rmidevice/hiddevice.h | 1 |
2 files changed, 21 insertions, 10 deletions
diff --git a/rmidevice/hiddevice.cpp b/rmidevice/hiddevice.cpp index d5e5176..00067e0 100755 --- a/rmidevice/hiddevice.cpp +++ b/rmidevice/hiddevice.cpp @@ -861,15 +861,8 @@ bool HIDDevice::FindTransportDevice(uint32_t bus, std::string & hidDeviceName, if (bus == BUS_I2C) { devicePrefix += "i2c/"; - // From new patch released on 2020/11, i2c_hid would be renamed as i2c_hid_acpi, - // and also need backward compatible. - std::string driverPathTemp = devicePrefix + "drivers/i2c_hid/"; - DIR *driverPathtest = opendir(driverPathTemp.c_str()); - if(!driverPathtest) { - driverPath = devicePrefix + "drivers/i2c_hid_acpi/"; - } else { - driverPath = devicePrefix + "drivers/i2c_hid/"; - } + // The i2c driver module installed on system is vary (i2c_hid, i2c_hid_acpi, i2c_hid_of), + // so we will assign driver path until we get device name later. } else { devicePrefix += "usb/"; driverPath = devicePrefix + "drivers/usbhid/"; @@ -908,8 +901,25 @@ bool HIDDevice::FindTransportDevice(uint32_t bus, std::string & hidDeviceName, } closedir(devDir); - if (deviceFound) + if (deviceFound) { + if (bus == BUS_I2C) { + std::fstream ueventfile; + std::string ueventfilepath = fullLinkPath + "/uevent"; + std::string uevent; + std::string modulename; + ueventfile.open(ueventfilepath.c_str(), std::ios::in); + if(ueventfile.is_open()) { + getline(ueventfile, uevent); + modulename = uevent.substr(uevent.find("=") + 1, std::string::npos); + driverPath = devicePrefix + "drivers/"; + driverPath += modulename; + driverPath += "/"; + } + ueventfile.close(); + } break; + } + } closedir(devicesDir); diff --git a/rmidevice/hiddevice.h b/rmidevice/hiddevice.h index 7ee5e1b..93b1ed8 100755 --- a/rmidevice/hiddevice.h +++ b/rmidevice/hiddevice.h @@ -20,6 +20,7 @@ #include <linux/hidraw.h> #include <string> +#include <fstream> #include <stdint.h> #include "rmidevice.h" |