[PATCH] hwmon: Semaphore to mutex conversions
convert drivers/hwmon/*.c semaphore use to mutexes. the conversion was generated via scripts, and the result was validated automatically via a script as well. all affected hwmon drivers were build-tested. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
3fb9a65529
commit
9a61bf6300
@ -27,6 +27,7 @@
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-vid.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
/* Addresses to scan */
|
||||
@ -131,10 +132,10 @@ static inline int TEMP_FROM_REG(s8 val)
|
||||
struct lm78_data {
|
||||
struct i2c_client client;
|
||||
struct class_device *class_dev;
|
||||
struct semaphore lock;
|
||||
struct mutex lock;
|
||||
enum chips type;
|
||||
|
||||
struct semaphore update_lock;
|
||||
struct mutex update_lock;
|
||||
char valid; /* !=0 if following fields are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
|
||||
@ -207,10 +208,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
|
||||
struct lm78_data *data = i2c_get_clientdata(client);
|
||||
unsigned long val = simple_strtoul(buf, NULL, 10);
|
||||
|
||||
down(&data->update_lock);
|
||||
mutex_lock(&data->update_lock);
|
||||
data->in_min[nr] = IN_TO_REG(val);
|
||||
lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]);
|
||||
up(&data->update_lock);
|
||||
mutex_unlock(&data->update_lock);
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -221,10 +222,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
|
||||
struct lm78_data *data = i2c_get_clientdata(client);
|
||||
unsigned long val = simple_strtoul(buf, NULL, 10);
|
||||
|
||||
down(&data->update_lock);
|
||||
mutex_lock(&data->update_lock);
|
||||
data->in_max[nr] = IN_TO_REG(val);
|
||||
lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]);
|
||||
up(&data->update_lock);
|
||||
mutex_unlock(&data->update_lock);
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -288,10 +289,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr,
|
||||
struct lm78_data *data = i2c_get_clientdata(client);
|
||||
long val = simple_strtol(buf, NULL, 10);
|
||||
|
||||
down(&data->update_lock);
|
||||
mutex_lock(&data->update_lock);
|
||||
data->temp_over = TEMP_TO_REG(val);
|
||||
lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over);
|
||||
up(&data->update_lock);
|
||||
mutex_unlock(&data->update_lock);
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -307,10 +308,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr,
|
||||
struct lm78_data *data = i2c_get_clientdata(client);
|
||||
long val = simple_strtol(buf, NULL, 10);
|
||||
|
||||
down(&data->update_lock);
|
||||
mutex_lock(&data->update_lock);
|
||||
data->temp_hyst = TEMP_TO_REG(val);
|
||||
lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst);
|
||||
up(&data->update_lock);
|
||||
mutex_unlock(&data->update_lock);
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -342,10 +343,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
|
||||
struct lm78_data *data = i2c_get_clientdata(client);
|
||||
unsigned long val = simple_strtoul(buf, NULL, 10);
|
||||
|
||||
down(&data->update_lock);
|
||||
mutex_lock(&data->update_lock);
|
||||
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
|
||||
lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]);
|
||||
up(&data->update_lock);
|
||||
mutex_unlock(&data->update_lock);
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -368,7 +369,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
|
||||
unsigned long min;
|
||||
u8 reg;
|
||||
|
||||
down(&data->update_lock);
|
||||
mutex_lock(&data->update_lock);
|
||||
min = FAN_FROM_REG(data->fan_min[nr],
|
||||
DIV_FROM_REG(data->fan_div[nr]));
|
||||
|
||||
@ -380,7 +381,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
|
||||
default:
|
||||
dev_err(&client->dev, "fan_div value %ld not "
|
||||
"supported. Choose one of 1, 2, 4 or 8!\n", val);
|
||||
up(&data->update_lock);
|
||||
mutex_unlock(&data->update_lock);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -398,7 +399,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
|
||||
data->fan_min[nr] =
|
||||
FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
|
||||
lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]);
|
||||
up(&data->update_lock);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
@ -548,7 +549,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||
|
||||
new_client = &data->client;
|
||||
if (is_isa)
|
||||
init_MUTEX(&data->lock);
|
||||
mutex_init(&data->lock);
|
||||
i2c_set_clientdata(new_client, data);
|
||||
new_client->addr = address;
|
||||
new_client->adapter = adapter;
|
||||
@ -598,7 +599,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||
data->type = kind;
|
||||
|
||||
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)))
|
||||
@ -697,10 +698,10 @@ static int lm78_read_value(struct i2c_client *client, u8 reg)
|
||||
int res;
|
||||
if (i2c_is_isa_client(client)) {
|
||||
struct lm78_data *data = i2c_get_clientdata(client);
|
||||
down(&data->lock);
|
||||
mutex_lock(&data->lock);
|
||||
outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET);
|
||||
res = inb_p(client->addr + LM78_DATA_REG_OFFSET);
|
||||
up(&data->lock);
|
||||
mutex_unlock(&data->lock);
|
||||
return res;
|
||||
} else
|
||||
return i2c_smbus_read_byte_data(client, reg);
|
||||
@ -717,10 +718,10 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value)
|
||||
{
|
||||
if (i2c_is_isa_client(client)) {
|
||||
struct lm78_data *data = i2c_get_clientdata(client);
|
||||
down(&data->lock);
|
||||
mutex_lock(&data->lock);
|
||||
outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET);
|
||||
outb_p(value, client->addr + LM78_DATA_REG_OFFSET);
|
||||
up(&data->lock);
|
||||
mutex_unlock(&data->lock);
|
||||
return 0;
|
||||
} else
|
||||
return i2c_smbus_write_byte_data(client, reg, value);
|
||||
@ -742,7 +743,7 @@ static struct lm78_data *lm78_update_device(struct device *dev)
|
||||
struct lm78_data *data = i2c_get_clientdata(client);
|
||||
int i;
|
||||
|
||||
down(&data->update_lock);
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|
||||
|| !data->valid) {
|
||||
@ -786,7 +787,7 @@ static struct lm78_data *lm78_update_device(struct device *dev)
|
||||
data->fan_div[2] = 1;
|
||||
}
|
||||
|
||||
up(&data->update_lock);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
Reference in New Issue
Block a user