diff options
author | Leandro Pereira <leandro@hardinfo.org> | 2020-12-29 17:15:43 -0800 |
---|---|---|
committer | Leandro Pereira <leandro@hardinfo.org> | 2020-12-29 17:15:43 -0800 |
commit | 0039a86519d6aefd556be44caf48b6e5fb25e587 (patch) | |
tree | cc95fb8936db313e6c6b6896b85888b49c37420f /modules/devices | |
parent | c289d3564d982690daa18debab1ff2dc9fc1cda3 (diff) |
If we could find sensors with libsensors, don't bother with other methods
Diffstat (limited to 'modules/devices')
-rw-r--r-- | modules/devices/sensors.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/modules/devices/sensors.c b/modules/devices/sensors.c index 633a1185..e1b3a4a7 100644 --- a/modules/devices/sensors.c +++ b/modules/devices/sensors.c @@ -577,7 +577,6 @@ static void read_sensors_udisks2(void) { g_slist_free(temps); } -static gboolean libsensors_initialized; #if HAS_LIBSENSORS static const struct libsensors_feature_type { const char *type_name; @@ -598,13 +597,16 @@ static const struct libsensors_feature_type { [SENSORS_FEATURE_VID] = {"CPU Voltage", "bolt", "V", SENSORS_SUBFEATURE_VID}, }; -static void read_sensors_libsensors(void) { +static gboolean libsensors_initialized; + +static int read_sensors_libsensors(void) { char chip_name_buf[512]; const sensors_chip_name *name; int chip_nr = 0; + int added_sensors = 0; if (!libsensors_initialized) - return; + return 0; while ((name = sensors_get_detected_chips(NULL, &chip_nr))) { const struct sensors_feature *feat; @@ -638,9 +640,18 @@ static void read_sensors_libsensors(void) { free(label_with_chip); free(label); + + added_sensors++; } } } + + return added_sensors; +} +#else +static int read_sensors_libsensors(void) +{ + return 0; } #endif @@ -655,11 +666,13 @@ void scan_sensors_do(void) { g_free(lginterval); lginterval = g_strdup(""); - read_sensors_libsensors(); - read_sensors_hwmon(); - read_sensors_acpi(); - read_sensors_sys_thermal(); - read_sensors_omnibook(); + if (read_sensors_libsensors() == 0) { + read_sensors_hwmon(); + read_sensors_acpi(); + read_sensors_sys_thermal(); + read_sensors_omnibook(); + } + read_sensors_hddtemp(); read_sensors_udisks2(); } |