On Fri, 25 May 2007 15:47:50 +0200, Jean Delvare wrote: > Here is the patch I have come up with, which fixes both problems and > makes the generic code work for my ADM1032. Can you please review it and > confirm that it doesn't break anything on your side? Thanks. I spoke a bit too fast. There was actually a third problem, alarms weren't reported. This is because the ADM1032 has per-limit alarm flags and the generic code only supported per-channel alarms for temperatures. So here is a more complete patch which fixes all three problems. Index: lib/sensors.h =================================================================== --- lib/sensors.h (r?vision 4405) +++ lib/sensors.h (copie de travail) @@ -166,15 +166,20 @@ SENSORS_FEATURE_FAN_DIV, SENSORS_FEATURE_TEMP = 0x200, - SENSORS_FEATURE_TEMP_HYST, SENSORS_FEATURE_TEMP_OVER, SENSORS_FEATURE_TEMP_MAX, + SENSORS_FEATURE_TEMP_MAX_HYST, SENSORS_FEATURE_TEMP_MIN, + SENSORS_FEATURE_TEMP_MIN_HYST, SENSORS_FEATURE_TEMP_HIGH, SENSORS_FEATURE_TEMP_LOW, SENSORS_FEATURE_TEMP_LIM, SENSORS_FEATURE_TEMP_CRIT, + SENSORS_FEATURE_TEMP_CRIT_HYST, SENSORS_FEATURE_TEMP_ALARM = 0x210, + SENSORS_FEATURE_TEMP_MAX_ALARM, + SENSORS_FEATURE_TEMP_MIN_ALARM, + SENSORS_FEATURE_TEMP_CRIT_ALARM, SENSORS_FEATURE_TEMP_FAULT, SENSORS_FEATURE_TEMP_SENS, @@ -185,7 +190,7 @@ /* special the largest number of subfeatures used, iow the highest ## from all the 0x?## above + 1*/ - SENSORS_FEATURE_MAX_SUB_FEATURES = 19 + SENSORS_FEATURE_MAX_SUB_FEATURES = 22 } sensors_feature_type; sensors_feature_type sensors_feature_get_type Index: lib/access.c =================================================================== --- lib/access.c (r?vision 4405) +++ lib/access.c (copie de travail) @@ -515,13 +515,18 @@ }; static struct feature_type_match temp_matches[] = { - { "hyst", SENSORS_FEATURE_TEMP_HYST }, { "over", SENSORS_FEATURE_TEMP_OVER }, { "max", SENSORS_FEATURE_TEMP_MAX }, + { "max_hyst", SENSORS_FEATURE_TEMP_MAX_HYST }, { "min", SENSORS_FEATURE_TEMP_MIN }, + { "min_hyst", SENSORS_FEATURE_TEMP_MIN_HYST }, { "low", SENSORS_FEATURE_TEMP_LOW }, { "crit", SENSORS_FEATURE_TEMP_CRIT }, + { "crit_hyst", SENSORS_FEATURE_TEMP_CRIT_HYST }, { "alarm", SENSORS_FEATURE_TEMP_ALARM }, + { "min_alarm", SENSORS_FEATURE_TEMP_MIN_ALARM }, + { "max_alarm", SENSORS_FEATURE_TEMP_MAX_ALARM }, + { "crit_alarm", SENSORS_FEATURE_TEMP_CRIT_ALARM }, { "fault", SENSORS_FEATURE_TEMP_FAULT }, { "type", SENSORS_FEATURE_TEMP_SENS }, { 0 } Index: lib/sysfs.c =================================================================== --- lib/sysfs.c (r?vision 4405) +++ lib/sysfs.c (copie de travail) @@ -37,6 +37,29 @@ #define MAX_SENSORS_PER_TYPE 16 +static +int get_type_scaling(int type) +{ + switch (type & 0xFF10) { + case SENSORS_FEATURE_IN: + case SENSORS_FEATURE_TEMP: + return 3; + case SENSORS_FEATURE_FAN: + return 0; + } + + switch (type) { + case SENSORS_FEATURE_VID: + return 3; + case SENSORS_FEATURE_VRM: + return 1; + default: + return 0; + } + + return 0; +} + static sensors_chip_features sensors_read_dynamic_chip(struct sysfs_device *sysdir) { @@ -149,6 +172,8 @@ SENSORS_MODE_R : (attr->method & SYSFS_METHOD_STORE) ? SENSORS_MODE_W : SENSORS_MODE_NO_RW; + feature.scaling = get_type_scaling(type); + features[i] = feature; fnum++; } Index: prog/sensors/chips_generic.c =================================================================== --- prog/sensors/chips_generic.c (r?vision 4405) +++ prog/sensors/chips_generic.c (copie de travail) @@ -144,27 +144,16 @@ } else { type = MINMAX; } + } else if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_MAX_HYST)) { + min = TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_MAX_HYST); + type = HYST; } else if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_CRIT)) { min = TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_CRIT); type = CRIT; - } else if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_HYST)) { - min = TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_HYST); - type = HYST; } else { min = 0; type = MAXONLY; } - } else if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_HYST)) { - min = TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_HYST); - - if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_OVER)) { - max = TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_OVER); - type = HYST; - } else { - max = min; - max = 0; - type = HYSTONLY; - } } else if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_LOW)) { min = TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_LOW); @@ -208,24 +197,27 @@ if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_FAULT) && TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_FAULT) > 0.5) { printf(" FAULT"); - } else if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_ALARM) && - TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_ALARM) > 0.5) { + } else + if ((TEMP_FEATURE(SENSORS_FEATURE_TEMP_ALARM) && + TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_ALARM) > 0.5) + || (type == MINMAX && + TEMP_FEATURE(SENSORS_FEATURE_TEMP_MIN_ALARM) && + TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_MIN_ALARM) > 0.5) + || (type == MINMAX && + TEMP_FEATURE(SENSORS_FEATURE_TEMP_MAX_ALARM) && + TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_MAX_ALARM) > 0.5)) { printf(" ALARM"); } printf("\n"); - if (type == MINMAX && TEMP_FEATURE(SENSORS_FEATURE_TEMP_CRIT)) + if (type != CRIT && TEMP_FEATURE(SENSORS_FEATURE_TEMP_CRIT)) { const sensors_feature_data *subfeature; max = TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_CRIT); - if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_HYST)) { - min = TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_HYST); + if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_CRIT_HYST)) { + min = TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_CRIT_HYST); type = HYSTONLY; - } else if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_MAX) && - !TEMP_FEATURE(SENSORS_FEATURE_TEMP_MIN)) { - min = TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_MAX); - type = HYSTONLY; } else { type = SINGLE; min = 0.0; @@ -239,7 +231,11 @@ if (valid) { print_label(label, label_size); free(label); - print_temp_info_real(max, min, 0, 0.0, type, 1, 0); + print_temp_info_real(max, min, 0, 0.0, type, 1, 1); + if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_CRIT_ALARM) && + TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_CRIT_ALARM) > 0.5) { + printf(" ALARM"); + } printf("\n"); } } -- Jean Delvare