diff options
author | Jean Delvare <khali@linux-fr.org> | 2007-06-09 10:11:15 -0400 |
---|---|---|
committer | Mark M. Hoffman <mhoffman@lightlink.com> | 2007-07-19 14:22:11 -0400 |
commit | e4a7167f82130fa95005097797bb1ec9c76201fd (patch) | |
tree | ffde1a281ed996732f16ef0974ee04a8ddf824ba /drivers | |
parent | 0966415d7267c860b88fe96f7e83cfd687efe0bd (diff) |
hwmon/smsc47m192: Semaphore to mutex conversion
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/smsc47m192.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/hwmon/smsc47m192.c b/drivers/hwmon/smsc47m192.c index a012f396f354..7c5cfa24d0c4 100644 --- a/drivers/hwmon/smsc47m192.c +++ b/drivers/hwmon/smsc47m192.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/hwmon-vid.h> | 31 | #include <linux/hwmon-vid.h> |
32 | #include <linux/err.h> | 32 | #include <linux/err.h> |
33 | #include <linux/sysfs.h> | 33 | #include <linux/sysfs.h> |
34 | #include <linux/mutex.h> | ||
34 | 35 | ||
35 | /* Addresses to scan */ | 36 | /* Addresses to scan */ |
36 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; | 37 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; |
@@ -97,7 +98,7 @@ static inline int TEMP_FROM_REG(s8 val) | |||
97 | struct smsc47m192_data { | 98 | struct smsc47m192_data { |
98 | struct i2c_client client; | 99 | struct i2c_client client; |
99 | struct class_device *class_dev; | 100 | struct class_device *class_dev; |
100 | struct semaphore update_lock; | 101 | struct mutex update_lock; |
101 | char valid; /* !=0 if following fields are valid */ | 102 | char valid; /* !=0 if following fields are valid */ |
102 | unsigned long last_updated; /* In jiffies */ | 103 | unsigned long last_updated; /* In jiffies */ |
103 | 104 | ||
@@ -164,11 +165,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
164 | struct smsc47m192_data *data = i2c_get_clientdata(client); | 165 | struct smsc47m192_data *data = i2c_get_clientdata(client); |
165 | unsigned long val = simple_strtoul(buf, NULL, 10); | 166 | unsigned long val = simple_strtoul(buf, NULL, 10); |
166 | 167 | ||
167 | down(&data->update_lock); | 168 | mutex_lock(&data->update_lock); |
168 | data->in_min[nr] = IN_TO_REG(val, nr); | 169 | data->in_min[nr] = IN_TO_REG(val, nr); |
169 | i2c_smbus_write_byte_data(client, SMSC47M192_REG_IN_MIN(nr), | 170 | i2c_smbus_write_byte_data(client, SMSC47M192_REG_IN_MIN(nr), |
170 | data->in_min[nr]); | 171 | data->in_min[nr]); |
171 | up(&data->update_lock); | 172 | mutex_unlock(&data->update_lock); |
172 | return count; | 173 | return count; |
173 | } | 174 | } |
174 | 175 | ||
@@ -181,11 +182,11 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
181 | struct smsc47m192_data *data = i2c_get_clientdata(client); | 182 | struct smsc47m192_data *data = i2c_get_clientdata(client); |
182 | unsigned long val = simple_strtoul(buf, NULL, 10); | 183 | unsigned long val = simple_strtoul(buf, NULL, 10); |
183 | 184 | ||
184 | down(&data->update_lock); | 185 | mutex_lock(&data->update_lock); |
185 | data->in_max[nr] = IN_TO_REG(val, nr); | 186 | data->in_max[nr] = IN_TO_REG(val, nr); |
186 | i2c_smbus_write_byte_data(client, SMSC47M192_REG_IN_MAX(nr), | 187 | i2c_smbus_write_byte_data(client, SMSC47M192_REG_IN_MAX(nr), |
187 | data->in_max[nr]); | 188 | data->in_max[nr]); |
188 | up(&data->update_lock); | 189 | mutex_unlock(&data->update_lock); |
189 | return count; | 190 | return count; |
190 | } | 191 | } |
191 | 192 | ||
@@ -243,11 +244,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
243 | struct smsc47m192_data *data = i2c_get_clientdata(client); | 244 | struct smsc47m192_data *data = i2c_get_clientdata(client); |
244 | long val = simple_strtol(buf, NULL, 10); | 245 | long val = simple_strtol(buf, NULL, 10); |
245 | 246 | ||
246 | down(&data->update_lock); | 247 | mutex_lock(&data->update_lock); |
247 | data->temp_min[nr] = TEMP_TO_REG(val); | 248 | data->temp_min[nr] = TEMP_TO_REG(val); |
248 | i2c_smbus_write_byte_data(client, SMSC47M192_REG_TEMP_MIN[nr], | 249 | i2c_smbus_write_byte_data(client, SMSC47M192_REG_TEMP_MIN[nr], |
249 | data->temp_min[nr]); | 250 | data->temp_min[nr]); |
250 | up(&data->update_lock); | 251 | mutex_unlock(&data->update_lock); |
251 | return count; | 252 | return count; |
252 | } | 253 | } |
253 | 254 | ||
@@ -260,11 +261,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
260 | struct smsc47m192_data *data = i2c_get_clientdata(client); | 261 | struct smsc47m192_data *data = i2c_get_clientdata(client); |
261 | long val = simple_strtol(buf, NULL, 10); | 262 | long val = simple_strtol(buf, NULL, 10); |
262 | 263 | ||
263 | down(&data->update_lock); | 264 | mutex_lock(&data->update_lock); |
264 | data->temp_max[nr] = TEMP_TO_REG(val); | 265 | data->temp_max[nr] = TEMP_TO_REG(val); |
265 | i2c_smbus_write_byte_data(client, SMSC47M192_REG_TEMP_MAX[nr], | 266 | i2c_smbus_write_byte_data(client, SMSC47M192_REG_TEMP_MAX[nr], |
266 | data->temp_max[nr]); | 267 | data->temp_max[nr]); |
267 | up(&data->update_lock); | 268 | mutex_unlock(&data->update_lock); |
268 | return count; | 269 | return count; |
269 | } | 270 | } |
270 | 271 | ||
@@ -287,7 +288,7 @@ static ssize_t set_temp_offset(struct device *dev, struct device_attribute | |||
287 | u8 sfr = i2c_smbus_read_byte_data(client, SMSC47M192_REG_SFR); | 288 | u8 sfr = i2c_smbus_read_byte_data(client, SMSC47M192_REG_SFR); |
288 | long val = simple_strtol(buf, NULL, 10); | 289 | long val = simple_strtol(buf, NULL, 10); |
289 | 290 | ||
290 | down(&data->update_lock); | 291 | mutex_lock(&data->update_lock); |
291 | data->temp_offset[nr] = TEMP_TO_REG(val); | 292 | data->temp_offset[nr] = TEMP_TO_REG(val); |
292 | if (nr>1) | 293 | if (nr>1) |
293 | i2c_smbus_write_byte_data(client, | 294 | i2c_smbus_write_byte_data(client, |
@@ -303,7 +304,7 @@ static ssize_t set_temp_offset(struct device *dev, struct device_attribute | |||
303 | } else if ((sfr & 0x10) == (nr==0 ? 0x10 : 0)) | 304 | } else if ((sfr & 0x10) == (nr==0 ? 0x10 : 0)) |
304 | i2c_smbus_write_byte_data(client, | 305 | i2c_smbus_write_byte_data(client, |
305 | SMSC47M192_REG_TEMP_OFFSET(nr), 0); | 306 | SMSC47M192_REG_TEMP_OFFSET(nr), 0); |
306 | up(&data->update_lock); | 307 | mutex_unlock(&data->update_lock); |
307 | return count; | 308 | return count; |
308 | } | 309 | } |
309 | 310 | ||
@@ -531,7 +532,7 @@ static int smsc47m192_detect(struct i2c_adapter *adapter, int address, | |||
531 | /* Fill in the remaining client fields and put into the global list */ | 532 | /* Fill in the remaining client fields and put into the global list */ |
532 | strlcpy(client->name, "smsc47m192", I2C_NAME_SIZE); | 533 | strlcpy(client->name, "smsc47m192", I2C_NAME_SIZE); |
533 | data->vrm = vid_which_vrm(); | 534 | data->vrm = vid_which_vrm(); |
534 | init_MUTEX(&data->update_lock); | 535 | mutex_init(&data->update_lock); |
535 | 536 | ||
536 | /* Tell the I2C layer a new client has arrived */ | 537 | /* Tell the I2C layer a new client has arrived */ |
537 | if ((err = i2c_attach_client(client))) | 538 | if ((err = i2c_attach_client(client))) |
@@ -594,7 +595,7 @@ static struct smsc47m192_data *smsc47m192_update_device(struct device *dev) | |||
594 | struct smsc47m192_data *data = i2c_get_clientdata(client); | 595 | struct smsc47m192_data *data = i2c_get_clientdata(client); |
595 | int i, config; | 596 | int i, config; |
596 | 597 | ||
597 | down(&data->update_lock); | 598 | mutex_lock(&data->update_lock); |
598 | 599 | ||
599 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 600 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
600 | || !data->valid) { | 601 | || !data->valid) { |
@@ -645,7 +646,7 @@ static struct smsc47m192_data *smsc47m192_update_device(struct device *dev) | |||
645 | data->valid = 1; | 646 | data->valid = 1; |
646 | } | 647 | } |
647 | 648 | ||
648 | up(&data->update_lock); | 649 | mutex_unlock(&data->update_lock); |
649 | 650 | ||
650 | return data; | 651 | return data; |
651 | } | 652 | } |