hwmon: (ltc4245) fix GPIO support
v2 cover hwmon: (ltc4245) fix GPIO support
This patch series fixes support for using a GPIO line as an analog input to the ADC on the LTC4245 chip. Jean suggested dropping support for multiple GPIO lines, and then adding it back as an optional feature.
I think this is fairly unintrusive to the ltc4245 code, and the multi-GPIO support is well encapsulated in a seperate function, hidden behind a kernel configuration option.
I have tested the sensors utility with the -EAGAIN code for stale values. The output looks like this:
ltc4245-i2c-1-22
12V Input: +11.66 V
5.0V Input: +5.10 V 3.3V Input: +3.19 V VEE Input: +0.00 V 12V Output: +11.66 V 5.0V Output: +5.08 V 3.3V Output: +3.19 V VEE Output: +0.00 V
Dig 3.30v Output: +3.26 V
ERROR: Can't get value of subfeature in10_input: Can't read Dig 2.25v Output: +0.00 V
ERROR: Can't get value of subfeature in11_input: Can't read Dig 1.80v Output: +0.00 V
12V Power: 816.20 mW
5.0V Power: 4.90 W 3.3V Power: 1.44 W VEE Power: 0.00 nW 12V Current: +0.07 A 5.0V Current: +0.96 A 3.3V Current: +0.45 A VEE Current: +0.00 A
Using cat to read the inX_input nodes, I get the expected output:
cat: in9_input: Resource temporarily unavailable
So I think that the lm-sensors software will handle this method of showing stale values just fine.
Thanks,
Ira
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 34 lines · Ira W. Snyder
This patch series fixes support for using a GPIO line as an analog input to the ADC on the LTC4245 chip. Jean suggested dropping support for multiple GPIO lines, and then adding it back as an optional feature.
I think this is fairly unintrusive to the ltc4245 code, and the multi-GPIO support is well encapsulated in a seperate function, hidden behind a kernel configuration option.
I have tested the sensors utility with the
-EAGAINcode for stale values. The output looks like this:ltc4245-i2c-1-22
12V Input: +11.66 V5.0V Input: +5.10 V 3.3V Input: +3.19 V VEE Input: +0.00 V 12V Output: +11.66 V 5.0V Output: +5.08 V 3.3V Output: +3.19 V VEE Output: +0.00 VDig 3.30v Output: +3.26 V
ERROR: Can't get value of subfeaturein10_input: Can't read Dig 2.25v Output: +0.00 V
ERROR: Can't get value of subfeaturein11_input: Can't read Dig 1.80v Output: +0.00 V
12V Power: 816.20 mW5.0V Power: 4.90 W 3.3V Power: 1.44 W VEE Power: 0.00 nW 12V Current: +0.07 A 5.0V Current: +0.96 A 3.3V Current: +0.45 A VEE Current: +0.00 A
Quoted 7 lines
Using cat to read the
inX_inputnodes, I get the expected output:cat:
in9_input: Resource temporarily unavailableSo I think that the lm-sensors software will handle this method of showing stale values just fine.
Hey Jean,
Have you had time to look at this patch series yet?
Thanks,
Ira
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Ira,
Quoted 39 lines · Ira W. Snyder
Quoted 38 lines · Ira W. Snyder
This patch series fixes support for using a GPIO line as an analog input to the ADC on the LTC4245 chip. Jean suggested dropping support for multiple GPIO lines, and then adding it back as an optional feature.
I think this is fairly unintrusive to the ltc4245 code, and the multi-GPIO support is well encapsulated in a seperate function, hidden behind a kernel configuration option.
I have tested the sensors utility with the
-EAGAINcode for stale values. The output looks like this:ltc4245-i2c-1-22
12V Input: +11.66 V5.0V Input: +5.10 V 3.3V Input: +3.19 V VEE Input: +0.00 V 12V Output: +11.66 V 5.0V Output: +5.08 V 3.3V Output: +3.19 V VEE Output: +0.00 VDig 3.30v Output: +3.26 V
ERROR: Can't get value of subfeaturein10_input: Can't read Dig 2.25v Output: +0.00 V
ERROR: Can't get value of subfeaturein11_input: Can't read Dig 1.80v Output: +0.00 V
12V Power: 816.20 mW5.0V Power: 4.90 W 3.3V Power: 1.44 W VEE Power: 0.00 nW 12V Current: +0.07 A 5.0V Current: +0.96 A 3.3V Current: +0.45 A VEE Current: +0.00 AUsing cat to read the
inX_inputnodes, I get the expected output:cat:
in9_input: Resource temporarily unavailable
Quoted 7 lines
Quoted 3 lines
So I think that the lm-sensors software will handle this method of showing stale values just fine.
Hey Jean,
Have you had time to look at this patch series yet?
I'm sorry, this has been on the back burner for quite some time now :( I still hope to get your patches reviewed in time for 2.6.35.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Ira,
Quoted 34 lines · Ira W. Snyder
This patch series fixes support for using a GPIO line as an analog input to the ADC on the LTC4245 chip. Jean suggested dropping support for multiple GPIO lines, and then adding it back as an optional feature.
I think this is fairly unintrusive to the ltc4245 code, and the multi-GPIO support is well encapsulated in a seperate function, hidden behind a kernel configuration option.
I have tested the sensors utility with the
-EAGAINcode for stale values. The output looks like this:ltc4245-i2c-1-22
12V Input: +11.66 V5.0V Input: +5.10 V 3.3V Input: +3.19 V VEE Input: +0.00 V 12V Output: +11.66 V 5.0V Output: +5.08 V 3.3V Output: +3.19 V VEE Output: +0.00 VDig 3.30v Output: +3.26 V
ERROR: Can't get value of subfeaturein10_input: Can't read Dig 2.25v Output: +0.00 V
ERROR: Can't get value of subfeaturein11_input: Can't read Dig 1.80v Output: +0.00 V
12V Power: 816.20 mW5.0V Power: 4.90 W 3.3V Power: 1.44 W VEE Power: 0.00 nW 12V Current: +0.07 A 5.0V Current: +0.96 A 3.3V Current: +0.45 A VEE Current: +0.00 A
Quoted 6 lines
Using cat to read the
inX_inputnodes, I get the expected output:cat:
in9_input: Resource temporarily unavailableSo I think that the lm-sensors software will handle this method of showing stale values just fine.
I still think the current error handling is less than ideal. If it becomes common that hwmon drivers return errors, I'd prefer them to look nice in the output of "sensors". Something like:
Quoted 3 lines
Dig 3.30v Output: +3.26 V Dig 2.25v Output: N/A Dig 1.80v Output: N/A
Hopefully this wouldn't be too hard to implement. What do you think?
We might have to invent new libsensors error codes to differentiate between error cases, or give callers a way to retrieve the original error code.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 52 lines · Jean Delvare
Hi Ira,
Quoted 34 lines · Ira W. Snyder
This patch series fixes support for using a GPIO line as an analog input to the ADC on the LTC4245 chip. Jean suggested dropping support for multiple GPIO lines, and then adding it back as an optional feature.
I think this is fairly unintrusive to the ltc4245 code, and the multi-GPIO support is well encapsulated in a seperate function, hidden behind a kernel configuration option.
I have tested the sensors utility with the
-EAGAINcode for stale values. The output looks like this:ltc4245-i2c-1-22
12V Input: +11.66 V5.0V Input: +5.10 V 3.3V Input: +3.19 V VEE Input: +0.00 V 12V Output: +11.66 V 5.0V Output: +5.08 V 3.3V Output: +3.19 V VEE Output: +0.00 VDig 3.30v Output: +3.26 V
ERROR: Can't get value of subfeaturein10_input: Can't read Dig 2.25v Output: +0.00 V
ERROR: Can't get value of subfeaturein11_input: Can't read Dig 1.80v Output: +0.00 V
12V Power: 816.20 mW5.0V Power: 4.90 W 3.3V Power: 1.44 W VEE Power: 0.00 nW 12V Current: +0.07 A 5.0V Current: +0.96 A 3.3V Current: +0.45 A VEE Current: +0.00 AQuoted 6 lines
Using cat to read the
inX_inputnodes, I get the expected output:cat:
in9_input: Resource temporarily unavailableSo I think that the lm-sensors software will handle this method of showing stale values just fine.
I still think the current error handling is less than ideal. If it becomes common that hwmon drivers return errors, I'd prefer them to look nice in the output of "sensors". Something like:
Quoted 3 lines
Dig 3.30v Output: +3.26 V Dig 2.25v Output: N/A Dig 1.80v Output: N/A
Quoted 6 lines
Hopefully this wouldn't be too hard to implement. What do you think?
We might have to invent new libsensors error codes to differentiate between error cases, or give callers a way to retrieve the original error code.
I agree, that would be nice. That's a libsensors patch, not a kernel patch though.
Ira
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Ira,
Quoted 9 lines · Ira W. Snyder
Quoted 8 lines · Jean Delvare
I still think the current error handling is less than ideal. If it becomes common that hwmon drivers return errors, I'd prefer them to look nice in the output of "sensors". Something like:
Dig 3.30v Output: +3.26 V Dig 2.25v Output: N/A Dig 1.80v Output: N/A
Quoted 8 lines
Quoted 5 lines
Hopefully this wouldn't be too hard to implement. What do you think?
We might have to invent new libsensors error codes to differentiate between error cases, or give callers a way to retrieve the original error code.
I agree, that would be nice. That's a libsensors patch, not a kernel patch though.
A more immediate action would actually be a sensors patch. I get the following output for my thinkpad with the attached patch applied:
thinkpad-isa-0000
Adapter: ISA adapter fan1: 3430 RPM temp1: +62.0°C temp2: +46.0°C temp3: +44.0°C temp4: +75.0°C temp5: +50.0°C temp6: N/A temp7: +37.0°C temp8: N/A temp9: +48.0°C temp10: +58.0°C temp11: +58.0°C temp12: N/A temp13: N/A temp14: N/A temp15: N/A temp16: N/A
Would this be OK with you?
--- prog/sensors/chips.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-)
prog/sensors/chips.c +28 -14
@@ -91,6 +91,21 @@ static double get_value(const sensors_chreturn val; } +/* A variant for input values, where we want to handle errors gracefully */ +static int get_input_value (const sensors_chip_name *name, +const sensors_subfeature *sub, +double *val) +{ +int err; + + err =sensors_get_value (name, sub->number, val); +if (err && err != -SENSORS_ERR_ACCESS_R ) { +fprintf (stderr,"ERROR: Can't get value of subfeature %s: %s\n" , + sub->name,sensors_strerror (err)); + } +return err; +} +static int get_label_size (const sensors_chip_name *name) {int i;
@@ -230,8 +245,8 @@ static void print_chip_temp(const sensor }else { sf =sensors_get_subfeature (name, feature,SENSORS_SUBFEATURE_TEMP_INPUT ); -if (sf) { - val =get_value (name, sf); +if (sf &&get_input_value (name, sf, &val) =0 ) { +get_input_value (name, sf, &val);if (fahrenheit) val =deg_ctof (val);printf ("%+6.1f%s " , val, degstr);
@@ -289,7 +304,7 @@ static void print_chip_in(const sensors_ int label_size) {const sensors_subfeature *sf, *sfmin, *sfmax; -double alarm_max, alarm_min; +double val, alarm_max, alarm_min;char *label;if (!(label =sensors_get_label (name, feature))) {
@@ -302,8 +317,8 @@ static void print_chip_in(const sensors_ sf =sensors_get_subfeature (name, feature,SENSORS_SUBFEATURE_IN_INPUT ); -if (sf) -printf ("%+6.2f V" ,get_value (name, sf)); +if (sf &&get_input_value (name, sf, &val) =0 ) +printf ("%+6.2f V" , val);else printf (" N/A" );
@@ -355,6 +370,7 @@ static void print_chip_fan(const sensors int label_size) {const sensors_subfeature *sf, *sfmin, *sfdiv; +double val;char *label;if (!(label =sensors_get_label (name, feature))) {
@@ -372,8 +388,8 @@ static void print_chip_fan(const sensorselse { sf =sensors_get_subfeature (name, feature,SENSORS_SUBFEATURE_FAN_INPUT ); -if (sf) -printf ("%4.0f RPM" ,get_value (name, sf)); +if (sf &&get_input_value (name, sf, &val) =0 ) +printf ("%4.0f RPM" , val);else printf (" N/A" ); }
@@ -471,8 +487,7 @@ static void print_chip_power(const senso SENSORS_SUBFEATURE_POWER_AVERAGE_INTERVAL); } -if (sf) { - val =get_value (name, sf); +if (sf &&get_input_value (name, sf, &val) =0 ) {scale_value (&val, &unit);printf ("%6.2f %sW" , val, unit); }else
@@ -526,8 +541,7 @@ static void print_chip_energy(const sens sf =sensors_get_subfeature (name, feature,SENSORS_SUBFEATURE_ENERGY_INPUT ); -if (sf) { - val =get_value (name, sf); +if (sf &&get_input_value (name, sf, &val) =0 ) {scale_value (&val, &unit);printf ("%6.2f %sJ" , val, unit); }else
@@ -583,7 +597,7 @@ static void print_chip_curr(const sensor int label_size) {const sensors_subfeature *sf, *sfmin, *sfmax; -double alarm_max, alarm_min; +double alarm_max, alarm_min, val;char *label;if (!(label =sensors_get_label (name, feature))) {
@@ -596,8 +610,8 @@ static void print_chip_curr(const sensor sf =sensors_get_subfeature (name, feature,SENSORS_SUBFEATURE_CURR_INPUT ); -if (sf) -printf ("%+6.2f A" ,get_value (name, sf)); +if (sf &&get_input_value (name, sf, &val) =0 ) +printf ("%+6.2f A" , val);else printf (" N/A" );
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 44 lines · On Sat, 22 May 2010 13:53:50 +0200 Jean Delvare <[email protected]> wrote:
Hi Ira,
Quoted 9 lines · Ira W. Snyder
Quoted 8 lines · Jean Delvare
I still think the current error handling is less than ideal. If it becomes common that hwmon drivers return errors, I'd prefer them to look nice in the output of "sensors". Something like:
Dig 3.30v Output: +3.26 V Dig 2.25v Output: N/A Dig 1.80v Output: N/AQuoted 8 lines
Quoted 5 lines
Hopefully this wouldn't be too hard to implement. What do you think?
We might have to invent new libsensors error codes to differentiate between error cases, or give callers a way to retrieve the original error code.
I agree, that would be nice. That's a libsensors patch, not a kernel patch though.
A more immediate action would actually be a sensors patch. I get the following output for my thinkpad with the attached patch applied:
thinkpad-isa-0000
Adapter: ISA adapter fan1: 3430 RPM temp1: +62.0°C temp2: +46.0°C temp3: +44.0°C temp4: +75.0°C temp5: +50.0°C temp6: N/A temp7: +37.0°C temp8: N/A temp9: +48.0°C temp10: +58.0°C temp11: +58.0°C temp12: N/A temp13: N/A temp14: N/A temp15: N/A temp16: N/A
Quoted 2 lines
Would this be OK with you?
That looks fine to me. I'm using libsensors (but not the sensors program itself, except when debugging) to read my chips. The output certainly is much nicer, though.
Ira
Quoted 124 lines
--- prog/sensors/chips.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-)prog/sensors/chips.c +28
-14@@ -91,6 +91,21 @@ static double get_value(const sensors_chreturn val; } +/* A variant for input values, where we want to handle errors gracefully */ +static int get_input_value (const sensors_chip_name *name, +const sensors_subfeature *sub, +double *val) +{ +int err; + + err =sensors_get_value (name, sub->number, val); +if (err && err != -SENSORS_ERR_ACCESS_R ) { +fprintf (stderr,"ERROR: Can't get value of subfeature %s: %s\n" , + sub->name,sensors_strerror (err)); + } +return err; +} +static int get_label_size (const sensors_chip_name *name) {int i;@@ -230,8 +245,8 @@ static void print_chip_temp(const sensor }else { sf =sensors_get_subfeature (name, feature,SENSORS_SUBFEATURE_TEMP_INPUT ); -if (sf) { - val =get_value (name, sf); +if (sf &&get_input_value (name, sf, &val) =0 ) { +get_input_value (name, sf, &val);if (fahrenheit) val =deg_ctof (val);printf ("%+6.1f%s " , val, degstr);@@ -289,7 +304,7 @@ static void print_chip_in(const sensors_ int label_size) {const sensors_subfeature *sf, *sfmin, *sfmax; -double alarm_max, alarm_min; +double val, alarm_max, alarm_min;char *label;if (!(label =sensors_get_label (name, feature))) {@@ -302,8 +317,8 @@ static void print_chip_in(const sensors_ sf =sensors_get_subfeature (name, feature,SENSORS_SUBFEATURE_IN_INPUT ); -if (sf) -printf ("%+6.2f V" ,get_value (name, sf)); +if (sf &&get_input_value (name, sf, &val) =0 ) +printf ("%+6.2f V" , val);else printf (" N/A" );@@ -355,6 +370,7 @@ static void print_chip_fan(const sensors int label_size) {const sensors_subfeature *sf, *sfmin, *sfdiv; +double val;char *label;if (!(label =sensors_get_label (name, feature))) {@@ -372,8 +388,8 @@ static void print_chip_fan(const sensorselse { sf =sensors_get_subfeature (name, feature,SENSORS_SUBFEATURE_FAN_INPUT ); -if (sf) -printf ("%4.0f RPM" ,get_value (name, sf)); +if (sf &&get_input_value (name, sf, &val) =0 ) +printf ("%4.0f RPM" , val);else printf (" N/A" ); }@@ -471,8 +487,7 @@ static void print_chip_power(const senso SENSORS_SUBFEATURE_POWER_AVERAGE_INTERVAL); } -if (sf) { - val =get_value (name, sf); +if (sf &&get_input_value (name, sf, &val) =0 ) {scale_value (&val, &unit);printf ("%6.2f %sW" , val, unit); }else @@ -526,8 +541,7 @@ static void print_chip_energy(const sens sf =sensors_get_subfeature (name, feature,SENSORS_SUBFEATURE_ENERGY_INPUT ); -if (sf) { - val =get_value (name, sf); +if (sf &&get_input_value (name, sf, &val) =0 ) {scale_value (&val, &unit);printf ("%6.2f %sJ" , val, unit); }else @@ -583,7 +597,7 @@ static void print_chip_curr(const sensor int label_size) {const sensors_subfeature *sf, *sfmin, *sfmax; -double alarm_max, alarm_min; +double alarm_max, alarm_min, val;char *label;if (!(label =sensors_get_label (name, feature))) {@@ -596,8 +610,8 @@ static void print_chip_curr(const sensor sf =sensors_get_subfeature (name, feature,SENSORS_SUBFEATURE_CURR_INPUT ); -if (sf) -printf ("%+6.2f A" ,get_value (name, sf)); +if (sf &&get_input_value (name, sf, &val) =0 ) +printf ("%+6.2f A" , val);else printf (" N/A" );Signature · 2 lines
-- Jean Delvare
Signature · 6 lines
Ira Snyder <[email protected]> _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors