diff options
Diffstat (limited to 'drivers/hwmon/it87.c')
-rw-r--r-- | drivers/hwmon/it87.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index db20c9e47393..92c5b2420f9b 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -39,6 +39,8 @@ | |||
39 | #include <linux/i2c-sensor.h> | 39 | #include <linux/i2c-sensor.h> |
40 | #include <linux/i2c-vid.h> | 40 | #include <linux/i2c-vid.h> |
41 | #include <linux/hwmon-sysfs.h> | 41 | #include <linux/hwmon-sysfs.h> |
42 | #include <linux/hwmon.h> | ||
43 | #include <linux/err.h> | ||
42 | #include <asm/io.h> | 44 | #include <asm/io.h> |
43 | 45 | ||
44 | 46 | ||
@@ -192,6 +194,7 @@ static int DIV_TO_REG(int val) | |||
192 | allocated. */ | 194 | allocated. */ |
193 | struct it87_data { | 195 | struct it87_data { |
194 | struct i2c_client client; | 196 | struct i2c_client client; |
197 | struct class_device *class_dev; | ||
195 | struct semaphore lock; | 198 | struct semaphore lock; |
196 | enum chips type; | 199 | enum chips type; |
197 | 200 | ||
@@ -840,6 +843,12 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
840 | it87_init_client(new_client, data); | 843 | it87_init_client(new_client, data); |
841 | 844 | ||
842 | /* Register sysfs hooks */ | 845 | /* Register sysfs hooks */ |
846 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
847 | if (IS_ERR(data->class_dev)) { | ||
848 | err = PTR_ERR(data->class_dev); | ||
849 | goto ERROR3; | ||
850 | } | ||
851 | |||
843 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); | 852 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); |
844 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); | 853 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); |
845 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); | 854 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); |
@@ -904,6 +913,8 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
904 | 913 | ||
905 | return 0; | 914 | return 0; |
906 | 915 | ||
916 | ERROR3: | ||
917 | i2c_detach_client(new_client); | ||
907 | ERROR2: | 918 | ERROR2: |
908 | kfree(data); | 919 | kfree(data); |
909 | ERROR1: | 920 | ERROR1: |
@@ -915,8 +926,11 @@ ERROR0: | |||
915 | 926 | ||
916 | static int it87_detach_client(struct i2c_client *client) | 927 | static int it87_detach_client(struct i2c_client *client) |
917 | { | 928 | { |
929 | struct it87_data *data = i2c_get_clientdata(client); | ||
918 | int err; | 930 | int err; |
919 | 931 | ||
932 | hwmon_device_unregister(data->class_dev); | ||
933 | |||
920 | if ((err = i2c_detach_client(client))) { | 934 | if ((err = i2c_detach_client(client))) { |
921 | dev_err(&client->dev, | 935 | dev_err(&client->dev, |
922 | "Client deregistration failed, client not detached.\n"); | 936 | "Client deregistration failed, client not detached.\n"); |
@@ -925,7 +939,7 @@ static int it87_detach_client(struct i2c_client *client) | |||
925 | 939 | ||
926 | if(i2c_is_isa_client(client)) | 940 | if(i2c_is_isa_client(client)) |
927 | release_region(client->addr, IT87_EXTENT); | 941 | release_region(client->addr, IT87_EXTENT); |
928 | kfree(i2c_get_clientdata(client)); | 942 | kfree(data); |
929 | 943 | ||
930 | return 0; | 944 | return 0; |
931 | } | 945 | } |