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.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index 4469d52aba4c..133e34ab1d0a 100644
--- a/drivers/hwmon/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
@@ -36,7 +36,8 @@
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/jiffies.h> 37#include <linux/jiffies.h>
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/i2c-sensor.h> 39#include <linux/hwmon.h>
40#include <linux/err.h>
40 41
41/* How many retries on register read error */ 42/* How many retries on register read error */
42#define MAX_RETRIES 5 43#define MAX_RETRIES 5
@@ -47,13 +48,12 @@
47 */ 48 */
48 49
49static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END }; 50static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END };
50static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
51 51
52/* 52/*
53 * Insmod parameters 53 * Insmod parameters
54 */ 54 */
55 55
56SENSORS_INSMOD_1(w83l785ts); 56I2C_CLIENT_INSMOD_1(w83l785ts);
57 57
58/* 58/*
59 * The W83L785TS-S registers 59 * The W83L785TS-S registers
@@ -105,6 +105,7 @@ static struct i2c_driver w83l785ts_driver = {
105 105
106struct w83l785ts_data { 106struct w83l785ts_data {
107 struct i2c_client client; 107 struct i2c_client client;
108 struct class_device *class_dev;
108 struct semaphore update_lock; 109 struct semaphore update_lock;
109 char valid; /* zero until following fields are valid */ 110 char valid; /* zero until following fields are valid */
110 unsigned long last_updated; /* in jiffies */ 111 unsigned long last_updated; /* in jiffies */
@@ -140,7 +141,7 @@ static int w83l785ts_attach_adapter(struct i2c_adapter *adapter)
140{ 141{
141 if (!(adapter->class & I2C_CLASS_HWMON)) 142 if (!(adapter->class & I2C_CLASS_HWMON))
142 return 0; 143 return 0;
143 return i2c_detect(adapter, &addr_data, w83l785ts_detect); 144 return i2c_probe(adapter, &addr_data, w83l785ts_detect);
144} 145}
145 146
146/* 147/*
@@ -239,11 +240,19 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
239 */ 240 */
240 241
241 /* Register sysfs hooks */ 242 /* Register sysfs hooks */
243 data->class_dev = hwmon_device_register(&new_client->dev);
244 if (IS_ERR(data->class_dev)) {
245 err = PTR_ERR(data->class_dev);
246 goto exit_detach;
247 }
248
242 device_create_file(&new_client->dev, &dev_attr_temp1_input); 249 device_create_file(&new_client->dev, &dev_attr_temp1_input);
243 device_create_file(&new_client->dev, &dev_attr_temp1_max); 250 device_create_file(&new_client->dev, &dev_attr_temp1_max);
244 251
245 return 0; 252 return 0;
246 253
254exit_detach:
255 i2c_detach_client(new_client);
247exit_free: 256exit_free:
248 kfree(data); 257 kfree(data);
249exit: 258exit:
@@ -252,15 +261,15 @@ exit:
252 261
253static int w83l785ts_detach_client(struct i2c_client *client) 262static int w83l785ts_detach_client(struct i2c_client *client)
254{ 263{
264 struct w83l785ts_data *data = i2c_get_clientdata(client);
255 int err; 265 int err;
256 266
257 if ((err = i2c_detach_client(client))) { 267 hwmon_device_unregister(data->class_dev);
258 dev_err(&client->dev, "Client deregistration failed, " 268
259 "client not detached.\n"); 269 if ((err = i2c_detach_client(client)))
260 return err; 270 return err;
261 }
262 271
263 kfree(i2c_get_clientdata(client)); 272 kfree(data);
264 return 0; 273 return 0;
265} 274}
266 275