]> Pileus Git - ~andy/linux/blobdiff - drivers/hwmon/it87.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[~andy/linux] / drivers / hwmon / it87.c
index bb16668ad2bdb8eea52063beabf55077bda0cf30..62afc63708a5c85dec58aae278b2f2047c476e3e 100644 (file)
@@ -214,14 +214,11 @@ static const unsigned int pwm_freq[8] = {
 };
 
 
-/* For each registered IT87, we need to keep some data in memory. That
-   data is pointed to by it87_list[NR]->data. The structure itself is
-   dynamically allocated, at the same time when a new it87 client is
-   allocated. */
+/* For each registered chip, we need to keep some data in memory.
+   The structure is dynamically allocated. */
 struct it87_data {
        struct i2c_client client;
        struct class_device *class_dev;
-       struct mutex lock;
        enum chips type;
 
        struct mutex update_lock;
@@ -548,9 +545,10 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
        struct i2c_client *client = to_i2c_client(dev);
        struct it87_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
-       u8 reg = it87_read_value(client, IT87_REG_FAN_DIV);
+       u8 reg;
 
        mutex_lock(&data->update_lock);
+       reg = it87_read_value(client, IT87_REG_FAN_DIV);
        switch (nr) {
        case 0: data->fan_div[nr] = reg & 0x07; break;
        case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break;
@@ -949,7 +947,6 @@ static int it87_detect(struct i2c_adapter *adapter)
        }
 
        new_client = &data->client;
-       mutex_init(&data->lock);
        i2c_set_clientdata(new_client, data);
        new_client->addr = isa_address;
        new_client->adapter = adapter;
@@ -1127,33 +1124,22 @@ static int it87_detach_client(struct i2c_client *client)
        return 0;
 }
 
-/* ISA access must be locked explicitly!
+/* Must be called with data->update_lock held, except during initialization.
    We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
    would slow down the IT87 access and should not be necessary. */
 static int it87_read_value(struct i2c_client *client, u8 reg)
 {
-       struct it87_data *data = i2c_get_clientdata(client);
-       int res;
-
-       mutex_lock(&data->lock);
        outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
-       res = inb_p(client->addr + IT87_DATA_REG_OFFSET);
-       mutex_unlock(&data->lock);
-
-       return res;
+       return inb_p(client->addr + IT87_DATA_REG_OFFSET);
 }
 
-/* ISA access must be locked explicitly!
+/* Must be called with data->update_lock held, except during initialization.
    We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
    would slow down the IT87 access and should not be necessary. */
 static void it87_write_value(struct i2c_client *client, u8 reg, u8 value)
 {
-       struct it87_data *data = i2c_get_clientdata(client);
-
-       mutex_lock(&data->lock);
        outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
        outb_p(value, client->addr + IT87_DATA_REG_OFFSET);
-       mutex_unlock(&data->lock);
 }
 
 /* Return 1 if and only if the PWM interface is safe to use */