From b76cd8a5f62ff304480c1088bd020d186d6eaee5 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Wed, 27 Dec 2023 13:05:07 +0100 Subject: [PATCH] sysfs: Specific match has to go before generic match This is not really a problem when the specific scaling factors happen to be for factors not matched by a generic match but this may not hold in general over time. Fixes: 1bd92120 ("Fill the magnitude field of dynamically generated device entries.") --- lib/sysfs.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/sysfs.c b/lib/sysfs.c index 8d6a5e72..d767578d 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -141,6 +141,17 @@ char sensors_sysfs_mount[NAME_MAX]; static int get_type_scaling(sensors_subfeature_type type) { + /* Multipliers for second class subfeatures + that need their own multiplier */ + switch (type) { + case SENSORS_SUBFEATURE_POWER_AVERAGE_INTERVAL: + case SENSORS_SUBFEATURE_VID: + case SENSORS_SUBFEATURE_TEMP_OFFSET: + return 1000; + default: + break; + } + /* Multipliers for subfeatures */ switch (type & 0xFF80) { case SENSORS_SUBFEATURE_IN_INPUT: @@ -157,16 +168,7 @@ int get_type_scaling(sensors_subfeature_type type) return 1000000; } - /* Multipliers for second class subfeatures - that need their own multiplier */ - switch (type) { - case SENSORS_SUBFEATURE_POWER_AVERAGE_INTERVAL: - case SENSORS_SUBFEATURE_VID: - case SENSORS_SUBFEATURE_TEMP_OFFSET: - return 1000; - default: - return 1; - } + return 1; } static