aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm85.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/lm85.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/lm85.c')
-rw-r--r--drivers/hwmon/lm85.c67
1 files changed, 34 insertions, 33 deletions
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index 7389a0127547..095e58ac2ceb 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -31,6 +31,7 @@
31#include <linux/hwmon.h> 31#include <linux/hwmon.h>
32#include <linux/hwmon-vid.h> 32#include <linux/hwmon-vid.h>
33#include <linux/err.h> 33#include <linux/err.h>
34#include <linux/mutex.h>
34 35
35/* Addresses to scan */ 36/* Addresses to scan */
36static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 37static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
@@ -331,10 +332,10 @@ struct lm85_autofan {
331struct lm85_data { 332struct lm85_data {
332 struct i2c_client client; 333 struct i2c_client client;
333 struct class_device *class_dev; 334 struct class_device *class_dev;
334 struct semaphore lock; 335 struct mutex lock;
335 enum chips type; 336 enum chips type;
336 337
337 struct semaphore update_lock; 338 struct mutex update_lock;
338 int valid; /* !=0 if following fields are valid */ 339 int valid; /* !=0 if following fields are valid */
339 unsigned long last_reading; /* In jiffies */ 340 unsigned long last_reading; /* In jiffies */
340 unsigned long last_config; /* In jiffies */ 341 unsigned long last_config; /* In jiffies */
@@ -407,10 +408,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
407 struct lm85_data *data = i2c_get_clientdata(client); 408 struct lm85_data *data = i2c_get_clientdata(client);
408 long val = simple_strtol(buf, NULL, 10); 409 long val = simple_strtol(buf, NULL, 10);
409 410
410 down(&data->update_lock); 411 mutex_lock(&data->update_lock);
411 data->fan_min[nr] = FAN_TO_REG(val); 412 data->fan_min[nr] = FAN_TO_REG(val);
412 lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]); 413 lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]);
413 up(&data->update_lock); 414 mutex_unlock(&data->update_lock);
414 return count; 415 return count;
415} 416}
416 417
@@ -499,10 +500,10 @@ static ssize_t set_pwm(struct device *dev, const char *buf,
499 struct lm85_data *data = i2c_get_clientdata(client); 500 struct lm85_data *data = i2c_get_clientdata(client);
500 long val = simple_strtol(buf, NULL, 10); 501 long val = simple_strtol(buf, NULL, 10);
501 502
502 down(&data->update_lock); 503 mutex_lock(&data->update_lock);
503 data->pwm[nr] = PWM_TO_REG(val); 504 data->pwm[nr] = PWM_TO_REG(val);
504 lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]); 505 lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]);
505 up(&data->update_lock); 506 mutex_unlock(&data->update_lock);
506 return count; 507 return count;
507} 508}
508static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) 509static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr)
@@ -559,10 +560,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
559 struct lm85_data *data = i2c_get_clientdata(client); 560 struct lm85_data *data = i2c_get_clientdata(client);
560 long val = simple_strtol(buf, NULL, 10); 561 long val = simple_strtol(buf, NULL, 10);
561 562
562 down(&data->update_lock); 563 mutex_lock(&data->update_lock);
563 data->in_min[nr] = INS_TO_REG(nr, val); 564 data->in_min[nr] = INS_TO_REG(nr, val);
564 lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]); 565 lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]);
565 up(&data->update_lock); 566 mutex_unlock(&data->update_lock);
566 return count; 567 return count;
567} 568}
568static ssize_t show_in_max(struct device *dev, char *buf, int nr) 569static ssize_t show_in_max(struct device *dev, char *buf, int nr)
@@ -577,10 +578,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
577 struct lm85_data *data = i2c_get_clientdata(client); 578 struct lm85_data *data = i2c_get_clientdata(client);
578 long val = simple_strtol(buf, NULL, 10); 579 long val = simple_strtol(buf, NULL, 10);
579 580
580 down(&data->update_lock); 581 mutex_lock(&data->update_lock);
581 data->in_max[nr] = INS_TO_REG(nr, val); 582 data->in_max[nr] = INS_TO_REG(nr, val);
582 lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]); 583 lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]);
583 up(&data->update_lock); 584 mutex_unlock(&data->update_lock);
584 return count; 585 return count;
585} 586}
586#define show_in_reg(offset) \ 587#define show_in_reg(offset) \
@@ -640,10 +641,10 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
640 struct lm85_data *data = i2c_get_clientdata(client); 641 struct lm85_data *data = i2c_get_clientdata(client);
641 long val = simple_strtol(buf, NULL, 10); 642 long val = simple_strtol(buf, NULL, 10);
642 643
643 down(&data->update_lock); 644 mutex_lock(&data->update_lock);
644 data->temp_min[nr] = TEMP_TO_REG(val); 645 data->temp_min[nr] = TEMP_TO_REG(val);
645 lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); 646 lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]);
646 up(&data->update_lock); 647 mutex_unlock(&data->update_lock);
647 return count; 648 return count;
648} 649}
649static ssize_t show_temp_max(struct device *dev, char *buf, int nr) 650static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
@@ -658,10 +659,10 @@ static ssize_t set_temp_max(struct device *dev, const char *buf,
658 struct lm85_data *data = i2c_get_clientdata(client); 659 struct lm85_data *data = i2c_get_clientdata(client);
659 long val = simple_strtol(buf, NULL, 10); 660 long val = simple_strtol(buf, NULL, 10);
660 661
661 down(&data->update_lock); 662 mutex_lock(&data->update_lock);
662 data->temp_max[nr] = TEMP_TO_REG(val); 663 data->temp_max[nr] = TEMP_TO_REG(val);
663 lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); 664 lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]);
664 up(&data->update_lock); 665 mutex_unlock(&data->update_lock);
665 return count; 666 return count;
666} 667}
667#define show_temp_reg(offset) \ 668#define show_temp_reg(offset) \
@@ -713,12 +714,12 @@ static ssize_t set_pwm_auto_channels(struct device *dev, const char *buf,
713 struct lm85_data *data = i2c_get_clientdata(client); 714 struct lm85_data *data = i2c_get_clientdata(client);
714 long val = simple_strtol(buf, NULL, 10); 715 long val = simple_strtol(buf, NULL, 10);
715 716
716 down(&data->update_lock); 717 mutex_lock(&data->update_lock);
717 data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) 718 data->autofan[nr].config = (data->autofan[nr].config & (~0xe0))
718 | ZONE_TO_REG(val) ; 719 | ZONE_TO_REG(val) ;
719 lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), 720 lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr),
720 data->autofan[nr].config); 721 data->autofan[nr].config);
721 up(&data->update_lock); 722 mutex_unlock(&data->update_lock);
722 return count; 723 return count;
723} 724}
724static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr) 725static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr)
@@ -733,11 +734,11 @@ static ssize_t set_pwm_auto_pwm_min(struct device *dev, const char *buf,
733 struct lm85_data *data = i2c_get_clientdata(client); 734 struct lm85_data *data = i2c_get_clientdata(client);
734 long val = simple_strtol(buf, NULL, 10); 735 long val = simple_strtol(buf, NULL, 10);
735 736
736 down(&data->update_lock); 737 mutex_lock(&data->update_lock);
737 data->autofan[nr].min_pwm = PWM_TO_REG(val); 738 data->autofan[nr].min_pwm = PWM_TO_REG(val);
738 lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr), 739 lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr),
739 data->autofan[nr].min_pwm); 740 data->autofan[nr].min_pwm);
740 up(&data->update_lock); 741 mutex_unlock(&data->update_lock);
741 return count; 742 return count;
742} 743}
743static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr) 744static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr)
@@ -752,7 +753,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf,
752 struct lm85_data *data = i2c_get_clientdata(client); 753 struct lm85_data *data = i2c_get_clientdata(client);
753 long val = simple_strtol(buf, NULL, 10); 754 long val = simple_strtol(buf, NULL, 10);
754 755
755 down(&data->update_lock); 756 mutex_lock(&data->update_lock);
756 data->autofan[nr].min_off = val; 757 data->autofan[nr].min_off = val;
757 lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] 758 lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0]
758 | data->syncpwm3 759 | data->syncpwm3
@@ -760,7 +761,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf,
760 | (data->autofan[1].min_off ? 0x40 : 0) 761 | (data->autofan[1].min_off ? 0x40 : 0)
761 | (data->autofan[2].min_off ? 0x80 : 0) 762 | (data->autofan[2].min_off ? 0x80 : 0)
762 ); 763 );
763 up(&data->update_lock); 764 mutex_unlock(&data->update_lock);
764 return count; 765 return count;
765} 766}
766static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr) 767static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr)
@@ -775,13 +776,13 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev, const char *buf,
775 struct lm85_data *data = i2c_get_clientdata(client); 776 struct lm85_data *data = i2c_get_clientdata(client);
776 long val = simple_strtol(buf, NULL, 10); 777 long val = simple_strtol(buf, NULL, 10);
777 778
778 down(&data->update_lock); 779 mutex_lock(&data->update_lock);
779 data->autofan[nr].freq = FREQ_TO_REG(val); 780 data->autofan[nr].freq = FREQ_TO_REG(val);
780 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), 781 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
781 (data->zone[nr].range << 4) 782 (data->zone[nr].range << 4)
782 | data->autofan[nr].freq 783 | data->autofan[nr].freq
783 ); 784 );
784 up(&data->update_lock); 785 mutex_unlock(&data->update_lock);
785 return count; 786 return count;
786} 787}
787#define pwm_auto(offset) \ 788#define pwm_auto(offset) \
@@ -857,7 +858,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf,
857 int min; 858 int min;
858 long val = simple_strtol(buf, NULL, 10); 859 long val = simple_strtol(buf, NULL, 10);
859 860
860 down(&data->update_lock); 861 mutex_lock(&data->update_lock);
861 min = TEMP_FROM_REG(data->zone[nr].limit); 862 min = TEMP_FROM_REG(data->zone[nr].limit);
862 data->zone[nr].off_desired = TEMP_TO_REG(val); 863 data->zone[nr].off_desired = TEMP_TO_REG(val);
863 data->zone[nr].hyst = HYST_TO_REG(min - val); 864 data->zone[nr].hyst = HYST_TO_REG(min - val);
@@ -871,7 +872,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf,
871 (data->zone[2].hyst << 4) 872 (data->zone[2].hyst << 4)
872 ); 873 );
873 } 874 }
874 up(&data->update_lock); 875 mutex_unlock(&data->update_lock);
875 return count; 876 return count;
876} 877}
877static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr) 878static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr)
@@ -886,7 +887,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf,
886 struct lm85_data *data = i2c_get_clientdata(client); 887 struct lm85_data *data = i2c_get_clientdata(client);
887 long val = simple_strtol(buf, NULL, 10); 888 long val = simple_strtol(buf, NULL, 10);
888 889
889 down(&data->update_lock); 890 mutex_lock(&data->update_lock);
890 data->zone[nr].limit = TEMP_TO_REG(val); 891 data->zone[nr].limit = TEMP_TO_REG(val);
891 lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr), 892 lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr),
892 data->zone[nr].limit); 893 data->zone[nr].limit);
@@ -913,7 +914,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf,
913 (data->zone[2].hyst << 4) 914 (data->zone[2].hyst << 4)
914 ); 915 );
915 } 916 }
916 up(&data->update_lock); 917 mutex_unlock(&data->update_lock);
917 return count; 918 return count;
918} 919}
919static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr) 920static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr)
@@ -930,7 +931,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf,
930 int min; 931 int min;
931 long val = simple_strtol(buf, NULL, 10); 932 long val = simple_strtol(buf, NULL, 10);
932 933
933 down(&data->update_lock); 934 mutex_lock(&data->update_lock);
934 min = TEMP_FROM_REG(data->zone[nr].limit); 935 min = TEMP_FROM_REG(data->zone[nr].limit);
935 data->zone[nr].max_desired = TEMP_TO_REG(val); 936 data->zone[nr].max_desired = TEMP_TO_REG(val);
936 data->zone[nr].range = RANGE_TO_REG( 937 data->zone[nr].range = RANGE_TO_REG(
@@ -938,7 +939,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf,
938 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), 939 lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
939 ((data->zone[nr].range & 0x0f) << 4) 940 ((data->zone[nr].range & 0x0f) << 4)
940 | (data->autofan[nr].freq & 0x07)); 941 | (data->autofan[nr].freq & 0x07));
941 up(&data->update_lock); 942 mutex_unlock(&data->update_lock);
942 return count; 943 return count;
943} 944}
944static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr) 945static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr)
@@ -953,11 +954,11 @@ static ssize_t set_temp_auto_temp_crit(struct device *dev, const char *buf,
953 struct lm85_data *data = i2c_get_clientdata(client); 954 struct lm85_data *data = i2c_get_clientdata(client);
954 long val = simple_strtol(buf, NULL, 10); 955 long val = simple_strtol(buf, NULL, 10);
955 956
956 down(&data->update_lock); 957 mutex_lock(&data->update_lock);
957 data->zone[nr].critical = TEMP_TO_REG(val); 958 data->zone[nr].critical = TEMP_TO_REG(val);
958 lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr), 959 lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr),
959 data->zone[nr].critical); 960 data->zone[nr].critical);
960 up(&data->update_lock); 961 mutex_unlock(&data->update_lock);
961 return count; 962 return count;
962} 963}
963#define temp_auto(offset) \ 964#define temp_auto(offset) \
@@ -1149,7 +1150,7 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
1149 /* Fill in the remaining client fields */ 1150 /* Fill in the remaining client fields */
1150 data->type = kind; 1151 data->type = kind;
1151 data->valid = 0; 1152 data->valid = 0;
1152 init_MUTEX(&data->update_lock); 1153 mutex_init(&data->update_lock);
1153 1154
1154 /* Tell the I2C layer a new client has arrived */ 1155 /* Tell the I2C layer a new client has arrived */
1155 if ((err = i2c_attach_client(new_client))) 1156 if ((err = i2c_attach_client(new_client)))
@@ -1368,7 +1369,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1368 struct lm85_data *data = i2c_get_clientdata(client); 1369 struct lm85_data *data = i2c_get_clientdata(client);
1369 int i; 1370 int i;
1370 1371
1371 down(&data->update_lock); 1372 mutex_lock(&data->update_lock);
1372 1373
1373 if ( !data->valid || 1374 if ( !data->valid ||
1374 time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) { 1375 time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) {
@@ -1571,7 +1572,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1571 1572
1572 data->valid = 1; 1573 data->valid = 1;
1573 1574
1574 up(&data->update_lock); 1575 mutex_unlock(&data->update_lock);
1575 1576
1576 return data; 1577 return data;
1577} 1578}