aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1026.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/adm1026.c')
-rw-r--r--drivers/hwmon/adm1026.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c
index c8a7f47911f9..eb55133a13ee 100644
--- a/drivers/hwmon/adm1026.c
+++ b/drivers/hwmon/adm1026.c
@@ -31,6 +31,8 @@
31#include <linux/i2c-sensor.h> 31#include <linux/i2c-sensor.h>
32#include <linux/i2c-vid.h> 32#include <linux/i2c-vid.h>
33#include <linux/hwmon-sysfs.h> 33#include <linux/hwmon-sysfs.h>
34#include <linux/hwmon.h>
35#include <linux/err.h>
34 36
35/* Addresses to scan */ 37/* Addresses to scan */
36static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 38static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
@@ -259,6 +261,7 @@ struct pwm_data {
259 261
260struct adm1026_data { 262struct adm1026_data {
261 struct i2c_client client; 263 struct i2c_client client;
264 struct class_device *class_dev;
262 struct semaphore lock; 265 struct semaphore lock;
263 enum chips type; 266 enum chips type;
264 267
@@ -324,8 +327,10 @@ int adm1026_attach_adapter(struct i2c_adapter *adapter)
324 327
325int adm1026_detach_client(struct i2c_client *client) 328int adm1026_detach_client(struct i2c_client *client)
326{ 329{
330 struct adm1026_data *data = i2c_get_clientdata(client);
331 hwmon_device_unregister(data->class_dev);
327 i2c_detach_client(client); 332 i2c_detach_client(client);
328 kfree(i2c_get_clientdata(client)); 333 kfree(data);
329 return 0; 334 return 0;
330} 335}
331 336
@@ -1555,6 +1560,12 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,
1555 adm1026_init_client(new_client); 1560 adm1026_init_client(new_client);
1556 1561
1557 /* Register sysfs hooks */ 1562 /* Register sysfs hooks */
1563 data->class_dev = hwmon_device_register(&new_client->dev);
1564 if (IS_ERR(data->class_dev)) {
1565 err = PTR_ERR(data->class_dev);
1566 goto exitdetach;
1567 }
1568
1558 device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); 1569 device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
1559 device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); 1570 device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
1560 device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); 1571 device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
@@ -1690,6 +1701,8 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,
1690 return 0; 1701 return 0;
1691 1702
1692 /* Error out and cleanup code */ 1703 /* Error out and cleanup code */
1704exitdetach:
1705 i2c_detach_client(new_client);
1693exitfree: 1706exitfree:
1694 kfree(data); 1707 kfree(data);
1695exit: 1708exit: