]> git.sur5r.net Git - groeck-it87/commitdiff
Do not disable SMBs unless really necessary
authorGuenter Roeck <linux@roeck-us.net>
Fri, 6 Oct 2017 23:14:31 +0000 (16:14 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 6 Oct 2017 23:14:31 +0000 (16:14 -0700)
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>
it87.c

diff --git a/it87.c b/it87.c
index 2acc57b73b2ed5adcfe3d7225dc6a21513a63978..8a51027b38cfc0b1280f742f855f081108285364 100644 (file)
--- a/it87.c
+++ b/it87.c
@@ -788,7 +788,6 @@ struct it87_data {
        const u8 *REG_TEMP_HIGH;
 
        unsigned short addr;
-       const char *name;
        struct mutex update_lock;
        char valid;             /* !=0 if following fields are valid */
        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)
 {
        struct it87_data *data = dev_get_drvdata(dev);
+       struct it87_data *ret = data;
        int err;
        int i;
 
-       err = it87_lock(data);
-       if (err)
-               return ERR_PTR(err);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ + HZ / 2) ||
            !data->valid) {
+               err = smbus_disable(data);
+               if (err) {
+                       ret = ERR_PTR(err);
+                       goto unlock;
+               }
                if (update_vbat) {
                        /*
                         * 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->valid = 1;
+               smbus_enable(data);
        }
-       it87_unlock(data);
-       return data;
+unlock:
+       mutex_unlock(&data->update_lock);
+       return ret;
 }
 
 static ssize_t show_in(struct device *dev, struct device_attribute *attr,