提交 96585f1a 编写于 作者: F Frans Meulenbroeks 提交者: Guenter Roeck

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: NFrans Meulenbroeks <fransmeulenbroeks@gmail.com>
Signed-off-by: NGuenter Roeck <guenter.roeck@ericsson.com>
上级 6a9e7c4c
...@@ -108,6 +108,7 @@ static inline long TEMP_FROM_REG(u16 temp) ...@@ -108,6 +108,7 @@ static inline long TEMP_FROM_REG(u16 temp)
struct lm80_data { struct lm80_data {
struct device *hwmon_dev; struct device *hwmon_dev;
struct mutex update_lock; struct mutex update_lock;
char error; /* !=0 if error occurred during last update */
char valid; /* !=0 if following fields are valid */ char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */ unsigned long last_updated; /* In jiffies */
...@@ -595,6 +596,9 @@ static struct lm80_data *lm80_update_device(struct device *dev) ...@@ -595,6 +596,9 @@ static struct lm80_data *lm80_update_device(struct device *dev)
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
if (data->error)
lm80_init_client(client);
if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
dev_dbg(&client->dev, "Starting lm80 update\n"); dev_dbg(&client->dev, "Starting lm80 update\n");
for (i = 0; i <= 6; i++) { for (i = 0; i <= 6; i++) {
...@@ -678,12 +682,14 @@ static struct lm80_data *lm80_update_device(struct device *dev) ...@@ -678,12 +682,14 @@ static struct lm80_data *lm80_update_device(struct device *dev)
data->last_updated = jiffies; data->last_updated = jiffies;
data->valid = 1; data->valid = 1;
data->error = 0;
} }
goto done; goto done;
abort: abort:
ret = ERR_PTR(rv); ret = ERR_PTR(rv);
data->valid = 0; data->valid = 0;
data->error = 1;
done: done:
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册