aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/gl518sm.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/gl518sm.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/gl518sm.c')
-rw-r--r--drivers/hwmon/gl518sm.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c
index 9e685e3a3bc9..6606aabdb49d 100644
--- a/drivers/hwmon/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
@@ -43,6 +43,7 @@
43#include <linux/i2c.h> 43#include <linux/i2c.h>
44#include <linux/hwmon.h> 44#include <linux/hwmon.h>
45#include <linux/err.h> 45#include <linux/err.h>
46#include <linux/mutex.h>
46 47
47/* Addresses to scan */ 48/* Addresses to scan */
48static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; 49static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
@@ -120,7 +121,7 @@ struct gl518_data {
120 struct class_device *class_dev; 121 struct class_device *class_dev;
121 enum chips type; 122 enum chips type;
122 123
123 struct semaphore update_lock; 124 struct mutex update_lock;
124 char valid; /* !=0 if following fields are valid */ 125 char valid; /* !=0 if following fields are valid */
125 unsigned long last_updated; /* In jiffies */ 126 unsigned long last_updated; /* In jiffies */
126 127
@@ -212,10 +213,10 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c
212 struct gl518_data *data = i2c_get_clientdata(client); \ 213 struct gl518_data *data = i2c_get_clientdata(client); \
213 long val = simple_strtol(buf, NULL, 10); \ 214 long val = simple_strtol(buf, NULL, 10); \
214 \ 215 \
215 down(&data->update_lock); \ 216 mutex_lock(&data->update_lock); \
216 data->value = type##_TO_REG(val); \ 217 data->value = type##_TO_REG(val); \
217 gl518_write_value(client, reg, data->value); \ 218 gl518_write_value(client, reg, data->value); \
218 up(&data->update_lock); \ 219 mutex_unlock(&data->update_lock); \
219 return count; \ 220 return count; \
220} 221}
221 222
@@ -228,12 +229,12 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c
228 int regvalue; \ 229 int regvalue; \
229 unsigned long val = simple_strtoul(buf, NULL, 10); \ 230 unsigned long val = simple_strtoul(buf, NULL, 10); \
230 \ 231 \
231 down(&data->update_lock); \ 232 mutex_lock(&data->update_lock); \
232 regvalue = gl518_read_value(client, reg); \ 233 regvalue = gl518_read_value(client, reg); \
233 data->value = type##_TO_REG(val); \ 234 data->value = type##_TO_REG(val); \
234 regvalue = (regvalue & ~mask) | (data->value << shift); \ 235 regvalue = (regvalue & ~mask) | (data->value << shift); \
235 gl518_write_value(client, reg, regvalue); \ 236 gl518_write_value(client, reg, regvalue); \
236 up(&data->update_lock); \ 237 mutex_unlock(&data->update_lock); \
237 return count; \ 238 return count; \
238} 239}
239 240
@@ -265,7 +266,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c
265 int regvalue; 266 int regvalue;
266 unsigned long val = simple_strtoul(buf, NULL, 10); 267 unsigned long val = simple_strtoul(buf, NULL, 10);
267 268
268 down(&data->update_lock); 269 mutex_lock(&data->update_lock);
269 regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); 270 regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT);
270 data->fan_min[0] = FAN_TO_REG(val, 271 data->fan_min[0] = FAN_TO_REG(val,
271 DIV_FROM_REG(data->fan_div[0])); 272 DIV_FROM_REG(data->fan_div[0]));
@@ -280,7 +281,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c
280 data->beep_mask &= data->alarm_mask; 281 data->beep_mask &= data->alarm_mask;
281 gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); 282 gl518_write_value(client, GL518_REG_ALARM, data->beep_mask);
282 283
283 up(&data->update_lock); 284 mutex_unlock(&data->update_lock);
284 return count; 285 return count;
285} 286}
286 287
@@ -291,7 +292,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c
291 int regvalue; 292 int regvalue;
292 unsigned long val = simple_strtoul(buf, NULL, 10); 293 unsigned long val = simple_strtoul(buf, NULL, 10);
293 294
294 down(&data->update_lock); 295 mutex_lock(&data->update_lock);
295 regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT); 296 regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT);
296 data->fan_min[1] = FAN_TO_REG(val, 297 data->fan_min[1] = FAN_TO_REG(val,
297 DIV_FROM_REG(data->fan_div[1])); 298 DIV_FROM_REG(data->fan_div[1]));
@@ -306,7 +307,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c
306 data->beep_mask &= data->alarm_mask; 307 data->beep_mask &= data->alarm_mask;
307 gl518_write_value(client, GL518_REG_ALARM, data->beep_mask); 308 gl518_write_value(client, GL518_REG_ALARM, data->beep_mask);
308 309
309 up(&data->update_lock); 310 mutex_unlock(&data->update_lock);
310 return count; 311 return count;
311} 312}
312 313
@@ -407,7 +408,7 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
407 strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE); 408 strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE);
408 data->type = kind; 409 data->type = kind;
409 data->valid = 0; 410 data->valid = 0;
410 init_MUTEX(&data->update_lock); 411 mutex_init(&data->update_lock);
411 412
412 /* Tell the I2C layer a new client has arrived */ 413 /* Tell the I2C layer a new client has arrived */
413 if ((err = i2c_attach_client(new_client))) 414 if ((err = i2c_attach_client(new_client)))
@@ -525,7 +526,7 @@ static struct gl518_data *gl518_update_device(struct device *dev)
525 struct gl518_data *data = i2c_get_clientdata(client); 526 struct gl518_data *data = i2c_get_clientdata(client);
526 int val; 527 int val;
527 528
528 down(&data->update_lock); 529 mutex_lock(&data->update_lock);
529 530
530 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 531 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
531 || !data->valid) { 532 || !data->valid) {
@@ -586,7 +587,7 @@ static struct gl518_data *gl518_update_device(struct device *dev)
586 data->valid = 1; 587 data->valid = 1;
587 } 588 }
588 589
589 up(&data->update_lock); 590 mutex_unlock(&data->update_lock);
590 591
591 return data; 592 return data;
592} 593}