aboutsummaryrefslogtreecommitdiff
path: root/drivers/hwmon/f71805f.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-02-14 21:15:03 +0100
committerJean Delvare <khali@arrakis.delvare>2007-02-14 21:15:03 +0100
commit7f999aa726ded3fd10d7619945e8b7d7e39833b3 (patch)
treecb99dfde0b69cf076810eb3c0d46aac54449e5e1 /drivers/hwmon/f71805f.c
parent6a0b1013c61396e588540713c8389038e7d0fead (diff)
hwmon: Simplify the locking model of two drivers
Many hardware monitoring drivers use two different mutexes, one to protect their per-device data structure, and one to protect the access to the device registers. These mutexes are essentially redundant, as the drivers are transfering values between the device registers and the data cache, so they almost always end up holding both mutexes at the same time. Using a single mutex will make the code more simple and faster. I am changing only two of the affected drivers here, the authors of the other affected drivers are welcome to submit similar patches if they want. Signed-off-by: Jean Delvare <khali@linux-fr.org>
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 a272cae8f60..2fc53781938 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -146,7 +146,6 @@ superio_exit(int base)
struct f71805f_data {
unsigned short addr;
const char *name;
- struct mutex lock;
struct class_device *class_dev;
struct mutex update_lock;
@@ -271,50 +270,42 @@ static inline u8 temp_to_reg(long val)
* Device I/O access
*/
+/* Must be called with data->update_lock held, except during initialization */
static u8 f71805f_read8(struct f71805f_data *data, u8 reg)
{
- u8 val;
-
- mutex_lock(&data->lock);
outb(reg, data->addr + ADDR_REG_OFFSET);
- val = inb(data->addr + DATA_REG_OFFSET);
- mutex_unlock(&data->lock);
-
- return val;
+ return inb(data->addr + DATA_REG_OFFSET);
}
+/* Must be called with data->update_lock held, except during initialization */
static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val)
{
- mutex_lock(&data->lock);
outb(reg, data->addr + ADDR_REG_OFFSET);
outb(val, data->addr + DATA_REG_OFFSET);
- mutex_unlock(&data->lock);
}
/* It is important to read the MSB first, because doing so latches the
- value of the LSB, so we are sure both bytes belong to the same value. */
+ value of the LSB, so we are sure both bytes belong to the same value.
+ Must be called with data->update_lock held, except during initialization */
static u16 f71805f_read16(struct f71805f_data *data, u8 reg)
{
u16 val;
- mutex_lock(&data->lock);
outb(reg, data->addr + ADDR_REG_OFFSET);
val = inb(data->addr + DATA_REG_OFFSET) << 8;
outb(++reg, data->addr + ADDR_REG_OFFSET);
val |= inb(data->addr + DATA_REG_OFFSET);
- mutex_unlock(&data->lock);
return val;
}
+/* Must be called with data->update_lock held, except during initialization */
static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val)
{
- mutex_lock(&data->lock);
outb(reg, data->addr + ADDR_REG_OFFSET);
outb(val >> 8, data->addr + DATA_REG_OFFSET);
outb(++reg, data->addr + ADDR_REG_OFFSET);
outb(val & 0xff, data->addr + DATA_REG_OFFSET);
- mutex_unlock(&data->lock);
}
static struct f71805f_data *f71805f_update_device(struct device *dev)
@@ -1150,7 +1141,6 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
data->addr = res->start;
- mutex_init(&data->lock);
data->name = names[sio_data->kind];
mutex_init(&data->update_lock);