aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/asb100.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/asb100.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/asb100.c')
-rw-r--r--drivers/hwmon/asb100.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index ae9de63cf2e0..65b2709f750c 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -44,6 +44,7 @@
44#include <linux/err.h> 44#include <linux/err.h>
45#include <linux/init.h> 45#include <linux/init.h>
46#include <linux/jiffies.h> 46#include <linux/jiffies.h>
47#include <linux/mutex.h>
47#include "lm75.h" 48#include "lm75.h"
48 49
49/* 50/*
@@ -182,10 +183,10 @@ static u8 DIV_TO_REG(long val)
182struct asb100_data { 183struct asb100_data {
183 struct i2c_client client; 184 struct i2c_client client;
184 struct class_device *class_dev; 185 struct class_device *class_dev;
185 struct semaphore lock; 186 struct mutex lock;
186 enum chips type; 187 enum chips type;
187 188
188 struct semaphore update_lock; 189 struct mutex update_lock;
189 unsigned long last_updated; /* In jiffies */ 190 unsigned long last_updated; /* In jiffies */
190 191
191 /* array of 2 pointers to subclients */ 192 /* array of 2 pointers to subclients */
@@ -245,11 +246,11 @@ static ssize_t set_in_##reg(struct device *dev, const char *buf, \
245 struct asb100_data *data = i2c_get_clientdata(client); \ 246 struct asb100_data *data = i2c_get_clientdata(client); \
246 unsigned long val = simple_strtoul(buf, NULL, 10); \ 247 unsigned long val = simple_strtoul(buf, NULL, 10); \
247 \ 248 \
248 down(&data->update_lock); \ 249 mutex_lock(&data->update_lock); \
249 data->in_##reg[nr] = IN_TO_REG(val); \ 250 data->in_##reg[nr] = IN_TO_REG(val); \
250 asb100_write_value(client, ASB100_REG_IN_##REG(nr), \ 251 asb100_write_value(client, ASB100_REG_IN_##REG(nr), \
251 data->in_##reg[nr]); \ 252 data->in_##reg[nr]); \
252 up(&data->update_lock); \ 253 mutex_unlock(&data->update_lock); \
253 return count; \ 254 return count; \
254} 255}
255 256
@@ -331,10 +332,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
331 struct asb100_data *data = i2c_get_clientdata(client); 332 struct asb100_data *data = i2c_get_clientdata(client);
332 u32 val = simple_strtoul(buf, NULL, 10); 333 u32 val = simple_strtoul(buf, NULL, 10);
333 334
334 down(&data->update_lock); 335 mutex_lock(&data->update_lock);
335 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 336 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
336 asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); 337 asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]);
337 up(&data->update_lock); 338 mutex_unlock(&data->update_lock);
338 return count; 339 return count;
339} 340}
340 341
@@ -351,7 +352,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
351 unsigned long val = simple_strtoul(buf, NULL, 10); 352 unsigned long val = simple_strtoul(buf, NULL, 10);
352 int reg; 353 int reg;
353 354
354 down(&data->update_lock); 355 mutex_lock(&data->update_lock);
355 356
356 min = FAN_FROM_REG(data->fan_min[nr], 357 min = FAN_FROM_REG(data->fan_min[nr],
357 DIV_FROM_REG(data->fan_div[nr])); 358 DIV_FROM_REG(data->fan_div[nr]));
@@ -381,7 +382,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
381 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 382 FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
382 asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]); 383 asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]);
383 384
384 up(&data->update_lock); 385 mutex_unlock(&data->update_lock);
385 386
386 return count; 387 return count;
387} 388}
@@ -461,7 +462,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \
461 struct asb100_data *data = i2c_get_clientdata(client); \ 462 struct asb100_data *data = i2c_get_clientdata(client); \
462 unsigned long val = simple_strtoul(buf, NULL, 10); \ 463 unsigned long val = simple_strtoul(buf, NULL, 10); \
463 \ 464 \
464 down(&data->update_lock); \ 465 mutex_lock(&data->update_lock); \
465 switch (nr) { \ 466 switch (nr) { \
466 case 1: case 2: \ 467 case 1: case 2: \
467 data->reg[nr] = LM75_TEMP_TO_REG(val); \ 468 data->reg[nr] = LM75_TEMP_TO_REG(val); \
@@ -472,7 +473,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \
472 } \ 473 } \
473 asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \ 474 asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \
474 data->reg[nr]); \ 475 data->reg[nr]); \
475 up(&data->update_lock); \ 476 mutex_unlock(&data->update_lock); \
476 return count; \ 477 return count; \
477} 478}
478 479
@@ -574,11 +575,11 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const
574 struct asb100_data *data = i2c_get_clientdata(client); 575 struct asb100_data *data = i2c_get_clientdata(client);
575 unsigned long val = simple_strtoul(buf, NULL, 10); 576 unsigned long val = simple_strtoul(buf, NULL, 10);
576 577
577 down(&data->update_lock); 578 mutex_lock(&data->update_lock);
578 data->pwm &= 0x80; /* keep the enable bit */ 579 data->pwm &= 0x80; /* keep the enable bit */
579 data->pwm |= (0x0f & ASB100_PWM_TO_REG(val)); 580 data->pwm |= (0x0f & ASB100_PWM_TO_REG(val));
580 asb100_write_value(client, ASB100_REG_PWM1, data->pwm); 581 asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
581 up(&data->update_lock); 582 mutex_unlock(&data->update_lock);
582 return count; 583 return count;
583} 584}
584 585
@@ -595,11 +596,11 @@ static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr
595 struct asb100_data *data = i2c_get_clientdata(client); 596 struct asb100_data *data = i2c_get_clientdata(client);
596 unsigned long val = simple_strtoul(buf, NULL, 10); 597 unsigned long val = simple_strtoul(buf, NULL, 10);
597 598
598 down(&data->update_lock); 599 mutex_lock(&data->update_lock);
599 data->pwm &= 0x0f; /* keep the duty cycle bits */ 600 data->pwm &= 0x0f; /* keep the duty cycle bits */
600 data->pwm |= (val ? 0x80 : 0x00); 601 data->pwm |= (val ? 0x80 : 0x00);
601 asb100_write_value(client, ASB100_REG_PWM1, data->pwm); 602 asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
602 up(&data->update_lock); 603 mutex_unlock(&data->update_lock);
603 return count; 604 return count;
604} 605}
605 606
@@ -729,7 +730,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
729 } 730 }
730 731
731 new_client = &data->client; 732 new_client = &data->client;
732 init_MUTEX(&data->lock); 733 mutex_init(&data->lock);
733 i2c_set_clientdata(new_client, data); 734 i2c_set_clientdata(new_client, data);
734 new_client->addr = address; 735 new_client->addr = address;
735 new_client->adapter = adapter; 736 new_client->adapter = adapter;
@@ -789,7 +790,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
789 data->type = kind; 790 data->type = kind;
790 791
791 data->valid = 0; 792 data->valid = 0;
792 init_MUTEX(&data->update_lock); 793 mutex_init(&data->update_lock);
793 794
794 /* Tell the I2C layer a new client has arrived */ 795 /* Tell the I2C layer a new client has arrived */
795 if ((err = i2c_attach_client(new_client))) 796 if ((err = i2c_attach_client(new_client)))
@@ -885,7 +886,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
885 struct i2c_client *cl; 886 struct i2c_client *cl;
886 int res, bank; 887 int res, bank;
887 888
888 down(&data->lock); 889 mutex_lock(&data->lock);
889 890
890 bank = (reg >> 8) & 0x0f; 891 bank = (reg >> 8) & 0x0f;
891 if (bank > 2) 892 if (bank > 2)
@@ -919,7 +920,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
919 if (bank > 2) 920 if (bank > 2)
920 i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); 921 i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0);
921 922
922 up(&data->lock); 923 mutex_unlock(&data->lock);
923 924
924 return res; 925 return res;
925} 926}
@@ -930,7 +931,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
930 struct i2c_client *cl; 931 struct i2c_client *cl;
931 int bank; 932 int bank;
932 933
933 down(&data->lock); 934 mutex_lock(&data->lock);
934 935
935 bank = (reg >> 8) & 0x0f; 936 bank = (reg >> 8) & 0x0f;
936 if (bank > 2) 937 if (bank > 2)
@@ -960,7 +961,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
960 if (bank > 2) 961 if (bank > 2)
961 i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0); 962 i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0);
962 963
963 up(&data->lock); 964 mutex_unlock(&data->lock);
964} 965}
965 966
966static void asb100_init_client(struct i2c_client *client) 967static void asb100_init_client(struct i2c_client *client)
@@ -984,7 +985,7 @@ static struct asb100_data *asb100_update_device(struct device *dev)
984 struct asb100_data *data = i2c_get_clientdata(client); 985 struct asb100_data *data = i2c_get_clientdata(client);
985 int i; 986 int i;
986 987
987 down(&data->update_lock); 988 mutex_lock(&data->update_lock);
988 989
989 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 990 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
990 || !data->valid) { 991 || !data->valid) {
@@ -1042,7 +1043,7 @@ static struct asb100_data *asb100_update_device(struct device *dev)
1042 dev_dbg(&client->dev, "... device update complete\n"); 1043 dev_dbg(&client->dev, "... device update complete\n");
1043 } 1044 }
1044 1045
1045 up(&data->update_lock); 1046 mutex_unlock(&data->update_lock);
1046 1047
1047 return data; 1048 return data;
1048} 1049}