Skip to content

Commit

Permalink
[PATCH] hwmon: Semaphore to mutex conversions
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Ingo Molnar authored and gregkh committed Mar 23, 2006
1 parent 3fb9a65 commit 9a61bf6
Show file tree
Hide file tree
Showing 36 changed files with 632 additions and 596 deletions.
13 changes: 7 additions & 6 deletions drivers/hwmon/adm1021.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>


/* Addresses to scan */
Expand Down Expand Up @@ -92,7 +93,7 @@ struct adm1021_data {
struct class_device *class_dev;
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 */

Expand Down Expand Up @@ -162,10 +163,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
struct adm1021_data *data = i2c_get_clientdata(client); \
int temp = simple_strtoul(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->value = TEMP_TO_REG(temp); \
adm1021_write_value(client, reg, data->value); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
}
set(temp_max, ADM1021_REG_TOS_W);
Expand Down Expand Up @@ -275,7 +276,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
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)))
Expand Down Expand Up @@ -351,7 +352,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct adm1021_data *data = i2c_get_clientdata(client);

down(&data->update_lock);
mutex_lock(&data->update_lock);

if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
Expand All @@ -375,7 +376,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
data->valid = 1;
}

up(&data->update_lock);
mutex_unlock(&data->update_lock);

return data;
}
Expand Down
25 changes: 13 additions & 12 deletions drivers/hwmon/adm1025.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/mutex.h>

/*
* Addresses to scan
Expand Down Expand Up @@ -133,7 +134,7 @@ static struct i2c_driver adm1025_driver = {
struct adm1025_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */

Expand Down Expand Up @@ -207,11 +208,11 @@ static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute
struct adm1025_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \
data->in_min[offset]); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
} \
static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
Expand All @@ -221,11 +222,11 @@ static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute
struct adm1025_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \
data->in_max[offset]); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
} \
static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
Expand All @@ -247,11 +248,11 @@ static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribut
struct adm1025_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->temp_min[offset-1] = TEMP_TO_REG(val); \
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \
data->temp_min[offset-1]); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
} \
static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
Expand All @@ -261,11 +262,11 @@ static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribut
struct adm1025_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->temp_max[offset-1] = TEMP_TO_REG(val); \
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \
data->temp_max[offset-1]); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
} \
static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
Expand Down Expand Up @@ -404,7 +405,7 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
/* We can fill in the remaining client fields */
strlcpy(new_client->name, name, 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)))
Expand Down Expand Up @@ -523,7 +524,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct adm1025_data *data = i2c_get_clientdata(client);

down(&data->update_lock);
mutex_lock(&data->update_lock);

if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
int i;
Expand Down Expand Up @@ -558,7 +559,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
data->valid = 1;
}

up(&data->update_lock);
mutex_unlock(&data->update_lock);

return data;
}
Expand Down
Loading

0 comments on commit 9a61bf6

Please sign in to comment.