aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm83.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm83.c')
-rw-r--r--drivers/hwmon/lm83.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c
index a49008b444c8..d74b2c20c719 100644
--- a/drivers/hwmon/lm83.c
+++ b/drivers/hwmon/lm83.c
@@ -32,8 +32,9 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/jiffies.h> 33#include <linux/jiffies.h>
34#include <linux/i2c.h> 34#include <linux/i2c.h>
35#include <linux/i2c-sensor.h>
36#include <linux/hwmon-sysfs.h> 35#include <linux/hwmon-sysfs.h>
36#include <linux/hwmon.h>
37#include <linux/err.h>
37 38
38/* 39/*
39 * Addresses to scan 40 * Addresses to scan
@@ -45,13 +46,12 @@ static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
45 0x29, 0x2a, 0x2b, 46 0x29, 0x2a, 0x2b,
46 0x4c, 0x4d, 0x4e, 47 0x4c, 0x4d, 0x4e,
47 I2C_CLIENT_END }; 48 I2C_CLIENT_END };
48static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
49 49
50/* 50/*
51 * Insmod parameters 51 * Insmod parameters
52 */ 52 */
53 53
54SENSORS_INSMOD_1(lm83); 54I2C_CLIENT_INSMOD_1(lm83);
55 55
56/* 56/*
57 * The LM83 registers 57 * The LM83 registers
@@ -138,6 +138,7 @@ static struct i2c_driver lm83_driver = {
138 138
139struct lm83_data { 139struct lm83_data {
140 struct i2c_client client; 140 struct i2c_client client;
141 struct class_device *class_dev;
141 struct semaphore update_lock; 142 struct semaphore update_lock;
142 char valid; /* zero until following fields are valid */ 143 char valid; /* zero until following fields are valid */
143 unsigned long last_updated; /* in jiffies */ 144 unsigned long last_updated; /* in jiffies */
@@ -212,7 +213,7 @@ static int lm83_attach_adapter(struct i2c_adapter *adapter)
212{ 213{
213 if (!(adapter->class & I2C_CLASS_HWMON)) 214 if (!(adapter->class & I2C_CLASS_HWMON))
214 return 0; 215 return 0;
215 return i2c_detect(adapter, &addr_data, lm83_detect); 216 return i2c_probe(adapter, &addr_data, lm83_detect);
216} 217}
217 218
218/* 219/*
@@ -312,6 +313,12 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
312 */ 313 */
313 314
314 /* Register sysfs hooks */ 315 /* Register sysfs hooks */
316 data->class_dev = hwmon_device_register(&new_client->dev);
317 if (IS_ERR(data->class_dev)) {
318 err = PTR_ERR(data->class_dev);
319 goto exit_detach;
320 }
321
315 device_create_file(&new_client->dev, 322 device_create_file(&new_client->dev,
316 &sensor_dev_attr_temp1_input.dev_attr); 323 &sensor_dev_attr_temp1_input.dev_attr);
317 device_create_file(&new_client->dev, 324 device_create_file(&new_client->dev,
@@ -340,6 +347,8 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
340 347
341 return 0; 348 return 0;
342 349
350exit_detach:
351 i2c_detach_client(new_client);
343exit_free: 352exit_free:
344 kfree(data); 353 kfree(data);
345exit: 354exit:
@@ -348,15 +357,15 @@ exit:
348 357
349static int lm83_detach_client(struct i2c_client *client) 358static int lm83_detach_client(struct i2c_client *client)
350{ 359{
360 struct lm83_data *data = i2c_get_clientdata(client);
351 int err; 361 int err;
352 362
353 if ((err = i2c_detach_client(client))) { 363 hwmon_device_unregister(data->class_dev);
354 dev_err(&client->dev, 364
355 "Client deregistration failed, client not detached.\n"); 365 if ((err = i2c_detach_client(client)))
356 return err; 366 return err;
357 }
358 367
359 kfree(i2c_get_clientdata(client)); 368 kfree(data);
360 return 0; 369 return 0;
361} 370}
362 371