Do not disable SMBs unless really necessary

Only disable SMBus if we are going to read/write data.
Disabling it on each attribute read can result in system
instabilities.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Guenter Roeck
2017-10-06 16:14:31 -07:00
parent f8240ebfd5
commit 4f8c82e23c

17
it87.c
View File

@@ -788,7 +788,6 @@ struct it87_data {
const u8 *REG_TEMP_HIGH; const u8 *REG_TEMP_HIGH;
unsigned short addr; unsigned short addr;
const char *name;
struct mutex update_lock; struct mutex update_lock;
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 */
@@ -1135,15 +1134,19 @@ static void it87_unlock(struct it87_data *data)
static struct it87_data *it87_update_device(struct device *dev) static struct it87_data *it87_update_device(struct device *dev)
{ {
struct it87_data *data = dev_get_drvdata(dev); struct it87_data *data = dev_get_drvdata(dev);
struct it87_data *ret = data;
int err; int err;
int i; int i;
err = it87_lock(data); mutex_lock(&data->update_lock);
if (err)
return ERR_PTR(err);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || if (time_after(jiffies, data->last_updated + HZ + HZ / 2) ||
!data->valid) { !data->valid) {
err = smbus_disable(data);
if (err) {
ret = ERR_PTR(err);
goto unlock;
}
if (update_vbat) { if (update_vbat) {
/* /*
* Cleared after each update, so reenable. Value * Cleared after each update, so reenable. Value
@@ -1240,9 +1243,11 @@ static struct it87_data *it87_update_device(struct device *dev)
} }
data->last_updated = jiffies; data->last_updated = jiffies;
data->valid = 1; data->valid = 1;
smbus_enable(data);
} }
it87_unlock(data); unlock:
return data; mutex_unlock(&data->update_lock);
return ret;
} }
static ssize_t show_in(struct device *dev, struct device_attribute *attr, static ssize_t show_in(struct device *dev, struct device_attribute *attr,