]> git.ipfire.org Git - thirdparty/lm-sensors.git/commitdiff
sysfs: Specific match has to go before generic match
authorMichal Suchanek <msuchanek@suse.de>
Wed, 27 Dec 2023 12:05:07 +0000 (13:05 +0100)
committerMichal Suchanek <msuchanek@suse.de>
Wed, 27 Dec 2023 12:17:16 +0000 (13:17 +0100)
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

index 8d6a5e7229bc539d65d597d2830d0664628624ee..d767578ddd9fefe9d9e8129aaf73d8fd94f1247a 100644 (file)
@@ -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