aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83l785ts.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/w83l785ts.c')
-rw-r--r--drivers/hwmon/w83l785ts.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index f66c0cfdeda7..3f2bac125fb1 100644
--- a/drivers/hwmon/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
@@ -39,6 +39,7 @@
39#include <linux/hwmon.h> 39#include <linux/hwmon.h>
40#include <linux/hwmon-sysfs.h> 40#include <linux/hwmon-sysfs.h>
41#include <linux/err.h> 41#include <linux/err.h>
42#include <linux/mutex.h>
42 43
43/* How many retries on register read error */ 44/* How many retries on register read error */
44#define MAX_RETRIES 5 45#define MAX_RETRIES 5
@@ -107,7 +108,7 @@ static struct i2c_driver w83l785ts_driver = {
107struct w83l785ts_data { 108struct w83l785ts_data {
108 struct i2c_client client; 109 struct i2c_client client;
109 struct class_device *class_dev; 110 struct class_device *class_dev;
110 struct semaphore update_lock; 111 struct mutex update_lock;
111 char valid; /* zero until following fields are valid */ 112 char valid; /* zero until following fields are valid */
112 unsigned long last_updated; /* in jiffies */ 113 unsigned long last_updated; /* in jiffies */
113 114
@@ -221,7 +222,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
221 /* We can fill in the remaining client fields. */ 222 /* We can fill in the remaining client fields. */
222 strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE); 223 strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE);
223 data->valid = 0; 224 data->valid = 0;
224 init_MUTEX(&data->update_lock); 225 mutex_init(&data->update_lock);
225 226
226 /* Default values in case the first read fails (unlikely). */ 227 /* Default values in case the first read fails (unlikely). */
227 data->temp[1] = data->temp[0] = 0; 228 data->temp[1] = data->temp[0] = 0;
@@ -299,7 +300,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev)
299 struct i2c_client *client = to_i2c_client(dev); 300 struct i2c_client *client = to_i2c_client(dev);
300 struct w83l785ts_data *data = i2c_get_clientdata(client); 301 struct w83l785ts_data *data = i2c_get_clientdata(client);
301 302
302 down(&data->update_lock); 303 mutex_lock(&data->update_lock);
303 304
304 if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { 305 if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) {
305 dev_dbg(&client->dev, "Updating w83l785ts data.\n"); 306 dev_dbg(&client->dev, "Updating w83l785ts data.\n");
@@ -312,7 +313,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev)
312 data->valid = 1; 313 data->valid = 1;
313 } 314 }
314 315
315 up(&data->update_lock); 316 mutex_unlock(&data->update_lock);
316 317
317 return data; 318 return data;
318} 319}