aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/sis5595.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/sis5595.c')
-rw-r--r--drivers/hwmon/sis5595.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 6bbfc8fb4f13..ea5934f89f05 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -56,6 +56,8 @@
56#include <linux/pci.h> 56#include <linux/pci.h>
57#include <linux/i2c.h> 57#include <linux/i2c.h>
58#include <linux/i2c-sensor.h> 58#include <linux/i2c-sensor.h>
59#include <linux/hwmon.h>
60#include <linux/err.h>
59#include <linux/init.h> 61#include <linux/init.h>
60#include <linux/jiffies.h> 62#include <linux/jiffies.h>
61#include <asm/io.h> 63#include <asm/io.h>
@@ -168,6 +170,7 @@ static inline u8 DIV_TO_REG(int val)
168 allocated. */ 170 allocated. */
169struct sis5595_data { 171struct sis5595_data {
170 struct i2c_client client; 172 struct i2c_client client;
173 struct class_device *class_dev;
171 struct semaphore lock; 174 struct semaphore lock;
172 175
173 struct semaphore update_lock; 176 struct semaphore update_lock;
@@ -578,6 +581,12 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
578 } 581 }
579 582
580 /* Register sysfs hooks */ 583 /* Register sysfs hooks */
584 data->class_dev = hwmon_device_register(&new_client->dev);
585 if (IS_ERR(data->class_dev)) {
586 err = PTR_ERR(data->class_dev);
587 goto exit_detach;
588 }
589
581 device_create_file(&new_client->dev, &dev_attr_in0_input); 590 device_create_file(&new_client->dev, &dev_attr_in0_input);
582 device_create_file(&new_client->dev, &dev_attr_in0_min); 591 device_create_file(&new_client->dev, &dev_attr_in0_min);
583 device_create_file(&new_client->dev, &dev_attr_in0_max); 592 device_create_file(&new_client->dev, &dev_attr_in0_max);
@@ -608,7 +617,9 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
608 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); 617 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
609 } 618 }
610 return 0; 619 return 0;
611 620
621exit_detach:
622 i2c_detach_client(new_client);
612exit_free: 623exit_free:
613 kfree(data); 624 kfree(data);
614exit_release: 625exit_release:
@@ -619,8 +630,11 @@ exit:
619 630
620static int sis5595_detach_client(struct i2c_client *client) 631static int sis5595_detach_client(struct i2c_client *client)
621{ 632{
633 struct sis5595_data *data = i2c_get_clientdata(client);
622 int err; 634 int err;
623 635
636 hwmon_device_unregister(data->class_dev);
637
624 if ((err = i2c_detach_client(client))) { 638 if ((err = i2c_detach_client(client))) {
625 dev_err(&client->dev, 639 dev_err(&client->dev,
626 "Client deregistration failed, client not detached.\n"); 640 "Client deregistration failed, client not detached.\n");
@@ -630,7 +644,7 @@ static int sis5595_detach_client(struct i2c_client *client)
630 if (i2c_is_isa_client(client)) 644 if (i2c_is_isa_client(client))
631 release_region(client->addr, SIS5595_EXTENT); 645 release_region(client->addr, SIS5595_EXTENT);
632 646
633 kfree(i2c_get_clientdata(client)); 647 kfree(data);
634 648
635 return 0; 649 return 0;
636} 650}