aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83627hf.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/w83627hf.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/w83627hf.c')
-rw-r--r--drivers/hwmon/w83627hf.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 7ea441d4da63..3d4888c178c9 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -46,6 +46,7 @@
46#include <linux/hwmon.h> 46#include <linux/hwmon.h>
47#include <linux/hwmon-vid.h> 47#include <linux/hwmon-vid.h>
48#include <linux/err.h> 48#include <linux/err.h>
49#include <linux/mutex.h>
49#include <asm/io.h> 50#include <asm/io.h>
50#include "lm75.h" 51#include "lm75.h"
51 52
@@ -285,10 +286,10 @@ static inline u8 DIV_TO_REG(long val)
285struct w83627hf_data { 286struct w83627hf_data {
286 struct i2c_client client; 287 struct i2c_client client;
287 struct class_device *class_dev; 288 struct class_device *class_dev;
288 struct semaphore lock; 289 struct mutex lock;
289 enum chips type; 290 enum chips type;
290 291
291 struct semaphore update_lock; 292 struct mutex update_lock;
292 char valid; /* !=0 if following fields are valid */ 293 char valid; /* !=0 if following fields are valid */
293 unsigned long last_updated; /* In jiffies */ 294 unsigned long last_updated; /* In jiffies */
294 295
@@ -360,12 +361,12 @@ store_in_##reg (struct device *dev, const char *buf, size_t count, int nr) \
360 \ 361 \
361 val = simple_strtoul(buf, NULL, 10); \ 362 val = simple_strtoul(buf, NULL, 10); \
362 \ 363 \
363 down(&data->update_lock); \ 364 mutex_lock(&data->update_lock); \
364 data->in_##reg[nr] = IN_TO_REG(val); \ 365 data->in_##reg[nr] = IN_TO_REG(val); \
365 w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \ 366 w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \
366 data->in_##reg[nr]); \ 367 data->in_##reg[nr]); \
367 \ 368 \
368 up(&data->update_lock); \ 369 mutex_unlock(&data->update_lock); \
369 return count; \ 370 return count; \
370} 371}
371store_in_reg(MIN, min) 372store_in_reg(MIN, min)
@@ -451,7 +452,7 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a
451 452
452 val = simple_strtoul(buf, NULL, 10); 453 val = simple_strtoul(buf, NULL, 10);
453 454
454 down(&data->update_lock); 455 mutex_lock(&data->update_lock);
455 456
456 if ((data->vrm_ovt & 0x01) && 457 if ((data->vrm_ovt & 0x01) &&
457 (w83627thf == data->type || w83637hf == data->type)) 458 (w83627thf == data->type || w83637hf == data->type))
@@ -465,7 +466,7 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a
465 data->in_min[0] = IN_TO_REG(val); 466 data->in_min[0] = IN_TO_REG(val);
466 467
467 w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]); 468 w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]);
468 up(&data->update_lock); 469 mutex_unlock(&data->update_lock);
469 return count; 470 return count;
470} 471}
471 472
@@ -478,7 +479,7 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a
478 479
479 val = simple_strtoul(buf, NULL, 10); 480 val = simple_strtoul(buf, NULL, 10);
480 481
481 down(&data->update_lock); 482 mutex_lock(&data->update_lock);
482 483
483 if ((data->vrm_ovt & 0x01) && 484 if ((data->vrm_ovt & 0x01) &&
484 (w83627thf == data->type || w83637hf == data->type)) 485 (w83627thf == data->type || w83637hf == data->type))
@@ -492,7 +493,7 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a
492 data->in_max[0] = IN_TO_REG(val); 493 data->in_max[0] = IN_TO_REG(val);
493 494
494 w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]); 495 w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]);
495 up(&data->update_lock); 496 mutex_unlock(&data->update_lock);
496 return count; 497 return count;
497} 498}
498 499
@@ -529,13 +530,13 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
529 530
530 val = simple_strtoul(buf, NULL, 10); 531 val = simple_strtoul(buf, NULL, 10);
531 532
532 down(&data->update_lock); 533 mutex_lock(&data->update_lock);
533 data->fan_min[nr - 1] = 534 data->fan_min[nr - 1] =
534 FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); 535 FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1]));
535 w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr), 536 w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr),
536 data->fan_min[nr - 1]); 537 data->fan_min[nr - 1]);
537 538
538 up(&data->update_lock); 539 mutex_unlock(&data->update_lock);
539 return count; 540 return count;
540} 541}
541 542
@@ -597,7 +598,7 @@ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \
597 \ 598 \
598 val = simple_strtoul(buf, NULL, 10); \ 599 val = simple_strtoul(buf, NULL, 10); \
599 \ 600 \
600 down(&data->update_lock); \ 601 mutex_lock(&data->update_lock); \
601 \ 602 \
602 if (nr >= 2) { /* TEMP2 and TEMP3 */ \ 603 if (nr >= 2) { /* TEMP2 and TEMP3 */ \
603 data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \ 604 data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \
@@ -609,7 +610,7 @@ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \
609 data->temp_##reg); \ 610 data->temp_##reg); \
610 } \ 611 } \
611 \ 612 \
612 up(&data->update_lock); \ 613 mutex_unlock(&data->update_lock); \
613 return count; \ 614 return count; \
614} 615}
615store_temp_reg(OVER, max); 616store_temp_reg(OVER, max);
@@ -718,7 +719,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count,
718 719
719 val = simple_strtoul(buf, NULL, 10); 720 val = simple_strtoul(buf, NULL, 10);
720 721
721 down(&data->update_lock); 722 mutex_lock(&data->update_lock);
722 723
723 if (update_mask == BEEP_MASK) { /* We are storing beep_mask */ 724 if (update_mask == BEEP_MASK) { /* We are storing beep_mask */
724 data->beep_mask = BEEP_MASK_TO_REG(val); 725 data->beep_mask = BEEP_MASK_TO_REG(val);
@@ -736,7 +737,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count,
736 w83627hf_write_value(client, W83781D_REG_BEEP_INTS2, 737 w83627hf_write_value(client, W83781D_REG_BEEP_INTS2,
737 val2 | data->beep_enable << 7); 738 val2 | data->beep_enable << 7);
738 739
739 up(&data->update_lock); 740 mutex_unlock(&data->update_lock);
740 return count; 741 return count;
741} 742}
742 743
@@ -783,7 +784,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
783 u8 reg; 784 u8 reg;
784 unsigned long val = simple_strtoul(buf, NULL, 10); 785 unsigned long val = simple_strtoul(buf, NULL, 10);
785 786
786 down(&data->update_lock); 787 mutex_lock(&data->update_lock);
787 788
788 /* Save fan_min */ 789 /* Save fan_min */
789 min = FAN_FROM_REG(data->fan_min[nr], 790 min = FAN_FROM_REG(data->fan_min[nr],
@@ -805,7 +806,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
805 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 806 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
806 w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); 807 w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]);
807 808
808 up(&data->update_lock); 809 mutex_unlock(&data->update_lock);
809 return count; 810 return count;
810} 811}
811 812
@@ -848,7 +849,7 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr)
848 849
849 val = simple_strtoul(buf, NULL, 10); 850 val = simple_strtoul(buf, NULL, 10);
850 851
851 down(&data->update_lock); 852 mutex_lock(&data->update_lock);
852 853
853 if (data->type == w83627thf) { 854 if (data->type == w83627thf) {
854 /* bits 0-3 are reserved in 627THF */ 855 /* bits 0-3 are reserved in 627THF */
@@ -865,7 +866,7 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr)
865 data->pwm[nr - 1]); 866 data->pwm[nr - 1]);
866 } 867 }
867 868
868 up(&data->update_lock); 869 mutex_unlock(&data->update_lock);
869 return count; 870 return count;
870} 871}
871 872
@@ -907,7 +908,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
907 908
908 val = simple_strtoul(buf, NULL, 10); 909 val = simple_strtoul(buf, NULL, 10);
909 910
910 down(&data->update_lock); 911 mutex_lock(&data->update_lock);
911 912
912 switch (val) { 913 switch (val) {
913 case 1: /* PII/Celeron diode */ 914 case 1: /* PII/Celeron diode */
@@ -941,7 +942,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
941 break; 942 break;
942 } 943 }
943 944
944 up(&data->update_lock); 945 mutex_unlock(&data->update_lock);
945 return count; 946 return count;
946} 947}
947 948
@@ -1057,7 +1058,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
1057 new_client = &data->client; 1058 new_client = &data->client;
1058 i2c_set_clientdata(new_client, data); 1059 i2c_set_clientdata(new_client, data);
1059 new_client->addr = address; 1060 new_client->addr = address;
1060 init_MUTEX(&data->lock); 1061 mutex_init(&data->lock);
1061 new_client->adapter = adapter; 1062 new_client->adapter = adapter;
1062 new_client->driver = &w83627hf_driver; 1063 new_client->driver = &w83627hf_driver;
1063 new_client->flags = 0; 1064 new_client->flags = 0;
@@ -1077,7 +1078,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
1077 strlcpy(new_client->name, client_name, I2C_NAME_SIZE); 1078 strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
1078 data->type = kind; 1079 data->type = kind;
1079 data->valid = 0; 1080 data->valid = 0;
1080 init_MUTEX(&data->update_lock); 1081 mutex_init(&data->update_lock);
1081 1082
1082 /* Tell the I2C layer a new client has arrived */ 1083 /* Tell the I2C layer a new client has arrived */
1083 if ((err = i2c_attach_client(new_client))) 1084 if ((err = i2c_attach_client(new_client)))
@@ -1187,7 +1188,7 @@ static int w83627hf_read_value(struct i2c_client *client, u16 reg)
1187 struct w83627hf_data *data = i2c_get_clientdata(client); 1188 struct w83627hf_data *data = i2c_get_clientdata(client);
1188 int res, word_sized; 1189 int res, word_sized;
1189 1190
1190 down(&data->lock); 1191 mutex_lock(&data->lock);
1191 word_sized = (((reg & 0xff00) == 0x100) 1192 word_sized = (((reg & 0xff00) == 0x100)
1192 || ((reg & 0xff00) == 0x200)) 1193 || ((reg & 0xff00) == 0x200))
1193 && (((reg & 0x00ff) == 0x50) 1194 && (((reg & 0x00ff) == 0x50)
@@ -1213,7 +1214,7 @@ static int w83627hf_read_value(struct i2c_client *client, u16 reg)
1213 client->addr + W83781D_ADDR_REG_OFFSET); 1214 client->addr + W83781D_ADDR_REG_OFFSET);
1214 outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); 1215 outb_p(0, client->addr + W83781D_DATA_REG_OFFSET);
1215 } 1216 }
1216 up(&data->lock); 1217 mutex_unlock(&data->lock);
1217 return res; 1218 return res;
1218} 1219}
1219 1220
@@ -1252,7 +1253,7 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value)
1252 struct w83627hf_data *data = i2c_get_clientdata(client); 1253 struct w83627hf_data *data = i2c_get_clientdata(client);
1253 int word_sized; 1254 int word_sized;
1254 1255
1255 down(&data->lock); 1256 mutex_lock(&data->lock);
1256 word_sized = (((reg & 0xff00) == 0x100) 1257 word_sized = (((reg & 0xff00) == 0x100)
1257 || ((reg & 0xff00) == 0x200)) 1258 || ((reg & 0xff00) == 0x200))
1258 && (((reg & 0x00ff) == 0x53) 1259 && (((reg & 0x00ff) == 0x53)
@@ -1277,7 +1278,7 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value)
1277 client->addr + W83781D_ADDR_REG_OFFSET); 1278 client->addr + W83781D_ADDR_REG_OFFSET);
1278 outb_p(0, client->addr + W83781D_DATA_REG_OFFSET); 1279 outb_p(0, client->addr + W83781D_DATA_REG_OFFSET);
1279 } 1280 }
1280 up(&data->lock); 1281 mutex_unlock(&data->lock);
1281 return 0; 1282 return 0;
1282} 1283}
1283 1284
@@ -1387,7 +1388,7 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
1387 struct w83627hf_data *data = i2c_get_clientdata(client); 1388 struct w83627hf_data *data = i2c_get_clientdata(client);
1388 int i; 1389 int i;
1389 1390
1390 down(&data->update_lock); 1391 mutex_lock(&data->update_lock);
1391 1392
1392 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 1393 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
1393 || !data->valid) { 1394 || !data->valid) {
@@ -1470,7 +1471,7 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
1470 data->valid = 1; 1471 data->valid = 1;
1471 } 1472 }
1472 1473
1473 up(&data->update_lock); 1474 mutex_unlock(&data->update_lock);
1474 1475
1475 return data; 1476 return data;
1476} 1477}