lm75: sensor reading bugfix
PATCH 1/1 lm75: sensor reading bugfix
LM75 sensor reading bugfix: never save error status as valid sensor output. This could be improved, but at least this prevents certain rude failure modes.
---
Goes on top of the previously submitted lm75 cleanup patch:
http://marc.info/?l=lm-sensors&m0880547009929&w=2
drivers/hwmon/lm75.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/hwmon/lm75.c +15 -5
@@ -259,10 +259,13 @@ static struct i2c_driver lm75_driver = {the SMBus standard. */ static int lm75_read_value (struct i2c_client *client,u8 reg) { +int value; +if (reg =LM75_REG_CONF )return i2c_smbus_read_byte_data (client, reg); -else -return swab16 (i2c_smbus_read_word_data (client, reg)); + + value =i2c_smbus_read_word_data (client, reg); +return (value <0 ) ? value :swab16 (value); }static int lm75_write_value (struct i2c_client *client,u8 reg,u16 value)
@@ -295,9 +298,16 @@ static struct lm75_data *lm75_update_devint i;dev_dbg (&client->dev,"Starting lm75 update\n" ); -for (i =0 ; i <ARRAY_SIZE (data->temp); i++) - data->temp[i] =lm75_read_value (client, -LM75_REG_TEMP [i]); +for (i =0 ; i <ARRAY_SIZE (data->temp); i++) { +int status; + + status =lm75_read_value (client,LM75_REG_TEMP [i]); +if (status <0 ) +dev_dbg (&client->dev,"reg %d, err %d\n" , +LM75_REG_TEMP [i], status); +else + data->temp[i] = status; + } data->last_updated = jiffies; data->valid =1 ; }
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 3 lines · David Brownell
LM75 sensor reading bugfix: never save error status as valid sensor output. This could be improved, but at least this prevents certain rude failure modes.
I agree this needs fixing, especially with the error value cleanup patches you've sent for the i2c stack lately. While -1 swabs to itself, other error values may look like real temperatures once swabbed.
Quoted 38 lines
Signed-off-by David Brownell <[email protected]>---
Goes on top of the previously submitted lm75 cleanup patch:http://marc.info/?l=lm-sensors&m0880547009929&w=2drivers/hwmon/lm75.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)drivers/hwmon/lm75.c +8
-5@@ -259,10 +259,13 @@ static struct i2c_driver lm75_driver = {the SMBus standard. */ static int lm75_read_value (struct i2c_client *client,u8 reg) { +int value; +if (reg =LM75_REG_CONF )return i2c_smbus_read_byte_data (client, reg); -else -return swab16 (i2c_smbus_read_word_data (client, reg)); + + value =i2c_smbus_read_word_data (client, reg); +return (value <0 ) ? value :swab16 (value); }static int lm75_write_value (struct i2c_client *client,u8 reg,u16 value)@@ -295,9 +298,16 @@ static struct lm75_data *lm75_update_devint i;dev_dbg (&client->dev,"Starting lm75 update\n" ); -for (i =0 ; i <ARRAY_SIZE (data->temp); i++) - data->temp[i] =lm75_read_value (client, -LM75_REG_TEMP [i]); +for (i =0 ; i <ARRAY_SIZE (data->temp); i++) { +int status; +
drivers/hwmon/lm75.c static struct lm75_data *lm75_update_dev · line 313
Quoted 10 lines
drivers/hwmon/lm75.c +7
-0+ status =lm75_read_value (client,LM75_REG_TEMP [i]); +if (status <0 ) +dev_dbg (&client->dev,"reg %d, err %d\n" , +LM75_REG_TEMP [i], status); +else + data->temp[i] = status; + } data->last_updated = jiffies; data->valid =1 ; }
Looks good, tested OK (i.e. no regression in the working case.)
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi David:
Quoted 4 lines · David Brownell
LM75 sensor reading bugfix: never save error status as valid sensor output. This could be improved, but at least this prevents certain rude failure modes.
Quoted 8 lines
Signed-off-by David Brownell <[email protected]>---
Goes on top of the previously submitted lm75 cleanup patch:http://marc.info/?l=lm-sensors&m0880547009929&w=2drivers/hwmon/lm75.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
Applied to hwmon-2.6.git/testing, thanks.
Hrm, I missed this one on the first pass through my queue when I picked up your other lm75 patches. Looks like it's severe enough to warrant sending to Linus before 2.6.26 (along with the prerequisite cleanup patch).
Any objections?
Signature · 8 lines
Mark M. Hoffman [email protected] _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Mark,
Quoted 17 lines · Mark M. Hoffman
Hi David:
Quoted 4 lines · David Brownell
LM75 sensor reading bugfix: never save error status as valid sensor output. This could be improved, but at least this prevents certain rude failure modes.
Quoted 8 lines
Signed-off-by David Brownell <[email protected]>---
Goes on top of the previously submitted lm75 cleanup patch:http://marc.info/?l=lm-sensors&m0880547009929&w=2drivers/hwmon/lm75.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
Quoted 7 lines
Applied to hwmon-2.6.git/testing, thanks.
Hrm, I missed this one on the first pass through my queue when I picked up your other lm75 patches. Looks like it's severe enough to warrant sending to Linus before 2.6.26 (along with the prerequisite cleanup patch).
Any objections?
Sending the reading bug fix to Linus now sounds fine, but the cleanup patch doesn't appear to actually be a prerequisite.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 7 lines · Mark M. Hoffman
Applied to hwmon-2.6.git/testing, thanks.
Hrm, I missed this one on the first pass through my queue when I picked up your other lm75 patches. Looks like it's severe enough to warrant sending to Linus before 2.6.26 (along with the prerequisite cleanup patch).
Any objections?
I'd not object if any of them were sent upstream. :)
FYI my comment about "goes on top of cleanup" was mostly to reflect the fact that I didn't test any other sequence.
If it applies in another order for you, fine. Though as a general policy, I'd be glad to see that cleanup patch upstream before its one year anniversary [0] passes!
- Dave
[0] http://marc.info/?l=lm-sensors&m9069752322212&w=2
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors