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.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c
index b98f44952997..15f30fdc75c6 100644
--- a/drivers/hwmon/lm77.c
+++ b/drivers/hwmon/lm77.c
@@ -31,7 +31,8 @@
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/i2c-sensor.h>
34 34#include <linux/hwmon.h>
35#include <linux/err.h>
35 36
36/* Addresses to scan */ 37/* Addresses to scan */
37static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; 38static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END };
@@ -51,6 +52,7 @@ SENSORS_INSMOD_1(lm77);
51/* Each client has this additional data */ 52/* Each client has this additional data */
52struct lm77_data { 53struct lm77_data {
53 struct i2c_client client; 54 struct i2c_client client;
55 struct class_device *class_dev;
54 struct semaphore update_lock; 56 struct semaphore update_lock;
55 char valid; 57 char valid;
56 unsigned long last_updated; /* In jiffies */ 58 unsigned long last_updated; /* In jiffies */
@@ -317,6 +319,12 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
317 lm77_init_client(new_client); 319 lm77_init_client(new_client);
318 320
319 /* Register sysfs hooks */ 321 /* Register sysfs hooks */
322 data->class_dev = hwmon_device_register(&new_client->dev);
323 if (IS_ERR(data->class_dev)) {
324 err = PTR_ERR(data->class_dev);
325 goto exit_detach;
326 }
327
320 device_create_file(&new_client->dev, &dev_attr_temp1_input); 328 device_create_file(&new_client->dev, &dev_attr_temp1_input);
321 device_create_file(&new_client->dev, &dev_attr_temp1_crit); 329 device_create_file(&new_client->dev, &dev_attr_temp1_crit);
322 device_create_file(&new_client->dev, &dev_attr_temp1_min); 330 device_create_file(&new_client->dev, &dev_attr_temp1_min);
@@ -327,6 +335,8 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
327 device_create_file(&new_client->dev, &dev_attr_alarms); 335 device_create_file(&new_client->dev, &dev_attr_alarms);
328 return 0; 336 return 0;
329 337
338exit_detach:
339 i2c_detach_client(new_client);
330exit_free: 340exit_free:
331 kfree(data); 341 kfree(data);
332exit: 342exit:
@@ -335,8 +345,10 @@ exit:
335 345
336static int lm77_detach_client(struct i2c_client *client) 346static int lm77_detach_client(struct i2c_client *client)
337{ 347{
348 struct lm77_data *data = i2c_get_clientdata(client);
349 hwmon_device_unregister(data->class_dev);
338 i2c_detach_client(client); 350 i2c_detach_client(client);
339 kfree(i2c_get_clientdata(client)); 351 kfree(data);
340 return 0; 352 return 0;
341} 353}
342 354