diff options
Diffstat (limited to 'drivers/hwmon/w83627hf.c')
-rw-r--r-- | drivers/hwmon/w83627hf.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index bd87a42e068a..da2f4992ee21 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c | |||
@@ -44,6 +44,8 @@ | |||
44 | #include <linux/i2c.h> | 44 | #include <linux/i2c.h> |
45 | #include <linux/i2c-sensor.h> | 45 | #include <linux/i2c-sensor.h> |
46 | #include <linux/i2c-vid.h> | 46 | #include <linux/i2c-vid.h> |
47 | #include <linux/hwmon.h> | ||
48 | #include <linux/err.h> | ||
47 | #include <asm/io.h> | 49 | #include <asm/io.h> |
48 | #include "lm75.h" | 50 | #include "lm75.h" |
49 | 51 | ||
@@ -277,6 +279,7 @@ static inline u8 DIV_TO_REG(long val) | |||
277 | dynamically allocated, at the same time when a new client is allocated. */ | 279 | dynamically allocated, at the same time when a new client is allocated. */ |
278 | struct w83627hf_data { | 280 | struct w83627hf_data { |
279 | struct i2c_client client; | 281 | struct i2c_client client; |
282 | struct class_device *class_dev; | ||
280 | struct semaphore lock; | 283 | struct semaphore lock; |
281 | enum chips type; | 284 | enum chips type; |
282 | 285 | ||
@@ -1102,6 +1105,12 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address, | |||
1102 | data->fan_min[2] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(3)); | 1105 | data->fan_min[2] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(3)); |
1103 | 1106 | ||
1104 | /* Register sysfs hooks */ | 1107 | /* Register sysfs hooks */ |
1108 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
1109 | if (IS_ERR(data->class_dev)) { | ||
1110 | err = PTR_ERR(data->class_dev); | ||
1111 | goto ERROR3; | ||
1112 | } | ||
1113 | |||
1105 | device_create_file_in(new_client, 0); | 1114 | device_create_file_in(new_client, 0); |
1106 | if (kind != w83697hf) | 1115 | if (kind != w83697hf) |
1107 | device_create_file_in(new_client, 1); | 1116 | device_create_file_in(new_client, 1); |
@@ -1152,6 +1161,8 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address, | |||
1152 | 1161 | ||
1153 | return 0; | 1162 | return 0; |
1154 | 1163 | ||
1164 | ERROR3: | ||
1165 | i2c_detach_client(new_client); | ||
1155 | ERROR2: | 1166 | ERROR2: |
1156 | kfree(data); | 1167 | kfree(data); |
1157 | ERROR1: | 1168 | ERROR1: |
@@ -1162,8 +1173,11 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address, | |||
1162 | 1173 | ||
1163 | static int w83627hf_detach_client(struct i2c_client *client) | 1174 | static int w83627hf_detach_client(struct i2c_client *client) |
1164 | { | 1175 | { |
1176 | struct w83627hf_data *data = i2c_get_clientdata(client); | ||
1165 | int err; | 1177 | int err; |
1166 | 1178 | ||
1179 | hwmon_device_unregister(data->class_dev); | ||
1180 | |||
1167 | if ((err = i2c_detach_client(client))) { | 1181 | if ((err = i2c_detach_client(client))) { |
1168 | dev_err(&client->dev, | 1182 | dev_err(&client->dev, |
1169 | "Client deregistration failed, client not detached.\n"); | 1183 | "Client deregistration failed, client not detached.\n"); |
@@ -1171,7 +1185,7 @@ static int w83627hf_detach_client(struct i2c_client *client) | |||
1171 | } | 1185 | } |
1172 | 1186 | ||
1173 | release_region(client->addr, WINB_EXTENT); | 1187 | release_region(client->addr, WINB_EXTENT); |
1174 | kfree(i2c_get_clientdata(client)); | 1188 | kfree(data); |
1175 | 1189 | ||
1176 | return 0; | 1190 | return 0; |
1177 | } | 1191 | } |