diff options
Diffstat (limited to 'drivers/hwmon/lm75.c')
-rw-r--r-- | drivers/hwmon/lm75.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 1888dd0fc05f..903f22904bf4 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -93,6 +93,10 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da, | |||
93 | { | 93 | { |
94 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); | 94 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
95 | struct lm75_data *data = lm75_update_device(dev); | 95 | struct lm75_data *data = lm75_update_device(dev); |
96 | |||
97 | if (IS_ERR(data)) | ||
98 | return PTR_ERR(data); | ||
99 | |||
96 | return sprintf(buf, "%d\n", | 100 | return sprintf(buf, "%d\n", |
97 | LM75_TEMP_FROM_REG(data->temp[attr->index])); | 101 | LM75_TEMP_FROM_REG(data->temp[attr->index])); |
98 | } | 102 | } |
@@ -402,6 +406,7 @@ static struct lm75_data *lm75_update_device(struct device *dev) | |||
402 | { | 406 | { |
403 | struct i2c_client *client = to_i2c_client(dev); | 407 | struct i2c_client *client = to_i2c_client(dev); |
404 | struct lm75_data *data = i2c_get_clientdata(client); | 408 | struct lm75_data *data = i2c_get_clientdata(client); |
409 | struct lm75_data *ret = data; | ||
405 | 410 | ||
406 | mutex_lock(&data->update_lock); | 411 | mutex_lock(&data->update_lock); |
407 | 412 | ||
@@ -414,19 +419,23 @@ static struct lm75_data *lm75_update_device(struct device *dev) | |||
414 | int status; | 419 | int status; |
415 | 420 | ||
416 | status = lm75_read_value(client, LM75_REG_TEMP[i]); | 421 | status = lm75_read_value(client, LM75_REG_TEMP[i]); |
417 | if (status < 0) | 422 | if (unlikely(status < 0)) { |
418 | dev_dbg(&client->dev, "reg %d, err %d\n", | 423 | dev_dbg(dev, |
419 | LM75_REG_TEMP[i], status); | 424 | "LM75: Failed to read value: reg %d, error %d\n", |
420 | else | 425 | LM75_REG_TEMP[i], status); |
421 | data->temp[i] = status; | 426 | ret = ERR_PTR(status); |
427 | data->valid = 0; | ||
428 | goto abort; | ||
429 | } | ||
430 | data->temp[i] = status; | ||
422 | } | 431 | } |
423 | data->last_updated = jiffies; | 432 | data->last_updated = jiffies; |
424 | data->valid = 1; | 433 | data->valid = 1; |
425 | } | 434 | } |
426 | 435 | ||
436 | abort: | ||
427 | mutex_unlock(&data->update_lock); | 437 | mutex_unlock(&data->update_lock); |
428 | 438 | return ret; | |
429 | return data; | ||
430 | } | 439 | } |
431 | 440 | ||
432 | /*-----------------------------------------------------------------------*/ | 441 | /*-----------------------------------------------------------------------*/ |