diff options
Diffstat (limited to 'drivers/hwmon/fscpos.c')
-rw-r--r-- | drivers/hwmon/fscpos.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 6d0146b..758978e 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c @@ -37,6 +37,7 @@ #include <linux/init.h> #include <linux/hwmon.h> #include <linux/err.h> +#include <linux/mutex.h> /* * Addresses to scan @@ -114,7 +115,7 @@ static struct i2c_driver fscpos_driver = { struct fscpos_data { struct i2c_client client; struct class_device *class_dev; - struct semaphore update_lock; + struct mutex update_lock; char valid; /* 0 until following fields are valid */ unsigned long last_updated; /* In jiffies */ @@ -208,13 +209,13 @@ static ssize_t set_fan_ripple(struct i2c_client *client, struct fscpos_data return -EINVAL; } - down(&data->update_lock); + mutex_lock(&data->update_lock); /* bits 2..7 reserved => mask with 0x03 */ data->fan_ripple[nr - 1] &= ~0x03; data->fan_ripple[nr - 1] |= v; fscpos_write_value(client, reg, data->fan_ripple[nr - 1]); - up(&data->update_lock); + mutex_unlock(&data->update_lock); return count; } @@ -232,10 +233,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscpos_data *data, if (v < 0) v = 0; if (v > 255) v = 255; - down(&data->update_lock); + mutex_lock(&data->update_lock); data->pwm[nr - 1] = v; fscpos_write_value(client, reg, data->pwm[nr - 1]); - up(&data->update_lock); + mutex_unlock(&data->update_lock); return count; } @@ -278,11 +279,11 @@ static ssize_t set_wdog_control(struct i2c_client *client, struct fscpos_data /* bits 0..3 reserved => mask with 0xf0 */ unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0; - down(&data->update_lock); + mutex_lock(&data->update_lock); data->wdog_control &= ~0xf0; data->wdog_control |= v; fscpos_write_value(client, reg, data->wdog_control); - up(&data->update_lock); + mutex_unlock(&data->update_lock); return count; } @@ -304,10 +305,10 @@ static ssize_t set_wdog_state(struct i2c_client *client, struct fscpos_data return -EINVAL; } - down(&data->update_lock); + mutex_lock(&data->update_lock); data->wdog_state &= ~v; fscpos_write_value(client, reg, v); - up(&data->update_lock); + mutex_unlock(&data->update_lock); return count; } @@ -321,10 +322,10 @@ static ssize_t set_wdog_preset(struct i2c_client *client, struct fscpos_data { unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff; - down(&data->update_lock); + mutex_lock(&data->update_lock); data->wdog_preset = v; fscpos_write_value(client, reg, data->wdog_preset); - up(&data->update_lock); + mutex_unlock(&data->update_lock); return count; } @@ -483,7 +484,7 @@ static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE); data->valid = 0; - init_MUTEX(&data->update_lock); + mutex_init(&data->update_lock); /* Tell the I2C layer a new client has arrived */ if ((err = i2c_attach_client(new_client))) @@ -579,7 +580,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct fscpos_data *data = i2c_get_clientdata(client); - down(&data->update_lock); + mutex_lock(&data->update_lock); if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { int i; @@ -625,7 +626,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev) data->last_updated = jiffies; data->valid = 1; } - up(&data->update_lock); + mutex_unlock(&data->update_lock); return data; } |