summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndřej Lysoněk <olysonek@redhat.com>2018-11-06 15:49:11 +0100
committerOndřej Lysoněk <olysonek@redhat.com>2018-11-23 12:17:01 +0100
commit7e976f1325e55b5e26a63c8f9c7af0cb9aac3aa7 (patch)
tree068a989135239fbd948f825d32d144b21a821816
parentd4cb932567407cc3cfb40fa11763a7459a278741 (diff)
downloadlm-sensors-git-7e976f1325e55b5e26a63c8f9c7af0cb9aac3aa7.tar.gz
libsensors: Treat devices without a known ancestor bus as virtual
Currently only hwmon devices that don't have a parent device are treated as virtual. Let's extend the concept to hwmon devices, that don't have a *recognized ancestor* device (hwmon devices that according to the kernel don't reside on a bus that we recognize). This change is meant to address cases where a hwmon device has a thermal class device for a parent, but the thermal class device doesn't have a parent device. These kind of hwmon devices started appearing in the 4.19 kernel due to commit f6b6b52ef7a54160c0. It was not reported as a kernel regression and fixed in the kernel, because according to Documentation/admin-guide/sysfs-rules.rst, the change was OK to make (it says "Position of devices along device chain can change"). Fixes #139 Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
-rw-r--r--lib/sysfs.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/sysfs.c b/lib/sysfs.c
index 1691b9f5..e63688b7 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -759,6 +759,7 @@ static int sensors_read_one_sysfs_chip(const char *dev_path,
const char *hwmon_path)
{
int ret = 1;
+ int virtual = 0;
sensors_chip_features entry;
/* ignore any device without name attribute */
@@ -770,15 +771,22 @@ static int sensors_read_one_sysfs_chip(const char *dev_path,
sensors_fatal_error(__func__, "Out of memory");
if (dev_path == NULL) {
+ virtual = 1;
+ } else {
+ ret = find_bus_type(dev_path, dev_name, &entry);
+ if (ret == 0) {
+ virtual = 1;
+ ret = 1;
+ } else if (ret < 0) {
+ goto exit_free;
+ }
+ }
+ if (virtual) {
/* Virtual device */
entry.chip.bus.type = SENSORS_BUS_TYPE_VIRTUAL;
entry.chip.bus.nr = 0;
/* For now we assume that virtual devices are unique */
entry.chip.addr = 0;
- } else {
- ret = find_bus_type(dev_path, dev_name, &entry);
- if (ret <= 0)
- goto exit_free;
}
if (sensors_read_dynamic_chip(&entry, hwmon_path) < 0) {