From fb5c1fd230022aa71293ba988e821ef1d65a59bf Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 28 Mar 2004 13:01:34 +0000 Subject: [PATCH] Change pcf8591 magnitude (libsensors only) so as to display values in pseudo-volts, much like what the 2.6 driver handles. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2398 7894878c-1315-0410-8ee3-d5d059ff63e0 --- lib/chips.c | 10 +++++----- prog/sensors/chips.c | 36 ++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/chips.c b/lib/chips.c index 1a8d53ee..1bdc0a82 100644 --- a/lib/chips.c +++ b/lib/chips.c @@ -4083,17 +4083,17 @@ static sensors_chip_feature fscscy_features[] = { SENSORS_PCF8591_AIN_CONF, "ain_conf", NOMAP, NOMAP, RW, PCF8591_SYSCTL_AIN_CONF, VALUE(1), 0 }, { SENSORS_PCF8591_CH0, "ch0", NOMAP, NOMAP, - R, PCF8591_SYSCTL_CH0, VALUE(1), 0, "in0_input", 3 }, + R, PCF8591_SYSCTL_CH0, VALUE(1), 2, "in0_input", 3 }, { SENSORS_PCF8591_CH1, "ch1", NOMAP, NOMAP, - R, PCF8591_SYSCTL_CH1, VALUE(1), 0, "in1_input", 3 }, + R, PCF8591_SYSCTL_CH1, VALUE(1), 2, "in1_input", 3 }, { SENSORS_PCF8591_CH2, "ch2", NOMAP, NOMAP, - R, PCF8591_SYSCTL_CH2, VALUE(1), 0, "in2_input", 3 }, + R, PCF8591_SYSCTL_CH2, VALUE(1), 2, "in2_input", 3 }, { SENSORS_PCF8591_CH3, "ch3", NOMAP, NOMAP, - R, PCF8591_SYSCTL_CH3, VALUE(1), 0, "in3_input", 3 }, + R, PCF8591_SYSCTL_CH3, VALUE(1), 2, "in3_input", 3 }, { SENSORS_PCF8591_AOUT_ENABLE, "aout_enable", NOMAP, NOMAP, RW, PCF8591_SYSCTL_AOUT_ENABLE, VALUE(1), 0, "out0_enable", 0 }, { SENSORS_PCF8591_AOUT, "aout", NOMAP, NOMAP, - RW, PCF8591_SYSCTL_AOUT, VALUE(1), 0, "out0_output", 3 }, + RW, PCF8591_SYSCTL_AOUT, VALUE(1), 2, "out0_output", 3 }, { 0 } }; diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c index 37a06c20..8417c173 100644 --- a/prog/sensors/chips.c +++ b/prog/sensors/chips.c @@ -3666,15 +3666,17 @@ void print_fscher(const sensors_chip_name *name) void print_pcf8591(const sensors_chip_name *name) { char *label; - double ain_conf, ch0, ch1, ch2, ch3; + int ain_conf = -1; + double ain; double aout_enable, aout; int valid; if (!sensors_get_label_and_valid(*name,SENSORS_PCF8591_AIN_CONF,&label,&valid) && - !sensors_get_feature(*name,SENSORS_PCF8591_AIN_CONF,&ain_conf)) { + !sensors_get_feature(*name, SENSORS_PCF8591_AIN_CONF, &ain)) { + ain_conf = (int)ain; if (valid) { print_label(label,10); - switch ((int)ain_conf) + switch (ain_conf) { case 0: printf("four single ended inputs\n"); break; @@ -3687,24 +3689,24 @@ void print_pcf8591(const sensors_chip_name *name) } } } - else printf("ERROR: Can't read analog inputs configuration!\n"); + /* display no error, 2.6 driver doesn't have that file */ free_the_label(&label); if (!sensors_get_label_and_valid(*name,SENSORS_PCF8591_CH0,&label,&valid) && - !sensors_get_feature(*name,SENSORS_PCF8591_CH0,&ch0)) { + !sensors_get_feature(*name, SENSORS_PCF8591_CH0, &ain)) { if (valid) { print_label(label,10); - printf("%0.0f\n", ch0); + printf("%6.2fV\n", ain); } } else printf("ERROR: Can't read ch0!\n"); free_the_label(&label); if (!sensors_get_label_and_valid(*name,SENSORS_PCF8591_CH1,&label,&valid) && - !sensors_get_feature(*name,SENSORS_PCF8591_CH1,&ch1)) { + !sensors_get_feature(*name, SENSORS_PCF8591_CH1, &ain)) { if (valid) { print_label(label,10); - printf("%0.0f\n", ch1); + printf("%6.2fV\n", ain); } } else printf("ERROR: Can't read ch1!\n"); @@ -3712,25 +3714,27 @@ void print_pcf8591(const sensors_chip_name *name) if (ain_conf != 3) { if (!sensors_get_label_and_valid(*name,SENSORS_PCF8591_CH2,&label,&valid) && - !sensors_get_feature(*name,SENSORS_PCF8591_CH2,&ch2)) { + !sensors_get_feature(*name, SENSORS_PCF8591_CH2, &ain)) { if (valid) { print_label(label,10); - printf("%0.0f\n", ch2); + printf("%6.2fV\n", ain); } } - else printf("ERROR: Can't read ch2!\n"); + else if (ain_conf >= 0) /* hide error for 2.6 kernel driver */ + printf("ERROR: Can't read ch2!\n"); free_the_label(&label); } - if (ain_conf == 0) { + if (ain_conf <= 0) { if (!sensors_get_label_and_valid(*name,SENSORS_PCF8591_CH3,&label,&valid) && - !sensors_get_feature(*name,SENSORS_PCF8591_CH3,&ch3)) { + !sensors_get_feature(*name, SENSORS_PCF8591_CH3, &ain)) { if (valid) { print_label(label,10); - printf("%0.0f\n", ch3); + printf("%6.2fV\n", ain); } } - else printf("ERROR: Can't read ch3!\n"); + else if (ain_conf >= 0) /* hide error for 2.6 kernel driver */ + printf("ERROR: Can't read ch3!\n"); free_the_label(&label); } @@ -3739,7 +3743,7 @@ void print_pcf8591(const sensors_chip_name *name) !sensors_get_feature(*name,SENSORS_PCF8591_AOUT_ENABLE,&aout_enable)) { if (valid) { print_label(label,10); - printf("%0.0f (%s)\n", aout, aout_enable?"enabled":"disabled"); + printf("%6.2fV (%s)\n", aout, aout_enable?"enabled":"disabled"); } } else printf("ERROR: Can't read aout!\n");