aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Chiu <dchiu@synaptics.com>2022-02-24 16:34:23 +0800
committerVincent Huang <vincenthsw@gmail.com>2022-03-01 10:45:24 +0800
commite9115fa74a72e9a267ec6c08b8df8cd05d4f9085 (patch)
tree289161f4f73093076738e2ad5983d94babb227a4
parent115762374d337c515587a02a387a845a4d6bdb6b (diff)
downloadrmi4utils-e9115fa74a72e9a267ec6c08b8df8cd05d4f9085.tar.gz
Parsing driver name instead of assigning one
-rwxr-xr-xrmidevice/hiddevice.cpp30
-rwxr-xr-xrmidevice/hiddevice.h1
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"