aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1021.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 18:51:32 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 18:51:32 -0500
commitb6585dedac232ca79fe978d97a95fdaa6da24f66 (patch)
tree4d2d78300bb9bcfb40cb35450f78dd3af82c78d3 /drivers/hwmon/adm1021.c
parenta3ea9b584ed2acdeae817f0dc91a5880e0828a05 (diff)
parentded2b66615613093eeb83b81499bc270de8fc499 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6: (36 commits) [PATCH] hwmon: add required idr locking [PATCH] I2C: hwmon: Rename register parameters [PATCH] I2C: Drop unneeded i2c-dev.h includes [PATCH] I2C: i2c-ixp4xx: Add hwmon class [PATCH] I2C: i2c-piix4: Add Broadcom HT-1000 support [PATCH] I2C: i2c-amd756-s4882: Improve static mutex initialization [PATCH] I2C: i2c-ali1535: Drop redundant mutex [PATCH] i2c: Cleanup isp1301_omap [PATCH] i2c: Fix i2c-ite name initialization [PATCH] i2c: Drop the i2c-frodo bus driver [PATCH] i2c: Optimize core_lists mutex usage [PATCH] w83781d: Don't reset the chip by default [PATCH] w83781d: Document the alarm and beep bits [PATCH] w83627ehf: Refactor the sysfs interface [PATCH] hwmon: Support the Pentium M VID code [PATCH] hwmon: Add support for the Winbond W83687THF [PATCH] hwmon: f71805f semaphore to mutex conversions [PATCH] hwmon: Semaphore to mutex conversions [PATCH] i2c: Semaphore to mutex conversions, part 3 [PATCH] i2c: Semaphore to mutex conversions, part 2 ...
Diffstat (limited to 'drivers/hwmon/adm1021.c')
-rw-r--r--drivers/hwmon/adm1021.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index 665612729cb9..2b6e74dd4a82 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -26,6 +26,7 @@
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/hwmon.h> 27#include <linux/hwmon.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/mutex.h>
29 30
30 31
31/* Addresses to scan */ 32/* Addresses to scan */
@@ -92,7 +93,7 @@ struct adm1021_data {
92 struct class_device *class_dev; 93 struct class_device *class_dev;
93 enum chips type; 94 enum chips type;
94 95
95 struct semaphore update_lock; 96 struct mutex update_lock;
96 char valid; /* !=0 if following fields are valid */ 97 char valid; /* !=0 if following fields are valid */
97 unsigned long last_updated; /* In jiffies */ 98 unsigned long last_updated; /* In jiffies */
98 99
@@ -162,10 +163,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
162 struct adm1021_data *data = i2c_get_clientdata(client); \ 163 struct adm1021_data *data = i2c_get_clientdata(client); \
163 int temp = simple_strtoul(buf, NULL, 10); \ 164 int temp = simple_strtoul(buf, NULL, 10); \
164 \ 165 \
165 down(&data->update_lock); \ 166 mutex_lock(&data->update_lock); \
166 data->value = TEMP_TO_REG(temp); \ 167 data->value = TEMP_TO_REG(temp); \
167 adm1021_write_value(client, reg, data->value); \ 168 adm1021_write_value(client, reg, data->value); \
168 up(&data->update_lock); \ 169 mutex_unlock(&data->update_lock); \
169 return count; \ 170 return count; \
170} 171}
171set(temp_max, ADM1021_REG_TOS_W); 172set(temp_max, ADM1021_REG_TOS_W);
@@ -275,7 +276,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
275 strlcpy(new_client->name, type_name, I2C_NAME_SIZE); 276 strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
276 data->type = kind; 277 data->type = kind;
277 data->valid = 0; 278 data->valid = 0;
278 init_MUTEX(&data->update_lock); 279 mutex_init(&data->update_lock);
279 280
280 /* Tell the I2C layer a new client has arrived */ 281 /* Tell the I2C layer a new client has arrived */
281 if ((err = i2c_attach_client(new_client))) 282 if ((err = i2c_attach_client(new_client)))
@@ -351,7 +352,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
351 struct i2c_client *client = to_i2c_client(dev); 352 struct i2c_client *client = to_i2c_client(dev);
352 struct adm1021_data *data = i2c_get_clientdata(client); 353 struct adm1021_data *data = i2c_get_clientdata(client);
353 354
354 down(&data->update_lock); 355 mutex_lock(&data->update_lock);
355 356
356 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 357 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
357 || !data->valid) { 358 || !data->valid) {
@@ -375,7 +376,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
375 data->valid = 1; 376 data->valid = 1;
376 } 377 }
377 378
378 up(&data->update_lock); 379 mutex_unlock(&data->update_lock);
379 380
380 return data; 381 return data;
381} 382}