diff options
Diffstat (limited to 'drivers/hwmon/f71805f.c')
-rw-r--r-- | drivers/hwmon/f71805f.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c index a272cae8f60e..7c2973487122 100644 --- a/drivers/hwmon/f71805f.c +++ b/drivers/hwmon/f71805f.c | |||
@@ -146,7 +146,6 @@ superio_exit(int base) | |||
146 | struct f71805f_data { | 146 | struct f71805f_data { |
147 | unsigned short addr; | 147 | unsigned short addr; |
148 | const char *name; | 148 | const char *name; |
149 | struct mutex lock; | ||
150 | struct class_device *class_dev; | 149 | struct class_device *class_dev; |
151 | 150 | ||
152 | struct mutex update_lock; | 151 | struct mutex update_lock; |
@@ -271,50 +270,42 @@ static inline u8 temp_to_reg(long val) | |||
271 | * Device I/O access | 270 | * Device I/O access |
272 | */ | 271 | */ |
273 | 272 | ||
273 | /* Must be called with data->update_lock held, except during initialization */ | ||
274 | static u8 f71805f_read8(struct f71805f_data *data, u8 reg) | 274 | static u8 f71805f_read8(struct f71805f_data *data, u8 reg) |
275 | { | 275 | { |
276 | u8 val; | ||
277 | |||
278 | mutex_lock(&data->lock); | ||
279 | outb(reg, data->addr + ADDR_REG_OFFSET); | 276 | outb(reg, data->addr + ADDR_REG_OFFSET); |
280 | val = inb(data->addr + DATA_REG_OFFSET); | 277 | return inb(data->addr + DATA_REG_OFFSET); |
281 | mutex_unlock(&data->lock); | ||
282 | |||
283 | return val; | ||
284 | } | 278 | } |
285 | 279 | ||
280 | /* Must be called with data->update_lock held, except during initialization */ | ||
286 | static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) | 281 | static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) |
287 | { | 282 | { |
288 | mutex_lock(&data->lock); | ||
289 | outb(reg, data->addr + ADDR_REG_OFFSET); | 283 | outb(reg, data->addr + ADDR_REG_OFFSET); |
290 | outb(val, data->addr + DATA_REG_OFFSET); | 284 | outb(val, data->addr + DATA_REG_OFFSET); |
291 | mutex_unlock(&data->lock); | ||
292 | } | 285 | } |
293 | 286 | ||
294 | /* It is important to read the MSB first, because doing so latches the | 287 | /* It is important to read the MSB first, because doing so latches the |
295 | value of the LSB, so we are sure both bytes belong to the same value. */ | 288 | value of the LSB, so we are sure both bytes belong to the same value. |
289 | Must be called with data->update_lock held, except during initialization */ | ||
296 | static u16 f71805f_read16(struct f71805f_data *data, u8 reg) | 290 | static u16 f71805f_read16(struct f71805f_data *data, u8 reg) |
297 | { | 291 | { |
298 | u16 val; | 292 | u16 val; |
299 | 293 | ||
300 | mutex_lock(&data->lock); | ||
301 | outb(reg, data->addr + ADDR_REG_OFFSET); | 294 | outb(reg, data->addr + ADDR_REG_OFFSET); |
302 | val = inb(data->addr + DATA_REG_OFFSET) << 8; | 295 | val = inb(data->addr + DATA_REG_OFFSET) << 8; |
303 | outb(++reg, data->addr + ADDR_REG_OFFSET); | 296 | outb(++reg, data->addr + ADDR_REG_OFFSET); |
304 | val |= inb(data->addr + DATA_REG_OFFSET); | 297 | val |= inb(data->addr + DATA_REG_OFFSET); |
305 | mutex_unlock(&data->lock); | ||
306 | 298 | ||
307 | return val; | 299 | return val; |
308 | } | 300 | } |
309 | 301 | ||
302 | /* Must be called with data->update_lock held, except during initialization */ | ||
310 | static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) | 303 | static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) |
311 | { | 304 | { |
312 | mutex_lock(&data->lock); | ||
313 | outb(reg, data->addr + ADDR_REG_OFFSET); | 305 | outb(reg, data->addr + ADDR_REG_OFFSET); |
314 | outb(val >> 8, data->addr + DATA_REG_OFFSET); | 306 | outb(val >> 8, data->addr + DATA_REG_OFFSET); |
315 | outb(++reg, data->addr + ADDR_REG_OFFSET); | 307 | outb(++reg, data->addr + ADDR_REG_OFFSET); |
316 | outb(val & 0xff, data->addr + DATA_REG_OFFSET); | 308 | outb(val & 0xff, data->addr + DATA_REG_OFFSET); |
317 | mutex_unlock(&data->lock); | ||
318 | } | 309 | } |
319 | 310 | ||
320 | static struct f71805f_data *f71805f_update_device(struct device *dev) | 311 | static struct f71805f_data *f71805f_update_device(struct device *dev) |
@@ -1150,7 +1141,6 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
1150 | 1141 | ||
1151 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 1142 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
1152 | data->addr = res->start; | 1143 | data->addr = res->start; |
1153 | mutex_init(&data->lock); | ||
1154 | data->name = names[sio_data->kind]; | 1144 | data->name = names[sio_data->kind]; |
1155 | mutex_init(&data->update_lock); | 1145 | mutex_init(&data->update_lock); |
1156 | 1146 | ||
@@ -1300,14 +1290,11 @@ static int __init f71805f_device_add(unsigned short address, | |||
1300 | if (err) { | 1290 | if (err) { |
1301 | printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n", | 1291 | printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n", |
1302 | err); | 1292 | err); |
1303 | goto exit_kfree_data; | 1293 | goto exit_device_put; |
1304 | } | 1294 | } |
1305 | 1295 | ||
1306 | return 0; | 1296 | return 0; |
1307 | 1297 | ||
1308 | exit_kfree_data: | ||
1309 | kfree(pdev->dev.platform_data); | ||
1310 | pdev->dev.platform_data = NULL; | ||
1311 | exit_device_put: | 1298 | exit_device_put: |
1312 | platform_device_put(pdev); | 1299 | platform_device_put(pdev); |
1313 | exit: | 1300 | exit: |
@@ -1400,10 +1387,7 @@ exit: | |||
1400 | 1387 | ||
1401 | static void __exit f71805f_exit(void) | 1388 | static void __exit f71805f_exit(void) |
1402 | { | 1389 | { |
1403 | kfree(pdev->dev.platform_data); | ||
1404 | pdev->dev.platform_data = NULL; | ||
1405 | platform_device_unregister(pdev); | 1390 | platform_device_unregister(pdev); |
1406 | |||
1407 | platform_driver_unregister(&f71805f_driver); | 1391 | platform_driver_unregister(&f71805f_driver); |
1408 | } | 1392 | } |
1409 | 1393 | ||