i8k: Properly handle errors
PATCH 1/1 i8k: Properly handle errors
My code originally didn't expect the temperature sensor to be missing, and also didn't properly handle run-time errors. This is fixed now.
Signed-off-by Jean Delvare <[email protected]>
Cc Guenter Roeck <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Massimo Dal Zotto <[email protected]>
---
I'll merge this fix in patch "i8k: Integrate with the hwmon subsystem".
drivers/char/i8k.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/char/i8k.c +18 -8
@@ -473,6 +473,8 @@ static ssize_t i8k_hwmon_show_temp(strucint cpu_temp; cpu_temp =i8k_get_temp (0 ); +if (cpu_temp <0 ) +return cpu_temp;return sprintf (buf,"%d\n" , cpu_temp *1000 ); }
@@ -484,6 +486,8 @@ static ssize_t i8k_hwmon_show_fan(structint fan_speed; fan_speed =i8k_get_fan_speed (index); +if (fan_speed <0 ) +return fan_speed;return sprintf (buf,"%d\n" , fan_speed); }
@@ -541,14 +545,20 @@ static int __init i8k_init_hwmon(void)if (err) goto exit_unregister; -/* CPU temperature attributes */ - err =device_create_file (i8k_hwmon_dev, &dev_attr_temp1_input); -if (err) - goto exit_remove_files; - err =device_create_file (i8k_hwmon_dev, - &sensor_dev_attr_temp1_label.dev_attr); -if (err) - goto exit_remove_files; +/* CPU temperature attributes, if temperature reading is OK */ + err =i8k_get_temp (0 ); +if (err <0 ) { +dev_dbg (i8k_hwmon_dev, +"Not creating temperature attributes (%d)\n" , err); + }else { + err =device_create_file (i8k_hwmon_dev, &dev_attr_temp1_input); +if (err) + goto exit_remove_files; + err =device_create_file (i8k_hwmon_dev, + &sensor_dev_attr_temp1_label.dev_attr); +if (err) + goto exit_remove_files; + }/* Left fan attributes, if left fan is present */ err =i8k_get_fan_status (I8K_FAN_LEFT );
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 9 lines · Jean Delvare
My code originally didn't expect the temperature sensor to be missing, and also didn't properly handle run-time errors. This is fixed now.
Signed-off-by Jean Delvare <[email protected]>Cc Guenter Roeck <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Massimo Dal Zotto <[email protected]>
Acked-by Guenter Roeck <[email protected]>
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors