aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm87.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/lm87.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/lm87.c')
-rw-r--r--drivers/hwmon/lm87.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index 6ba34c302d8d..e229daf666de 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -60,6 +60,7 @@
60#include <linux/hwmon.h> 60#include <linux/hwmon.h>
61#include <linux/hwmon-vid.h> 61#include <linux/hwmon-vid.h>
62#include <linux/err.h> 62#include <linux/err.h>
63#include <linux/mutex.h>
63 64
64/* 65/*
65 * Addresses to scan 66 * Addresses to scan
@@ -176,7 +177,7 @@ static struct i2c_driver lm87_driver = {
176struct lm87_data { 177struct lm87_data {
177 struct i2c_client client; 178 struct i2c_client client;
178 struct class_device *class_dev; 179 struct class_device *class_dev;
179 struct semaphore update_lock; 180 struct mutex update_lock;
180 char valid; /* zero until following fields are valid */ 181 char valid; /* zero until following fields are valid */
181 unsigned long last_updated; /* In jiffies */ 182 unsigned long last_updated; /* In jiffies */
182 183
@@ -253,11 +254,11 @@ static void set_in_min(struct device *dev, const char *buf, int nr)
253 struct lm87_data *data = i2c_get_clientdata(client); 254 struct lm87_data *data = i2c_get_clientdata(client);
254 long val = simple_strtol(buf, NULL, 10); 255 long val = simple_strtol(buf, NULL, 10);
255 256
256 down(&data->update_lock); 257 mutex_lock(&data->update_lock);
257 data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]); 258 data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]);
258 lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) : 259 lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) :
259 LM87_REG_AIN_MIN(nr-6), data->in_min[nr]); 260 LM87_REG_AIN_MIN(nr-6), data->in_min[nr]);
260 up(&data->update_lock); 261 mutex_unlock(&data->update_lock);
261} 262}
262 263
263static void set_in_max(struct device *dev, const char *buf, int nr) 264static void set_in_max(struct device *dev, const char *buf, int nr)
@@ -266,11 +267,11 @@ static void set_in_max(struct device *dev, const char *buf, int nr)
266 struct lm87_data *data = i2c_get_clientdata(client); 267 struct lm87_data *data = i2c_get_clientdata(client);
267 long val = simple_strtol(buf, NULL, 10); 268 long val = simple_strtol(buf, NULL, 10);
268 269
269 down(&data->update_lock); 270 mutex_lock(&data->update_lock);
270 data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]); 271 data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]);
271 lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) : 272 lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) :
272 LM87_REG_AIN_MAX(nr-6), data->in_max[nr]); 273 LM87_REG_AIN_MAX(nr-6), data->in_max[nr]);
273 up(&data->update_lock); 274 mutex_unlock(&data->update_lock);
274} 275}
275 276
276#define set_in(offset) \ 277#define set_in(offset) \
@@ -327,10 +328,10 @@ static void set_temp_low(struct device *dev, const char *buf, int nr)
327 struct lm87_data *data = i2c_get_clientdata(client); 328 struct lm87_data *data = i2c_get_clientdata(client);
328 long val = simple_strtol(buf, NULL, 10); 329 long val = simple_strtol(buf, NULL, 10);
329 330
330 down(&data->update_lock); 331 mutex_lock(&data->update_lock);
331 data->temp_low[nr] = TEMP_TO_REG(val); 332 data->temp_low[nr] = TEMP_TO_REG(val);
332 lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]); 333 lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]);
333 up(&data->update_lock); 334 mutex_unlock(&data->update_lock);
334} 335}
335 336
336static void set_temp_high(struct device *dev, const char *buf, int nr) 337static void set_temp_high(struct device *dev, const char *buf, int nr)
@@ -339,10 +340,10 @@ static void set_temp_high(struct device *dev, const char *buf, int nr)
339 struct lm87_data *data = i2c_get_clientdata(client); 340 struct lm87_data *data = i2c_get_clientdata(client);
340 long val = simple_strtol(buf, NULL, 10); 341 long val = simple_strtol(buf, NULL, 10);
341 342
342 down(&data->update_lock); 343 mutex_lock(&data->update_lock);
343 data->temp_high[nr] = TEMP_TO_REG(val); 344 data->temp_high[nr] = TEMP_TO_REG(val);
344 lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]); 345 lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]);
345 up(&data->update_lock); 346 mutex_unlock(&data->update_lock);
346} 347}
347 348
348#define set_temp(offset) \ 349#define set_temp(offset) \
@@ -411,11 +412,11 @@ static void set_fan_min(struct device *dev, const char *buf, int nr)
411 struct lm87_data *data = i2c_get_clientdata(client); 412 struct lm87_data *data = i2c_get_clientdata(client);
412 long val = simple_strtol(buf, NULL, 10); 413 long val = simple_strtol(buf, NULL, 10);
413 414
414 down(&data->update_lock); 415 mutex_lock(&data->update_lock);
415 data->fan_min[nr] = FAN_TO_REG(val, 416 data->fan_min[nr] = FAN_TO_REG(val,
416 FAN_DIV_FROM_REG(data->fan_div[nr])); 417 FAN_DIV_FROM_REG(data->fan_div[nr]));
417 lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]); 418 lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]);
418 up(&data->update_lock); 419 mutex_unlock(&data->update_lock);
419} 420}
420 421
421/* Note: we save and restore the fan minimum here, because its value is 422/* Note: we save and restore the fan minimum here, because its value is
@@ -431,7 +432,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
431 unsigned long min; 432 unsigned long min;
432 u8 reg; 433 u8 reg;
433 434
434 down(&data->update_lock); 435 mutex_lock(&data->update_lock);
435 min = FAN_FROM_REG(data->fan_min[nr], 436 min = FAN_FROM_REG(data->fan_min[nr],
436 FAN_DIV_FROM_REG(data->fan_div[nr])); 437 FAN_DIV_FROM_REG(data->fan_div[nr]));
437 438
@@ -441,7 +442,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
441 case 4: data->fan_div[nr] = 2; break; 442 case 4: data->fan_div[nr] = 2; break;
442 case 8: data->fan_div[nr] = 3; break; 443 case 8: data->fan_div[nr] = 3; break;
443 default: 444 default:
444 up(&data->update_lock); 445 mutex_unlock(&data->update_lock);
445 return -EINVAL; 446 return -EINVAL;
446 } 447 }
447 448
@@ -459,7 +460,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
459 data->fan_min[nr] = FAN_TO_REG(min, val); 460 data->fan_min[nr] = FAN_TO_REG(min, val);
460 lm87_write_value(client, LM87_REG_FAN_MIN(nr), 461 lm87_write_value(client, LM87_REG_FAN_MIN(nr),
461 data->fan_min[nr]); 462 data->fan_min[nr]);
462 up(&data->update_lock); 463 mutex_unlock(&data->update_lock);
463 464
464 return count; 465 return count;
465} 466}
@@ -522,10 +523,10 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const
522 struct lm87_data *data = i2c_get_clientdata(client); 523 struct lm87_data *data = i2c_get_clientdata(client);
523 long val = simple_strtol(buf, NULL, 10); 524 long val = simple_strtol(buf, NULL, 10);
524 525
525 down(&data->update_lock); 526 mutex_lock(&data->update_lock);
526 data->aout = AOUT_TO_REG(val); 527 data->aout = AOUT_TO_REG(val);
527 lm87_write_value(client, LM87_REG_AOUT, data->aout); 528 lm87_write_value(client, LM87_REG_AOUT, data->aout);
528 up(&data->update_lock); 529 mutex_unlock(&data->update_lock);
529 return count; 530 return count;
530} 531}
531static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); 532static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
@@ -589,7 +590,7 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
589 /* We can fill in the remaining client fields */ 590 /* We can fill in the remaining client fields */
590 strlcpy(new_client->name, "lm87", I2C_NAME_SIZE); 591 strlcpy(new_client->name, "lm87", I2C_NAME_SIZE);
591 data->valid = 0; 592 data->valid = 0;
592 init_MUTEX(&data->update_lock); 593 mutex_init(&data->update_lock);
593 594
594 /* Tell the I2C layer a new client has arrived */ 595 /* Tell the I2C layer a new client has arrived */
595 if ((err = i2c_attach_client(new_client))) 596 if ((err = i2c_attach_client(new_client)))
@@ -744,7 +745,7 @@ static struct lm87_data *lm87_update_device(struct device *dev)
744 struct i2c_client *client = to_i2c_client(dev); 745 struct i2c_client *client = to_i2c_client(dev);
745 struct lm87_data *data = i2c_get_clientdata(client); 746 struct lm87_data *data = i2c_get_clientdata(client);
746 747
747 down(&data->update_lock); 748 mutex_lock(&data->update_lock);
748 749
749 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 750 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
750 int i, j; 751 int i, j;
@@ -813,7 +814,7 @@ static struct lm87_data *lm87_update_device(struct device *dev)
813 data->valid = 1; 814 data->valid = 1;
814 } 815 }
815 816
816 up(&data->update_lock); 817 mutex_unlock(&data->update_lock);
817 818
818 return data; 819 return data;
819} 820}