aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm80.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-01-18 17:19:26 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-23 17:21:52 -0500
commit9a61bf6300533d3b64d7ff29adfec00e596de67d (patch)
treecadce1ae78b51a1dc4c4414699cb590e8c8625e1 /drivers/hwmon/lm80.c
parent3fb9a65529615944138d527b70174840c95c637a (diff)
[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>
Diffstat (limited to 'drivers/hwmon/lm80.c')
-rw-r--r--drivers/hwmon/lm80.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index c9a7cdea7bd7..f72120d08c4c 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -28,6 +28,7 @@
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/hwmon.h> 29#include <linux/hwmon.h>
30#include <linux/err.h> 30#include <linux/err.h>
31#include <linux/mutex.h>
31 32
32/* Addresses to scan */ 33/* Addresses to scan */
33static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 34static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c,
@@ -108,7 +109,7 @@ static inline long TEMP_FROM_REG(u16 temp)
108struct lm80_data { 109struct lm80_data {
109 struct i2c_client client; 110 struct i2c_client client;
110 struct class_device *class_dev; 111 struct class_device *class_dev;
111 struct semaphore update_lock; 112 struct mutex update_lock;
112 char valid; /* !=0 if following fields are valid */ 113 char valid; /* !=0 if following fields are valid */
113 unsigned long last_updated; /* In jiffies */ 114 unsigned long last_updated; /* In jiffies */
114 115
@@ -191,10 +192,10 @@ static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr
191 struct lm80_data *data = i2c_get_clientdata(client); \ 192 struct lm80_data *data = i2c_get_clientdata(client); \
192 long val = simple_strtol(buf, NULL, 10); \ 193 long val = simple_strtol(buf, NULL, 10); \
193 \ 194 \
194 down(&data->update_lock);\ 195 mutex_lock(&data->update_lock);\
195 data->value = IN_TO_REG(val); \ 196 data->value = IN_TO_REG(val); \
196 lm80_write_value(client, reg, data->value); \ 197 lm80_write_value(client, reg, data->value); \
197 up(&data->update_lock);\ 198 mutex_unlock(&data->update_lock);\
198 return count; \ 199 return count; \
199} 200}
200set_in(min0, in_min[0], LM80_REG_IN_MIN(0)); 201set_in(min0, in_min[0], LM80_REG_IN_MIN(0));
@@ -241,10 +242,10 @@ static ssize_t set_fan_##suffix(struct device *dev, struct device_attribute *att
241 struct lm80_data *data = i2c_get_clientdata(client); \ 242 struct lm80_data *data = i2c_get_clientdata(client); \
242 long val = simple_strtoul(buf, NULL, 10); \ 243 long val = simple_strtoul(buf, NULL, 10); \
243 \ 244 \
244 down(&data->update_lock);\ 245 mutex_lock(&data->update_lock);\
245 data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \ 246 data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \
246 lm80_write_value(client, reg, data->value); \ 247 lm80_write_value(client, reg, data->value); \
247 up(&data->update_lock);\ 248 mutex_unlock(&data->update_lock);\
248 return count; \ 249 return count; \
249} 250}
250set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]); 251set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]);
@@ -263,7 +264,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
263 u8 reg; 264 u8 reg;
264 265
265 /* Save fan_min */ 266 /* Save fan_min */
266 down(&data->update_lock); 267 mutex_lock(&data->update_lock);
267 min = FAN_FROM_REG(data->fan_min[nr], 268 min = FAN_FROM_REG(data->fan_min[nr],
268 DIV_FROM_REG(data->fan_div[nr])); 269 DIV_FROM_REG(data->fan_div[nr]));
269 270
@@ -275,7 +276,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
275 default: 276 default:
276 dev_err(&client->dev, "fan_div value %ld not " 277 dev_err(&client->dev, "fan_div value %ld not "
277 "supported. Choose one of 1, 2, 4 or 8!\n", val); 278 "supported. Choose one of 1, 2, 4 or 8!\n", val);
278 up(&data->update_lock); 279 mutex_unlock(&data->update_lock);
279 return -EINVAL; 280 return -EINVAL;
280 } 281 }
281 282
@@ -286,7 +287,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
286 /* Restore fan_min */ 287 /* Restore fan_min */
287 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 288 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
288 lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]); 289 lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]);
289 up(&data->update_lock); 290 mutex_unlock(&data->update_lock);
290 291
291 return count; 292 return count;
292} 293}
@@ -325,10 +326,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at
325 struct lm80_data *data = i2c_get_clientdata(client); \ 326 struct lm80_data *data = i2c_get_clientdata(client); \
326 long val = simple_strtoul(buf, NULL, 10); \ 327 long val = simple_strtoul(buf, NULL, 10); \
327 \ 328 \
328 down(&data->update_lock); \ 329 mutex_lock(&data->update_lock); \
329 data->value = TEMP_LIMIT_TO_REG(val); \ 330 data->value = TEMP_LIMIT_TO_REG(val); \
330 lm80_write_value(client, reg, data->value); \ 331 lm80_write_value(client, reg, data->value); \
331 up(&data->update_lock); \ 332 mutex_unlock(&data->update_lock); \
332 return count; \ 333 return count; \
333} 334}
334set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX); 335set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX);
@@ -437,7 +438,7 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
437 /* Fill in the remaining client fields and put it into the global list */ 438 /* Fill in the remaining client fields and put it into the global list */
438 strlcpy(new_client->name, name, I2C_NAME_SIZE); 439 strlcpy(new_client->name, name, I2C_NAME_SIZE);
439 data->valid = 0; 440 data->valid = 0;
440 init_MUTEX(&data->update_lock); 441 mutex_init(&data->update_lock);
441 442
442 /* Tell the I2C layer a new client has arrived */ 443 /* Tell the I2C layer a new client has arrived */
443 if ((err = i2c_attach_client(new_client))) 444 if ((err = i2c_attach_client(new_client)))
@@ -545,7 +546,7 @@ static struct lm80_data *lm80_update_device(struct device *dev)
545 struct lm80_data *data = i2c_get_clientdata(client); 546 struct lm80_data *data = i2c_get_clientdata(client);
546 int i; 547 int i;
547 548
548 down(&data->update_lock); 549 mutex_lock(&data->update_lock);
549 550
550 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { 551 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
551 dev_dbg(&client->dev, "Starting lm80 update\n"); 552 dev_dbg(&client->dev, "Starting lm80 update\n");
@@ -585,7 +586,7 @@ static struct lm80_data *lm80_update_device(struct device *dev)
585 data->valid = 1; 586 data->valid = 1;
586 } 587 }
587 588
588 up(&data->update_lock); 589 mutex_unlock(&data->update_lock);
589 590
590 return data; 591 return data;
591} 592}