diff options
Diffstat (limited to 'drivers/hwmon/it87.c')
-rw-r--r-- | drivers/hwmon/it87.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index bb16668ad2bd..18bb44d18e89 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -221,7 +221,6 @@ static const unsigned int pwm_freq[8] = { | |||
221 | struct it87_data { | 221 | struct it87_data { |
222 | struct i2c_client client; | 222 | struct i2c_client client; |
223 | struct class_device *class_dev; | 223 | struct class_device *class_dev; |
224 | struct mutex lock; | ||
225 | enum chips type; | 224 | enum chips type; |
226 | 225 | ||
227 | struct mutex update_lock; | 226 | struct mutex update_lock; |
@@ -548,9 +547,10 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
548 | struct i2c_client *client = to_i2c_client(dev); | 547 | struct i2c_client *client = to_i2c_client(dev); |
549 | struct it87_data *data = i2c_get_clientdata(client); | 548 | struct it87_data *data = i2c_get_clientdata(client); |
550 | int val = simple_strtol(buf, NULL, 10); | 549 | int val = simple_strtol(buf, NULL, 10); |
551 | u8 reg = it87_read_value(client, IT87_REG_FAN_DIV); | 550 | u8 reg; |
552 | 551 | ||
553 | mutex_lock(&data->update_lock); | 552 | mutex_lock(&data->update_lock); |
553 | reg = it87_read_value(client, IT87_REG_FAN_DIV); | ||
554 | switch (nr) { | 554 | switch (nr) { |
555 | case 0: data->fan_div[nr] = reg & 0x07; break; | 555 | case 0: data->fan_div[nr] = reg & 0x07; break; |
556 | case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break; | 556 | case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break; |
@@ -949,7 +949,6 @@ static int it87_detect(struct i2c_adapter *adapter) | |||
949 | } | 949 | } |
950 | 950 | ||
951 | new_client = &data->client; | 951 | new_client = &data->client; |
952 | mutex_init(&data->lock); | ||
953 | i2c_set_clientdata(new_client, data); | 952 | i2c_set_clientdata(new_client, data); |
954 | new_client->addr = isa_address; | 953 | new_client->addr = isa_address; |
955 | new_client->adapter = adapter; | 954 | new_client->adapter = adapter; |
@@ -1127,33 +1126,22 @@ static int it87_detach_client(struct i2c_client *client) | |||
1127 | return 0; | 1126 | return 0; |
1128 | } | 1127 | } |
1129 | 1128 | ||
1130 | /* ISA access must be locked explicitly! | 1129 | /* Must be called with data->update_lock held, except during initialization. |
1131 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, | 1130 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, |
1132 | would slow down the IT87 access and should not be necessary. */ | 1131 | would slow down the IT87 access and should not be necessary. */ |
1133 | static int it87_read_value(struct i2c_client *client, u8 reg) | 1132 | static int it87_read_value(struct i2c_client *client, u8 reg) |
1134 | { | 1133 | { |
1135 | struct it87_data *data = i2c_get_clientdata(client); | ||
1136 | int res; | ||
1137 | |||
1138 | mutex_lock(&data->lock); | ||
1139 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); | 1134 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); |
1140 | res = inb_p(client->addr + IT87_DATA_REG_OFFSET); | 1135 | return inb_p(client->addr + IT87_DATA_REG_OFFSET); |
1141 | mutex_unlock(&data->lock); | ||
1142 | |||
1143 | return res; | ||
1144 | } | 1136 | } |
1145 | 1137 | ||
1146 | /* ISA access must be locked explicitly! | 1138 | /* Must be called with data->update_lock held, except during initialization. |
1147 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, | 1139 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, |
1148 | would slow down the IT87 access and should not be necessary. */ | 1140 | would slow down the IT87 access and should not be necessary. */ |
1149 | static void it87_write_value(struct i2c_client *client, u8 reg, u8 value) | 1141 | static void it87_write_value(struct i2c_client *client, u8 reg, u8 value) |
1150 | { | 1142 | { |
1151 | struct it87_data *data = i2c_get_clientdata(client); | ||
1152 | |||
1153 | mutex_lock(&data->lock); | ||
1154 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); | 1143 | outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); |
1155 | outb_p(value, client->addr + IT87_DATA_REG_OFFSET); | 1144 | outb_p(value, client->addr + IT87_DATA_REG_OFFSET); |
1156 | mutex_unlock(&data->lock); | ||
1157 | } | 1145 | } |
1158 | 1146 | ||
1159 | /* Return 1 if and only if the PWM interface is safe to use */ | 1147 | /* Return 1 if and only if the PWM interface is safe to use */ |