aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm80.c
diff options
context:
space:
mode:
authorFrans Meulenbroeks <fransmeulenbroeks@gmail.com>2012-01-10 09:49:36 -0500
committerGuenter Roeck <guenter.roeck@ericsson.com>2012-03-18 21:26:42 -0400
commit96585f1ae4698800a18582935e2f01bb65a44fe6 (patch)
tree6eda4d63a8f8f5f38c38af17b337ac98d26f5ae8 /drivers/hwmon/lm80.c
parent6a9e7c4c0365e246d85166a5ee04a8dd4dcfada9 (diff)
hwmon: (lm80) reset device if error occurred
If an error occurs while updating (e.g. because the chip was disconnected) the device needs to be reinitialized in order to get back to 11 bit temperature and set the fan divider. Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon/lm80.c')
-rw-r--r--drivers/hwmon/lm80.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index c4de272f3aaf..dc6df4efedc1 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -108,6 +108,7 @@ static inline long TEMP_FROM_REG(u16 temp)
108struct lm80_data { 108struct lm80_data {
109 struct device *hwmon_dev; 109 struct device *hwmon_dev;
110 struct mutex update_lock; 110 struct mutex update_lock;
111 char error; /* !=0 if error occurred during last update */
111 char valid; /* !=0 if following fields are valid */ 112 char valid; /* !=0 if following fields are valid */
112 unsigned long last_updated; /* In jiffies */ 113 unsigned long last_updated; /* In jiffies */
113 114
@@ -595,6 +596,9 @@ static struct lm80_data *lm80_update_device(struct device *dev)
595 596
596 mutex_lock(&data->update_lock); 597 mutex_lock(&data->update_lock);
597 598
599 if (data->error)
600 lm80_init_client(client);
601
598 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { 602 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
599 dev_dbg(&client->dev, "Starting lm80 update\n"); 603 dev_dbg(&client->dev, "Starting lm80 update\n");
600 for (i = 0; i <= 6; i++) { 604 for (i = 0; i <= 6; i++) {
@@ -678,12 +682,14 @@ static struct lm80_data *lm80_update_device(struct device *dev)
678 682
679 data->last_updated = jiffies; 683 data->last_updated = jiffies;
680 data->valid = 1; 684 data->valid = 1;
685 data->error = 0;
681 } 686 }
682 goto done; 687 goto done;
683 688
684abort: 689abort:
685 ret = ERR_PTR(rv); 690 ret = ERR_PTR(rv);
686 data->valid = 0; 691 data->valid = 0;
692 data->error = 1;
687 693
688done: 694done:
689 mutex_unlock(&data->update_lock); 695 mutex_unlock(&data->update_lock);