aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm80.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm80.c')
-rw-r--r--drivers/hwmon/lm80.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index 8100595feb44..dbf8df386250 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -27,6 +27,8 @@
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-sensor.h> 29#include <linux/i2c-sensor.h>
30#include <linux/hwmon.h>
31#include <linux/err.h>
30 32
31/* Addresses to scan */ 33/* Addresses to scan */
32static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 34static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c,
@@ -107,6 +109,7 @@ static inline long TEMP_FROM_REG(u16 temp)
107 109
108struct lm80_data { 110struct lm80_data {
109 struct i2c_client client; 111 struct i2c_client client;
112 struct class_device *class_dev;
110 struct semaphore update_lock; 113 struct semaphore update_lock;
111 char valid; /* !=0 if following fields are valid */ 114 char valid; /* !=0 if following fields are valid */
112 unsigned long last_updated; /* In jiffies */ 115 unsigned long last_updated; /* In jiffies */
@@ -451,6 +454,12 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
451 data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2)); 454 data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2));
452 455
453 /* Register sysfs hooks */ 456 /* Register sysfs hooks */
457 data->class_dev = hwmon_device_register(&new_client->dev);
458 if (IS_ERR(data->class_dev)) {
459 err = PTR_ERR(data->class_dev);
460 goto error_detach;
461 }
462
454 device_create_file(&new_client->dev, &dev_attr_in0_min); 463 device_create_file(&new_client->dev, &dev_attr_in0_min);
455 device_create_file(&new_client->dev, &dev_attr_in1_min); 464 device_create_file(&new_client->dev, &dev_attr_in1_min);
456 device_create_file(&new_client->dev, &dev_attr_in2_min); 465 device_create_file(&new_client->dev, &dev_attr_in2_min);
@@ -487,6 +496,8 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
487 496
488 return 0; 497 return 0;
489 498
499error_detach:
500 i2c_detach_client(new_client);
490error_free: 501error_free:
491 kfree(data); 502 kfree(data);
492exit: 503exit:
@@ -495,15 +506,18 @@ exit:
495 506
496static int lm80_detach_client(struct i2c_client *client) 507static int lm80_detach_client(struct i2c_client *client)
497{ 508{
509 struct lm80_data *data = i2c_get_clientdata(client);
498 int err; 510 int err;
499 511
512 hwmon_device_unregister(data->class_dev);
513
500 if ((err = i2c_detach_client(client))) { 514 if ((err = i2c_detach_client(client))) {
501 dev_err(&client->dev, "Client deregistration failed, " 515 dev_err(&client->dev, "Client deregistration failed, "
502 "client not detached.\n"); 516 "client not detached.\n");
503 return err; 517 return err;
504 } 518 }
505 519
506 kfree(i2c_get_clientdata(client)); 520 kfree(data);
507 return 0; 521 return 0;
508} 522}
509 523