aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1021.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/adm1021.c')
-rw-r--r--drivers/hwmon/adm1021.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index d2c774c32f45..a483d96e4cef 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -25,6 +25,8 @@
25#include <linux/jiffies.h> 25#include <linux/jiffies.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/i2c-sensor.h> 27#include <linux/i2c-sensor.h>
28#include <linux/hwmon.h>
29#include <linux/err.h>
28 30
29 31
30/* Addresses to scan */ 32/* Addresses to scan */
@@ -89,6 +91,7 @@ clearing it. Weird, ey? --Phil */
89/* Each client has this additional data */ 91/* Each client has this additional data */
90struct adm1021_data { 92struct adm1021_data {
91 struct i2c_client client; 93 struct i2c_client client;
94 struct class_device *class_dev;
92 enum chips type; 95 enum chips type;
93 96
94 struct semaphore update_lock; 97 struct semaphore update_lock;
@@ -295,6 +298,12 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
295 adm1021_init_client(new_client); 298 adm1021_init_client(new_client);
296 299
297 /* Register sysfs hooks */ 300 /* Register sysfs hooks */
301 data->class_dev = hwmon_device_register(&new_client->dev);
302 if (IS_ERR(data->class_dev)) {
303 err = PTR_ERR(data->class_dev);
304 goto error2;
305 }
306
298 device_create_file(&new_client->dev, &dev_attr_temp1_max); 307 device_create_file(&new_client->dev, &dev_attr_temp1_max);
299 device_create_file(&new_client->dev, &dev_attr_temp1_min); 308 device_create_file(&new_client->dev, &dev_attr_temp1_min);
300 device_create_file(&new_client->dev, &dev_attr_temp1_input); 309 device_create_file(&new_client->dev, &dev_attr_temp1_input);
@@ -305,6 +314,8 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
305 314
306 return 0; 315 return 0;
307 316
317error2:
318 i2c_detach_client(new_client);
308error1: 319error1:
309 kfree(data); 320 kfree(data);
310error0: 321error0:
@@ -322,14 +333,17 @@ static void adm1021_init_client(struct i2c_client *client)
322 333
323static int adm1021_detach_client(struct i2c_client *client) 334static int adm1021_detach_client(struct i2c_client *client)
324{ 335{
336 struct adm1021_data *data = i2c_get_clientdata(client);
325 int err; 337 int err;
326 338
339 hwmon_device_unregister(data->class_dev);
340
327 if ((err = i2c_detach_client(client))) { 341 if ((err = i2c_detach_client(client))) {
328 dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); 342 dev_err(&client->dev, "Client deregistration failed, client not detached.\n");
329 return err; 343 return err;
330 } 344 }
331 345
332 kfree(i2c_get_clientdata(client)); 346 kfree(data);
333 return 0; 347 return 0;
334} 348}
335 349