diff options
author | Ingo Molnar <mingo@elte.hu> | 2006-01-18 17:19:26 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-23 17:21:52 -0500 |
commit | 9a61bf6300533d3b64d7ff29adfec00e596de67d (patch) | |
tree | cadce1ae78b51a1dc4c4414699cb590e8c8625e1 /drivers/hwmon/vt8231.c | |
parent | 3fb9a65529615944138d527b70174840c95c637a (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/vt8231.c')
-rw-r--r-- | drivers/hwmon/vt8231.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index 271e9cb9532c..686f3deb3093 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/hwmon-sysfs.h> | 35 | #include <linux/hwmon-sysfs.h> |
36 | #include <linux/hwmon-vid.h> | 36 | #include <linux/hwmon-vid.h> |
37 | #include <linux/err.h> | 37 | #include <linux/err.h> |
38 | #include <linux/mutex.h> | ||
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
39 | 40 | ||
40 | static int force_addr; | 41 | static int force_addr; |
@@ -148,7 +149,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
148 | 149 | ||
149 | struct vt8231_data { | 150 | struct vt8231_data { |
150 | struct i2c_client client; | 151 | struct i2c_client client; |
151 | struct semaphore update_lock; | 152 | struct mutex update_lock; |
152 | struct class_device *class_dev; | 153 | struct class_device *class_dev; |
153 | char valid; /* !=0 if following fields are valid */ | 154 | char valid; /* !=0 if following fields are valid */ |
154 | unsigned long last_updated; /* In jiffies */ | 155 | unsigned long last_updated; /* In jiffies */ |
@@ -223,10 +224,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
223 | struct vt8231_data *data = i2c_get_clientdata(client); | 224 | struct vt8231_data *data = i2c_get_clientdata(client); |
224 | unsigned long val = simple_strtoul(buf, NULL, 10); | 225 | unsigned long val = simple_strtoul(buf, NULL, 10); |
225 | 226 | ||
226 | down(&data->update_lock); | 227 | mutex_lock(&data->update_lock); |
227 | data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); | 228 | data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); |
228 | vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]); | 229 | vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]); |
229 | up(&data->update_lock); | 230 | mutex_unlock(&data->update_lock); |
230 | return count; | 231 | return count; |
231 | } | 232 | } |
232 | 233 | ||
@@ -239,10 +240,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
239 | struct vt8231_data *data = i2c_get_clientdata(client); | 240 | struct vt8231_data *data = i2c_get_clientdata(client); |
240 | unsigned long val = simple_strtoul(buf, NULL, 10); | 241 | unsigned long val = simple_strtoul(buf, NULL, 10); |
241 | 242 | ||
242 | down(&data->update_lock); | 243 | mutex_lock(&data->update_lock); |
243 | data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); | 244 | data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); |
244 | vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]); | 245 | vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]); |
245 | up(&data->update_lock); | 246 | mutex_unlock(&data->update_lock); |
246 | return count; | 247 | return count; |
247 | } | 248 | } |
248 | 249 | ||
@@ -281,11 +282,11 @@ static ssize_t set_in5_min(struct device *dev, struct device_attribute *attr, | |||
281 | struct vt8231_data *data = i2c_get_clientdata(client); | 282 | struct vt8231_data *data = i2c_get_clientdata(client); |
282 | unsigned long val = simple_strtoul(buf, NULL, 10); | 283 | unsigned long val = simple_strtoul(buf, NULL, 10); |
283 | 284 | ||
284 | down(&data->update_lock); | 285 | mutex_lock(&data->update_lock); |
285 | data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, | 286 | data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, |
286 | 0, 255); | 287 | 0, 255); |
287 | vt8231_write_value(client, regvoltmin[5], data->in_min[5]); | 288 | vt8231_write_value(client, regvoltmin[5], data->in_min[5]); |
288 | up(&data->update_lock); | 289 | mutex_unlock(&data->update_lock); |
289 | return count; | 290 | return count; |
290 | } | 291 | } |
291 | 292 | ||
@@ -296,11 +297,11 @@ static ssize_t set_in5_max(struct device *dev, struct device_attribute *attr, | |||
296 | struct vt8231_data *data = i2c_get_clientdata(client); | 297 | struct vt8231_data *data = i2c_get_clientdata(client); |
297 | unsigned long val = simple_strtoul(buf, NULL, 10); | 298 | unsigned long val = simple_strtoul(buf, NULL, 10); |
298 | 299 | ||
299 | down(&data->update_lock); | 300 | mutex_lock(&data->update_lock); |
300 | data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, | 301 | data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, |
301 | 0, 255); | 302 | 0, 255); |
302 | vt8231_write_value(client, regvoltmax[5], data->in_max[5]); | 303 | vt8231_write_value(client, regvoltmax[5], data->in_max[5]); |
303 | up(&data->update_lock); | 304 | mutex_unlock(&data->update_lock); |
304 | return count; | 305 | return count; |
305 | } | 306 | } |
306 | 307 | ||
@@ -351,10 +352,10 @@ static ssize_t set_temp0_max(struct device *dev, struct device_attribute *attr, | |||
351 | struct vt8231_data *data = i2c_get_clientdata(client); | 352 | struct vt8231_data *data = i2c_get_clientdata(client); |
352 | int val = simple_strtol(buf, NULL, 10); | 353 | int val = simple_strtol(buf, NULL, 10); |
353 | 354 | ||
354 | down(&data->update_lock); | 355 | mutex_lock(&data->update_lock); |
355 | data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); | 356 | data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); |
356 | vt8231_write_value(client, regtempmax[0], data->temp_max[0]); | 357 | vt8231_write_value(client, regtempmax[0], data->temp_max[0]); |
357 | up(&data->update_lock); | 358 | mutex_unlock(&data->update_lock); |
358 | return count; | 359 | return count; |
359 | } | 360 | } |
360 | static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, | 361 | static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, |
@@ -364,10 +365,10 @@ static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, | |||
364 | struct vt8231_data *data = i2c_get_clientdata(client); | 365 | struct vt8231_data *data = i2c_get_clientdata(client); |
365 | int val = simple_strtol(buf, NULL, 10); | 366 | int val = simple_strtol(buf, NULL, 10); |
366 | 367 | ||
367 | down(&data->update_lock); | 368 | mutex_lock(&data->update_lock); |
368 | data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); | 369 | data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); |
369 | vt8231_write_value(client, regtempmin[0], data->temp_min[0]); | 370 | vt8231_write_value(client, regtempmin[0], data->temp_min[0]); |
370 | up(&data->update_lock); | 371 | mutex_unlock(&data->update_lock); |
371 | return count; | 372 | return count; |
372 | } | 373 | } |
373 | 374 | ||
@@ -407,10 +408,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
407 | struct vt8231_data *data = i2c_get_clientdata(client); | 408 | struct vt8231_data *data = i2c_get_clientdata(client); |
408 | int val = simple_strtol(buf, NULL, 10); | 409 | int val = simple_strtol(buf, NULL, 10); |
409 | 410 | ||
410 | down(&data->update_lock); | 411 | mutex_lock(&data->update_lock); |
411 | data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); | 412 | data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); |
412 | vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]); | 413 | vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]); |
413 | up(&data->update_lock); | 414 | mutex_unlock(&data->update_lock); |
414 | return count; | 415 | return count; |
415 | } | 416 | } |
416 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | 417 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
@@ -422,10 +423,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
422 | struct vt8231_data *data = i2c_get_clientdata(client); | 423 | struct vt8231_data *data = i2c_get_clientdata(client); |
423 | int val = simple_strtol(buf, NULL, 10); | 424 | int val = simple_strtol(buf, NULL, 10); |
424 | 425 | ||
425 | down(&data->update_lock); | 426 | mutex_lock(&data->update_lock); |
426 | data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); | 427 | data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); |
427 | vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]); | 428 | vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]); |
428 | up(&data->update_lock); | 429 | mutex_unlock(&data->update_lock); |
429 | return count; | 430 | return count; |
430 | } | 431 | } |
431 | 432 | ||
@@ -520,10 +521,10 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
520 | struct vt8231_data *data = i2c_get_clientdata(client); | 521 | struct vt8231_data *data = i2c_get_clientdata(client); |
521 | int val = simple_strtoul(buf, NULL, 10); | 522 | int val = simple_strtoul(buf, NULL, 10); |
522 | 523 | ||
523 | down(&data->update_lock); | 524 | mutex_lock(&data->update_lock); |
524 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 525 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
525 | vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); | 526 | vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); |
526 | up(&data->update_lock); | 527 | mutex_unlock(&data->update_lock); |
527 | return count; | 528 | return count; |
528 | } | 529 | } |
529 | 530 | ||
@@ -539,7 +540,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
539 | long min = FAN_FROM_REG(data->fan_min[nr], | 540 | long min = FAN_FROM_REG(data->fan_min[nr], |
540 | DIV_FROM_REG(data->fan_div[nr])); | 541 | DIV_FROM_REG(data->fan_div[nr])); |
541 | 542 | ||
542 | down(&data->update_lock); | 543 | mutex_lock(&data->update_lock); |
543 | switch (val) { | 544 | switch (val) { |
544 | case 1: data->fan_div[nr] = 0; break; | 545 | case 1: data->fan_div[nr] = 0; break; |
545 | case 2: data->fan_div[nr] = 1; break; | 546 | case 2: data->fan_div[nr] = 1; break; |
@@ -548,7 +549,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
548 | default: | 549 | default: |
549 | dev_err(&client->dev, "fan_div value %ld not supported." | 550 | dev_err(&client->dev, "fan_div value %ld not supported." |
550 | "Choose one of 1, 2, 4 or 8!\n", val); | 551 | "Choose one of 1, 2, 4 or 8!\n", val); |
551 | up(&data->update_lock); | 552 | mutex_unlock(&data->update_lock); |
552 | return -EINVAL; | 553 | return -EINVAL; |
553 | } | 554 | } |
554 | 555 | ||
@@ -558,7 +559,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
558 | 559 | ||
559 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); | 560 | old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); |
560 | vt8231_write_value(client, VT8231_REG_FANDIV, old); | 561 | vt8231_write_value(client, VT8231_REG_FANDIV, old); |
561 | up(&data->update_lock); | 562 | mutex_unlock(&data->update_lock); |
562 | return count; | 563 | return count; |
563 | } | 564 | } |
564 | 565 | ||
@@ -660,7 +661,7 @@ int vt8231_detect(struct i2c_adapter *adapter) | |||
660 | /* Fill in the remaining client fields and put into the global list */ | 661 | /* Fill in the remaining client fields and put into the global list */ |
661 | strlcpy(client->name, "vt8231", I2C_NAME_SIZE); | 662 | strlcpy(client->name, "vt8231", I2C_NAME_SIZE); |
662 | 663 | ||
663 | init_MUTEX(&data->update_lock); | 664 | mutex_init(&data->update_lock); |
664 | 665 | ||
665 | /* Tell the I2C layer a new client has arrived */ | 666 | /* Tell the I2C layer a new client has arrived */ |
666 | if ((err = i2c_attach_client(client))) | 667 | if ((err = i2c_attach_client(client))) |
@@ -745,7 +746,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev) | |||
745 | int i; | 746 | int i; |
746 | u16 low; | 747 | u16 low; |
747 | 748 | ||
748 | down(&data->update_lock); | 749 | mutex_lock(&data->update_lock); |
749 | 750 | ||
750 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | 751 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
751 | || !data->valid) { | 752 | || !data->valid) { |
@@ -804,7 +805,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev) | |||
804 | data->valid = 1; | 805 | data->valid = 1; |
805 | } | 806 | } |
806 | 807 | ||
807 | up(&data->update_lock); | 808 | mutex_unlock(&data->update_lock); |
808 | 809 | ||
809 | return data; | 810 | return data; |
810 | } | 811 | } |