aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm63.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/lm63.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/lm63.c')
-rw-r--r--drivers/hwmon/lm63.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index 6b1aa7ef552e..071f0fc6adec 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -45,6 +45,7 @@
45#include <linux/hwmon-sysfs.h> 45#include <linux/hwmon-sysfs.h>
46#include <linux/hwmon.h> 46#include <linux/hwmon.h>
47#include <linux/err.h> 47#include <linux/err.h>
48#include <linux/mutex.h>
48 49
49/* 50/*
50 * Addresses to scan 51 * Addresses to scan
@@ -153,7 +154,7 @@ static struct i2c_driver lm63_driver = {
153struct lm63_data { 154struct lm63_data {
154 struct i2c_client client; 155 struct i2c_client client;
155 struct class_device *class_dev; 156 struct class_device *class_dev;
156 struct semaphore update_lock; 157 struct mutex update_lock;
157 char valid; /* zero until following fields are valid */ 158 char valid; /* zero until following fields are valid */
158 unsigned long last_updated; /* in jiffies */ 159 unsigned long last_updated; /* in jiffies */
159 160
@@ -192,13 +193,13 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *dummy,
192 struct lm63_data *data = i2c_get_clientdata(client); 193 struct lm63_data *data = i2c_get_clientdata(client);
193 unsigned long val = simple_strtoul(buf, NULL, 10); 194 unsigned long val = simple_strtoul(buf, NULL, 10);
194 195
195 down(&data->update_lock); 196 mutex_lock(&data->update_lock);
196 data->fan[1] = FAN_TO_REG(val); 197 data->fan[1] = FAN_TO_REG(val);
197 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, 198 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB,
198 data->fan[1] & 0xFF); 199 data->fan[1] & 0xFF);
199 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, 200 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB,
200 data->fan[1] >> 8); 201 data->fan[1] >> 8);
201 up(&data->update_lock); 202 mutex_unlock(&data->update_lock);
202 return count; 203 return count;
203} 204}
204 205
@@ -222,12 +223,12 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy,
222 return -EPERM; 223 return -EPERM;
223 224
224 val = simple_strtoul(buf, NULL, 10); 225 val = simple_strtoul(buf, NULL, 10);
225 down(&data->update_lock); 226 mutex_lock(&data->update_lock);
226 data->pwm1_value = val <= 0 ? 0 : 227 data->pwm1_value = val <= 0 ? 0 :
227 val >= 255 ? 2 * data->pwm1_freq : 228 val >= 255 ? 2 * data->pwm1_freq :
228 (val * data->pwm1_freq * 2 + 127) / 255; 229 (val * data->pwm1_freq * 2 + 127) / 255;
229 i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value); 230 i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value);
230 up(&data->update_lock); 231 mutex_unlock(&data->update_lock);
231 return count; 232 return count;
232} 233}
233 234
@@ -253,10 +254,10 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy,
253 struct lm63_data *data = i2c_get_clientdata(client); 254 struct lm63_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->temp8[1] = TEMP8_TO_REG(val); 258 data->temp8[1] = TEMP8_TO_REG(val);
258 i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); 259 i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]);
259 up(&data->update_lock); 260 mutex_unlock(&data->update_lock);
260 return count; 261 return count;
261} 262}
262 263
@@ -284,13 +285,13 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
284 long val = simple_strtol(buf, NULL, 10); 285 long val = simple_strtol(buf, NULL, 10);
285 int nr = attr->index; 286 int nr = attr->index;
286 287
287 down(&data->update_lock); 288 mutex_lock(&data->update_lock);
288 data->temp11[nr] = TEMP11_TO_REG(val); 289 data->temp11[nr] = TEMP11_TO_REG(val);
289 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], 290 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2],
290 data->temp11[nr] >> 8); 291 data->temp11[nr] >> 8);
291 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], 292 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],
292 data->temp11[nr] & 0xff); 293 data->temp11[nr] & 0xff);
293 up(&data->update_lock); 294 mutex_unlock(&data->update_lock);
294 return count; 295 return count;
295} 296}
296 297
@@ -314,11 +315,11 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *
314 long val = simple_strtol(buf, NULL, 10); 315 long val = simple_strtol(buf, NULL, 10);
315 long hyst; 316 long hyst;
316 317
317 down(&data->update_lock); 318 mutex_lock(&data->update_lock);
318 hyst = TEMP8_FROM_REG(data->temp8[2]) - val; 319 hyst = TEMP8_FROM_REG(data->temp8[2]) - val;
319 i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, 320 i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST,
320 HYST_TO_REG(hyst)); 321 HYST_TO_REG(hyst));
321 up(&data->update_lock); 322 mutex_unlock(&data->update_lock);
322 return count; 323 return count;
323} 324}
324 325
@@ -427,7 +428,7 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
427 428
428 strlcpy(new_client->name, "lm63", I2C_NAME_SIZE); 429 strlcpy(new_client->name, "lm63", I2C_NAME_SIZE);
429 data->valid = 0; 430 data->valid = 0;
430 init_MUTEX(&data->update_lock); 431 mutex_init(&data->update_lock);
431 432
432 /* Tell the I2C layer a new client has arrived */ 433 /* Tell the I2C layer a new client has arrived */
433 if ((err = i2c_attach_client(new_client))) 434 if ((err = i2c_attach_client(new_client)))
@@ -530,7 +531,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
530 struct i2c_client *client = to_i2c_client(dev); 531 struct i2c_client *client = to_i2c_client(dev);
531 struct lm63_data *data = i2c_get_clientdata(client); 532 struct lm63_data *data = i2c_get_clientdata(client);
532 533
533 down(&data->update_lock); 534 mutex_lock(&data->update_lock);
534 535
535 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 536 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
536 if (data->config & 0x04) { /* tachometer enabled */ 537 if (data->config & 0x04) { /* tachometer enabled */
@@ -582,7 +583,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
582 data->valid = 1; 583 data->valid = 1;
583 } 584 }
584 585
585 up(&data->update_lock); 586 mutex_unlock(&data->update_lock);
586 587
587 return data; 588 return data;
588} 589}