aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm78.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/lm78.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/lm78.c')
-rw-r--r--drivers/hwmon/lm78.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index e404001e20da..36d1192ebe2a 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -27,6 +27,7 @@
27#include <linux/hwmon.h> 27#include <linux/hwmon.h>
28#include <linux/hwmon-vid.h> 28#include <linux/hwmon-vid.h>
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/mutex.h>
30#include <asm/io.h> 31#include <asm/io.h>
31 32
32/* Addresses to scan */ 33/* Addresses to scan */
@@ -131,10 +132,10 @@ static inline int TEMP_FROM_REG(s8 val)
131struct lm78_data { 132struct lm78_data {
132 struct i2c_client client; 133 struct i2c_client client;
133 struct class_device *class_dev; 134 struct class_device *class_dev;
134 struct semaphore lock; 135 struct mutex lock;
135 enum chips type; 136 enum chips type;
136 137
137 struct semaphore update_lock; 138 struct mutex update_lock;
138 char valid; /* !=0 if following fields are valid */ 139 char valid; /* !=0 if following fields are valid */
139 unsigned long last_updated; /* In jiffies */ 140 unsigned long last_updated; /* In jiffies */
140 141
@@ -207,10 +208,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
207 struct lm78_data *data = i2c_get_clientdata(client); 208 struct lm78_data *data = i2c_get_clientdata(client);
208 unsigned long val = simple_strtoul(buf, NULL, 10); 209 unsigned long val = simple_strtoul(buf, NULL, 10);
209 210
210 down(&data->update_lock); 211 mutex_lock(&data->update_lock);
211 data->in_min[nr] = IN_TO_REG(val); 212 data->in_min[nr] = IN_TO_REG(val);
212 lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]); 213 lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]);
213 up(&data->update_lock); 214 mutex_unlock(&data->update_lock);
214 return count; 215 return count;
215} 216}
216 217
@@ -221,10 +222,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
221 struct lm78_data *data = i2c_get_clientdata(client); 222 struct lm78_data *data = i2c_get_clientdata(client);
222 unsigned long val = simple_strtoul(buf, NULL, 10); 223 unsigned long val = simple_strtoul(buf, NULL, 10);
223 224
224 down(&data->update_lock); 225 mutex_lock(&data->update_lock);
225 data->in_max[nr] = IN_TO_REG(val); 226 data->in_max[nr] = IN_TO_REG(val);
226 lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]); 227 lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]);
227 up(&data->update_lock); 228 mutex_unlock(&data->update_lock);
228 return count; 229 return count;
229} 230}
230 231
@@ -288,10 +289,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr,
288 struct lm78_data *data = i2c_get_clientdata(client); 289 struct lm78_data *data = i2c_get_clientdata(client);
289 long val = simple_strtol(buf, NULL, 10); 290 long val = simple_strtol(buf, NULL, 10);
290 291
291 down(&data->update_lock); 292 mutex_lock(&data->update_lock);
292 data->temp_over = TEMP_TO_REG(val); 293 data->temp_over = TEMP_TO_REG(val);
293 lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over); 294 lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over);
294 up(&data->update_lock); 295 mutex_unlock(&data->update_lock);
295 return count; 296 return count;
296} 297}
297 298
@@ -307,10 +308,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr,
307 struct lm78_data *data = i2c_get_clientdata(client); 308 struct lm78_data *data = i2c_get_clientdata(client);
308 long val = simple_strtol(buf, NULL, 10); 309 long val = simple_strtol(buf, NULL, 10);
309 310
310 down(&data->update_lock); 311 mutex_lock(&data->update_lock);
311 data->temp_hyst = TEMP_TO_REG(val); 312 data->temp_hyst = TEMP_TO_REG(val);
312 lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst); 313 lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst);
313 up(&data->update_lock); 314 mutex_unlock(&data->update_lock);
314 return count; 315 return count;
315} 316}
316 317
@@ -342,10 +343,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
342 struct lm78_data *data = i2c_get_clientdata(client); 343 struct lm78_data *data = i2c_get_clientdata(client);
343 unsigned long val = simple_strtoul(buf, NULL, 10); 344 unsigned long val = simple_strtoul(buf, NULL, 10);
344 345
345 down(&data->update_lock); 346 mutex_lock(&data->update_lock);
346 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 347 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
347 lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); 348 lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]);
348 up(&data->update_lock); 349 mutex_unlock(&data->update_lock);
349 return count; 350 return count;
350} 351}
351 352
@@ -368,7 +369,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
368 unsigned long min; 369 unsigned long min;
369 u8 reg; 370 u8 reg;
370 371
371 down(&data->update_lock); 372 mutex_lock(&data->update_lock);
372 min = FAN_FROM_REG(data->fan_min[nr], 373 min = FAN_FROM_REG(data->fan_min[nr],
373 DIV_FROM_REG(data->fan_div[nr])); 374 DIV_FROM_REG(data->fan_div[nr]));
374 375
@@ -380,7 +381,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
380 default: 381 default:
381 dev_err(&client->dev, "fan_div value %ld not " 382 dev_err(&client->dev, "fan_div value %ld not "
382 "supported. Choose one of 1, 2, 4 or 8!\n", val); 383 "supported. Choose one of 1, 2, 4 or 8!\n", val);
383 up(&data->update_lock); 384 mutex_unlock(&data->update_lock);
384 return -EINVAL; 385 return -EINVAL;
385 } 386 }
386 387
@@ -398,7 +399,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
398 data->fan_min[nr] = 399 data->fan_min[nr] =
399 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 400 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
400 lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); 401 lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]);
401 up(&data->update_lock); 402 mutex_unlock(&data->update_lock);
402 403
403 return count; 404 return count;
404} 405}
@@ -548,7 +549,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
548 549
549 new_client = &data->client; 550 new_client = &data->client;
550 if (is_isa) 551 if (is_isa)
551 init_MUTEX(&data->lock); 552 mutex_init(&data->lock);
552 i2c_set_clientdata(new_client, data); 553 i2c_set_clientdata(new_client, data);
553 new_client->addr = address; 554 new_client->addr = address;
554 new_client->adapter = adapter; 555 new_client->adapter = adapter;
@@ -598,7 +599,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
598 data->type = kind; 599 data->type = kind;
599 600
600 data->valid = 0; 601 data->valid = 0;
601 init_MUTEX(&data->update_lock); 602 mutex_init(&data->update_lock);
602 603
603 /* Tell the I2C layer a new client has arrived */ 604 /* Tell the I2C layer a new client has arrived */
604 if ((err = i2c_attach_client(new_client))) 605 if ((err = i2c_attach_client(new_client)))
@@ -697,10 +698,10 @@ static int lm78_read_value(struct i2c_client *client, u8 reg)
697 int res; 698 int res;
698 if (i2c_is_isa_client(client)) { 699 if (i2c_is_isa_client(client)) {
699 struct lm78_data *data = i2c_get_clientdata(client); 700 struct lm78_data *data = i2c_get_clientdata(client);
700 down(&data->lock); 701 mutex_lock(&data->lock);
701 outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); 702 outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET);
702 res = inb_p(client->addr + LM78_DATA_REG_OFFSET); 703 res = inb_p(client->addr + LM78_DATA_REG_OFFSET);
703 up(&data->lock); 704 mutex_unlock(&data->lock);
704 return res; 705 return res;
705 } else 706 } else
706 return i2c_smbus_read_byte_data(client, reg); 707 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)
717{ 718{
718 if (i2c_is_isa_client(client)) { 719 if (i2c_is_isa_client(client)) {
719 struct lm78_data *data = i2c_get_clientdata(client); 720 struct lm78_data *data = i2c_get_clientdata(client);
720 down(&data->lock); 721 mutex_lock(&data->lock);
721 outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); 722 outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET);
722 outb_p(value, client->addr + LM78_DATA_REG_OFFSET); 723 outb_p(value, client->addr + LM78_DATA_REG_OFFSET);
723 up(&data->lock); 724 mutex_unlock(&data->lock);
724 return 0; 725 return 0;
725 } else 726 } else
726 return i2c_smbus_write_byte_data(client, reg, value); 727 return i2c_smbus_write_byte_data(client, reg, value);
@@ -742,7 +743,7 @@ static struct lm78_data *lm78_update_device(struct device *dev)
742 struct lm78_data *data = i2c_get_clientdata(client); 743 struct lm78_data *data = i2c_get_clientdata(client);
743 int i; 744 int i;
744 745
745 down(&data->update_lock); 746 mutex_lock(&data->update_lock);
746 747
747 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 748 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
748 || !data->valid) { 749 || !data->valid) {
@@ -786,7 +787,7 @@ static struct lm78_data *lm78_update_device(struct device *dev)
786 data->fan_div[2] = 1; 787 data->fan_div[2] = 1;
787 } 788 }
788 789
789 up(&data->update_lock); 790 mutex_unlock(&data->update_lock);
790 791
791 return data; 792 return data;
792} 793}