aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm92.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm92.c')
-rw-r--r--drivers/hwmon/lm92.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index b0c4cb730a7e..197f77226dc4 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -46,6 +46,7 @@
46#include <linux/i2c.h> 46#include <linux/i2c.h>
47#include <linux/hwmon.h> 47#include <linux/hwmon.h>
48#include <linux/err.h> 48#include <linux/err.h>
49#include <linux/mutex.h>
49 50
50/* The LM92 and MAX6635 have 2 two-state pins for address selection, 51/* The LM92 and MAX6635 have 2 two-state pins for address selection,
51 resulting in 4 possible addresses. */ 52 resulting in 4 possible addresses. */
@@ -96,7 +97,7 @@ static struct i2c_driver lm92_driver;
96struct lm92_data { 97struct lm92_data {
97 struct i2c_client client; 98 struct i2c_client client;
98 struct class_device *class_dev; 99 struct class_device *class_dev;
99 struct semaphore update_lock; 100 struct mutex update_lock;
100 char valid; /* zero until following fields are valid */ 101 char valid; /* zero until following fields are valid */
101 unsigned long last_updated; /* in jiffies */ 102 unsigned long last_updated; /* in jiffies */
102 103
@@ -114,7 +115,7 @@ static struct lm92_data *lm92_update_device(struct device *dev)
114 struct i2c_client *client = to_i2c_client(dev); 115 struct i2c_client *client = to_i2c_client(dev);
115 struct lm92_data *data = i2c_get_clientdata(client); 116 struct lm92_data *data = i2c_get_clientdata(client);
116 117
117 down(&data->update_lock); 118 mutex_lock(&data->update_lock);
118 119
119 if (time_after(jiffies, data->last_updated + HZ) 120 if (time_after(jiffies, data->last_updated + HZ)
120 || !data->valid) { 121 || !data->valid) {
@@ -134,7 +135,7 @@ static struct lm92_data *lm92_update_device(struct device *dev)
134 data->valid = 1; 135 data->valid = 1;
135 } 136 }
136 137
137 up(&data->update_lock); 138 mutex_unlock(&data->update_lock);
138 139
139 return data; 140 return data;
140} 141}
@@ -158,10 +159,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
158 struct lm92_data *data = i2c_get_clientdata(client); \ 159 struct lm92_data *data = i2c_get_clientdata(client); \
159 long val = simple_strtol(buf, NULL, 10); \ 160 long val = simple_strtol(buf, NULL, 10); \
160 \ 161 \
161 down(&data->update_lock); \ 162 mutex_lock(&data->update_lock); \
162 data->value = TEMP_TO_REG(val); \ 163 data->value = TEMP_TO_REG(val); \
163 i2c_smbus_write_word_data(client, reg, swab16(data->value)); \ 164 i2c_smbus_write_word_data(client, reg, swab16(data->value)); \
164 up(&data->update_lock); \ 165 mutex_unlock(&data->update_lock); \
165 return count; \ 166 return count; \
166} 167}
167set_temp(temp1_crit, LM92_REG_TEMP_CRIT); 168set_temp(temp1_crit, LM92_REG_TEMP_CRIT);
@@ -194,11 +195,11 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute *
194 struct lm92_data *data = i2c_get_clientdata(client); 195 struct lm92_data *data = i2c_get_clientdata(client);
195 long val = simple_strtol(buf, NULL, 10); 196 long val = simple_strtol(buf, NULL, 10);
196 197
197 down(&data->update_lock); 198 mutex_lock(&data->update_lock);
198 data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; 199 data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val;
199 i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST, 200 i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST,
200 swab16(TEMP_TO_REG(data->temp1_hyst))); 201 swab16(TEMP_TO_REG(data->temp1_hyst)));
201 up(&data->update_lock); 202 mutex_unlock(&data->update_lock);
202 return count; 203 return count;
203} 204}
204 205
@@ -348,7 +349,7 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
348 /* Fill in the remaining client fields */ 349 /* Fill in the remaining client fields */
349 strlcpy(new_client->name, name, I2C_NAME_SIZE); 350 strlcpy(new_client->name, name, I2C_NAME_SIZE);
350 data->valid = 0; 351 data->valid = 0;
351 init_MUTEX(&data->update_lock); 352 mutex_init(&data->update_lock);
352 353
353 /* Tell the i2c subsystem a new client has arrived */ 354 /* Tell the i2c subsystem a new client has arrived */
354 if ((err = i2c_attach_client(new_client))) 355 if ((err = i2c_attach_client(new_client)))