aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/f71805f.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/f71805f.c')
-rw-r--r--drivers/hwmon/f71805f.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
index a272cae8f60e..2fc537819388 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -146,7 +146,6 @@ superio_exit(int base)
146struct f71805f_data { 146struct 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 */
274static u8 f71805f_read8(struct f71805f_data *data, u8 reg) 274static 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 */
286static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) 281static 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 */
296static u16 f71805f_read16(struct f71805f_data *data, u8 reg) 290static 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 */
310static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) 303static 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
320static struct f71805f_data *f71805f_update_device(struct device *dev) 311static 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