diff --git a/lib/sensors.h b/lib/sensors.h index c8350295..2a84a5b3 100644 --- a/lib/sensors.h +++ b/lib/sensors.h @@ -276,6 +276,25 @@ typedef struct sensors_quantity { const sensors_quantity *sensors_get_quantity(sensors_subfeature_type) __attribute__ ((const)); +static inline const char *sensors_temp_type_name(int sens) +{ + /* older kernels / drivers sometimes report a beta value for + thermistors */ + if (sens > 1000) + sens = 4; + + switch (sens) { + case 0: return "disabled"; + case 1: return "CPU diode"; + case 2: return "transistor"; + case 3: return "thermal diode"; + case 4: return "thermistor"; + case 5: return "AMD AMDSI"; + case 6: return "Intel PECI"; + default: return "unknown"; + } +} + /* Data about a single chip feature (or category leader) */ struct sensors_feature { char *name; diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c index 311b1daa..c847db78 100644 --- a/prog/sensors/chips.c +++ b/prog/sensors/chips.c @@ -409,13 +409,7 @@ static void print_chip_temp(const sensors_chip_name *name, if (sens > 1000) sens = 4; - printf(" sensor = %s", sens == 0 ? "disabled" : - sens == 1 ? "CPU diode" : - sens == 2 ? "transistor" : - sens == 3 ? "thermal diode" : - sens == 4 ? "thermistor" : - sens == 5 ? "AMD AMDSI" : - sens == 6 ? "Intel PECI" : "unknown"); + printf(" sensor = %s", sensors_temp_type_name(sens)); } printf("\n"); }