aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm77.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm77.c')
-rw-r--r--drivers/hwmon/lm77.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c
index b98f44952997..866eab96a6f6 100644
--- a/drivers/hwmon/lm77.c
+++ b/drivers/hwmon/lm77.c
@@ -30,15 +30,14 @@
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/jiffies.h> 31#include <linux/jiffies.h>
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/i2c-sensor.h> 33#include <linux/hwmon.h>
34 34#include <linux/err.h>
35 35
36/* Addresses to scan */ 36/* Addresses to scan */
37static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; 37static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END };
38static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
39 38
40/* Insmod parameters */ 39/* Insmod parameters */
41SENSORS_INSMOD_1(lm77); 40I2C_CLIENT_INSMOD_1(lm77);
42 41
43/* The LM77 registers */ 42/* The LM77 registers */
44#define LM77_REG_TEMP 0x00 43#define LM77_REG_TEMP 0x00
@@ -51,6 +50,7 @@ SENSORS_INSMOD_1(lm77);
51/* Each client has this additional data */ 50/* Each client has this additional data */
52struct lm77_data { 51struct lm77_data {
53 struct i2c_client client; 52 struct i2c_client client;
53 struct class_device *class_dev;
54 struct semaphore update_lock; 54 struct semaphore update_lock;
55 char valid; 55 char valid;
56 unsigned long last_updated; /* In jiffies */ 56 unsigned long last_updated; /* In jiffies */
@@ -208,10 +208,10 @@ static int lm77_attach_adapter(struct i2c_adapter *adapter)
208{ 208{
209 if (!(adapter->class & I2C_CLASS_HWMON)) 209 if (!(adapter->class & I2C_CLASS_HWMON))
210 return 0; 210 return 0;
211 return i2c_detect(adapter, &addr_data, lm77_detect); 211 return i2c_probe(adapter, &addr_data, lm77_detect);
212} 212}
213 213
214/* This function is called by i2c_detect */ 214/* This function is called by i2c_probe */
215static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) 215static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
216{ 216{
217 struct i2c_client *new_client; 217 struct i2c_client *new_client;
@@ -317,6 +317,12 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
317 lm77_init_client(new_client); 317 lm77_init_client(new_client);
318 318
319 /* Register sysfs hooks */ 319 /* Register sysfs hooks */
320 data->class_dev = hwmon_device_register(&new_client->dev);
321 if (IS_ERR(data->class_dev)) {
322 err = PTR_ERR(data->class_dev);
323 goto exit_detach;
324 }
325
320 device_create_file(&new_client->dev, &dev_attr_temp1_input); 326 device_create_file(&new_client->dev, &dev_attr_temp1_input);
321 device_create_file(&new_client->dev, &dev_attr_temp1_crit); 327 device_create_file(&new_client->dev, &dev_attr_temp1_crit);
322 device_create_file(&new_client->dev, &dev_attr_temp1_min); 328 device_create_file(&new_client->dev, &dev_attr_temp1_min);
@@ -327,6 +333,8 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
327 device_create_file(&new_client->dev, &dev_attr_alarms); 333 device_create_file(&new_client->dev, &dev_attr_alarms);
328 return 0; 334 return 0;
329 335
336exit_detach:
337 i2c_detach_client(new_client);
330exit_free: 338exit_free:
331 kfree(data); 339 kfree(data);
332exit: 340exit:
@@ -335,8 +343,10 @@ exit:
335 343
336static int lm77_detach_client(struct i2c_client *client) 344static int lm77_detach_client(struct i2c_client *client)
337{ 345{
346 struct lm77_data *data = i2c_get_clientdata(client);
347 hwmon_device_unregister(data->class_dev);
338 i2c_detach_client(client); 348 i2c_detach_client(client);
339 kfree(i2c_get_clientdata(client)); 349 kfree(data);
340 return 0; 350 return 0;
341} 351}
342 352