diff options
Diffstat (limited to 'drivers/hwmon/adm1026.c')
-rw-r--r-- | drivers/hwmon/adm1026.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index c8a7f47911f9..625158110fd4 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c | |||
@@ -28,16 +28,16 @@ | |||
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/jiffies.h> | 29 | #include <linux/jiffies.h> |
30 | #include <linux/i2c.h> | 30 | #include <linux/i2c.h> |
31 | #include <linux/i2c-sensor.h> | 31 | #include <linux/hwmon.h> |
32 | #include <linux/i2c-vid.h> | ||
33 | #include <linux/hwmon-sysfs.h> | 32 | #include <linux/hwmon-sysfs.h> |
33 | #include <linux/hwmon-vid.h> | ||
34 | #include <linux/err.h> | ||
34 | 35 | ||
35 | /* Addresses to scan */ | 36 | /* Addresses to scan */ |
36 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 37 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
37 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
38 | 38 | ||
39 | /* Insmod parameters */ | 39 | /* Insmod parameters */ |
40 | SENSORS_INSMOD_1(adm1026); | 40 | I2C_CLIENT_INSMOD_1(adm1026); |
41 | 41 | ||
42 | static int gpio_input[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, | 42 | static int gpio_input[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, |
43 | -1, -1, -1, -1, -1, -1, -1, -1 }; | 43 | -1, -1, -1, -1, -1, -1, -1, -1 }; |
@@ -259,6 +259,7 @@ struct pwm_data { | |||
259 | 259 | ||
260 | struct adm1026_data { | 260 | struct adm1026_data { |
261 | struct i2c_client client; | 261 | struct i2c_client client; |
262 | struct class_device *class_dev; | ||
262 | struct semaphore lock; | 263 | struct semaphore lock; |
263 | enum chips type; | 264 | enum chips type; |
264 | 265 | ||
@@ -319,13 +320,15 @@ int adm1026_attach_adapter(struct i2c_adapter *adapter) | |||
319 | if (!(adapter->class & I2C_CLASS_HWMON)) { | 320 | if (!(adapter->class & I2C_CLASS_HWMON)) { |
320 | return 0; | 321 | return 0; |
321 | } | 322 | } |
322 | return i2c_detect(adapter, &addr_data, adm1026_detect); | 323 | return i2c_probe(adapter, &addr_data, adm1026_detect); |
323 | } | 324 | } |
324 | 325 | ||
325 | int adm1026_detach_client(struct i2c_client *client) | 326 | int adm1026_detach_client(struct i2c_client *client) |
326 | { | 327 | { |
328 | struct adm1026_data *data = i2c_get_clientdata(client); | ||
329 | hwmon_device_unregister(data->class_dev); | ||
327 | i2c_detach_client(client); | 330 | i2c_detach_client(client); |
328 | kfree(i2c_get_clientdata(client)); | 331 | kfree(data); |
329 | return 0; | 332 | return 0; |
330 | } | 333 | } |
331 | 334 | ||
@@ -1549,12 +1552,18 @@ int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1549 | goto exitfree; | 1552 | goto exitfree; |
1550 | 1553 | ||
1551 | /* Set the VRM version */ | 1554 | /* Set the VRM version */ |
1552 | data->vrm = i2c_which_vrm(); | 1555 | data->vrm = vid_which_vrm(); |
1553 | 1556 | ||
1554 | /* Initialize the ADM1026 chip */ | 1557 | /* Initialize the ADM1026 chip */ |
1555 | adm1026_init_client(new_client); | 1558 | adm1026_init_client(new_client); |
1556 | 1559 | ||
1557 | /* Register sysfs hooks */ | 1560 | /* Register sysfs hooks */ |
1561 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
1562 | if (IS_ERR(data->class_dev)) { | ||
1563 | err = PTR_ERR(data->class_dev); | ||
1564 | goto exitdetach; | ||
1565 | } | ||
1566 | |||
1558 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); | 1567 | 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); | 1568 | 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); | 1569 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); |
@@ -1690,6 +1699,8 @@ int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1690 | return 0; | 1699 | return 0; |
1691 | 1700 | ||
1692 | /* Error out and cleanup code */ | 1701 | /* Error out and cleanup code */ |
1702 | exitdetach: | ||
1703 | i2c_detach_client(new_client); | ||
1693 | exitfree: | 1704 | exitfree: |
1694 | kfree(data); | 1705 | kfree(data); |
1695 | exit: | 1706 | exit: |