Fix CPU detection GPIO handling logic
This commit fixes CPU detection GPIO handling logic to support
the latest kernel SGPIO driver which creates a single gpiochip cdev
entry, /dev/gpiochip1.
Change-Id: I386d3d6831b55d553635e71900299bd840f57906
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
diff --git a/include/CPUSensor.hpp b/include/CPUSensor.hpp
index 1c25655..65f30e7 100644
--- a/include/CPUSensor.hpp
+++ b/include/CPUSensor.hpp
@@ -59,7 +59,9 @@
return findIndex->second;
}
+ // todo: need to change this number based setting to name based
constexpr size_t sgpioBase = 232;
+ constexpr const char* labelSgpiochipIn = "1e780200.sgpio";
// check if sysfs has device
bool sysfs = std::filesystem::exists(gpioPath + std::string("gpio") +
@@ -80,9 +82,8 @@
}
}
- size_t chipNum = (gpioNum - sgpioBase) / 8;
- size_t index = (gpioNum - sgpioBase) % 8;
- gpiod::chip chip("gpiochip" + std::to_string(chipNum));
+ size_t index = gpioNum - sgpioBase;
+ gpiod::chip chip(labelSgpiochipIn);
auto line = chip.get_line(index);
if (!line)