aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm9240.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/adm9240.c')
-rw-r--r--drivers/hwmon/adm9240.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index ce2a6eb93f6e..7ef61206ba10 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -47,6 +47,8 @@
47#include <linux/i2c.h> 47#include <linux/i2c.h>
48#include <linux/i2c-sensor.h> 48#include <linux/i2c-sensor.h>
49#include <linux/i2c-vid.h> 49#include <linux/i2c-vid.h>
50#include <linux/hwmon.h>
51#include <linux/err.h>
50 52
51/* Addresses to scan */ 53/* Addresses to scan */
52static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, 54static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
@@ -150,6 +152,7 @@ static struct i2c_driver adm9240_driver = {
150struct adm9240_data { 152struct adm9240_data {
151 enum chips type; 153 enum chips type;
152 struct i2c_client client; 154 struct i2c_client client;
155 struct class_device *class_dev;
153 struct semaphore update_lock; 156 struct semaphore update_lock;
154 char valid; 157 char valid;
155 unsigned long last_updated_measure; 158 unsigned long last_updated_measure;
@@ -582,6 +585,12 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
582 adm9240_init_client(new_client); 585 adm9240_init_client(new_client);
583 586
584 /* populate sysfs filesystem */ 587 /* populate sysfs filesystem */
588 data->class_dev = hwmon_device_register(&new_client->dev);
589 if (IS_ERR(data->class_dev)) {
590 err = PTR_ERR(data->class_dev);
591 goto exit_detach;
592 }
593
585 device_create_file(&new_client->dev, &dev_attr_in0_input); 594 device_create_file(&new_client->dev, &dev_attr_in0_input);
586 device_create_file(&new_client->dev, &dev_attr_in0_min); 595 device_create_file(&new_client->dev, &dev_attr_in0_min);
587 device_create_file(&new_client->dev, &dev_attr_in0_max); 596 device_create_file(&new_client->dev, &dev_attr_in0_max);
@@ -615,6 +624,9 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
615 device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 624 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
616 625
617 return 0; 626 return 0;
627
628exit_detach:
629 i2c_detach_client(new_client);
618exit_free: 630exit_free:
619 kfree(data); 631 kfree(data);
620exit: 632exit:
@@ -630,15 +642,18 @@ static int adm9240_attach_adapter(struct i2c_adapter *adapter)
630 642
631static int adm9240_detach_client(struct i2c_client *client) 643static int adm9240_detach_client(struct i2c_client *client)
632{ 644{
645 struct adm9240_data *data = i2c_get_clientdata(client);
633 int err; 646 int err;
634 647
648 hwmon_device_unregister(data->class_dev);
649
635 if ((err = i2c_detach_client(client))) { 650 if ((err = i2c_detach_client(client))) {
636 dev_err(&client->dev, "Client deregistration failed, " 651 dev_err(&client->dev, "Client deregistration failed, "
637 "client not detached.\n"); 652 "client not detached.\n");
638 return err; 653 return err;
639 } 654 }
640 655
641 kfree(i2c_get_clientdata(client)); 656 kfree(data);
642 return 0; 657 return 0;
643} 658}
644 659