mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-30 22:05:11 +00:00
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>
This commit is contained in:
16
lib/sysfs.c
16
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) {
|
||||
|
Reference in New Issue
Block a user