diff options
Diffstat (limited to 'drivers/hwmon/adm1031.c')
-rw-r--r-- | drivers/hwmon/adm1031.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 936250957270..58338ed7c8a1 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -26,7 +26,8 @@ | |||
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/jiffies.h> | 27 | #include <linux/jiffies.h> |
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/i2c-sensor.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/err.h> | ||
30 | 31 | ||
31 | /* Following macros takes channel parameter starting from 0 to 2 */ | 32 | /* Following macros takes channel parameter starting from 0 to 2 */ |
32 | #define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) | 33 | #define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) |
@@ -59,16 +60,16 @@ | |||
59 | 60 | ||
60 | /* Addresses to scan */ | 61 | /* Addresses to scan */ |
61 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 62 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
62 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
63 | 63 | ||
64 | /* Insmod parameters */ | 64 | /* Insmod parameters */ |
65 | SENSORS_INSMOD_2(adm1030, adm1031); | 65 | I2C_CLIENT_INSMOD_2(adm1030, adm1031); |
66 | 66 | ||
67 | typedef u8 auto_chan_table_t[8][2]; | 67 | typedef u8 auto_chan_table_t[8][2]; |
68 | 68 | ||
69 | /* Each client has this additional data */ | 69 | /* Each client has this additional data */ |
70 | struct adm1031_data { | 70 | struct adm1031_data { |
71 | struct i2c_client client; | 71 | struct i2c_client client; |
72 | struct class_device *class_dev; | ||
72 | struct semaphore update_lock; | 73 | struct semaphore update_lock; |
73 | int chip_type; | 74 | int chip_type; |
74 | char valid; /* !=0 if following fields are valid */ | 75 | char valid; /* !=0 if following fields are valid */ |
@@ -725,10 +726,10 @@ static int adm1031_attach_adapter(struct i2c_adapter *adapter) | |||
725 | { | 726 | { |
726 | if (!(adapter->class & I2C_CLASS_HWMON)) | 727 | if (!(adapter->class & I2C_CLASS_HWMON)) |
727 | return 0; | 728 | return 0; |
728 | return i2c_detect(adapter, &addr_data, adm1031_detect); | 729 | return i2c_probe(adapter, &addr_data, adm1031_detect); |
729 | } | 730 | } |
730 | 731 | ||
731 | /* This function is called by i2c_detect */ | 732 | /* This function is called by i2c_probe */ |
732 | static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) | 733 | static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) |
733 | { | 734 | { |
734 | struct i2c_client *new_client; | 735 | struct i2c_client *new_client; |
@@ -788,6 +789,12 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) | |||
788 | adm1031_init_client(new_client); | 789 | adm1031_init_client(new_client); |
789 | 790 | ||
790 | /* Register sysfs hooks */ | 791 | /* Register sysfs hooks */ |
792 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
793 | if (IS_ERR(data->class_dev)) { | ||
794 | err = PTR_ERR(data->class_dev); | ||
795 | goto exit_detach; | ||
796 | } | ||
797 | |||
791 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 798 | device_create_file(&new_client->dev, &dev_attr_fan1_input); |
792 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | 799 | device_create_file(&new_client->dev, &dev_attr_fan1_div); |
793 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 800 | device_create_file(&new_client->dev, &dev_attr_fan1_min); |
@@ -833,6 +840,8 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) | |||
833 | 840 | ||
834 | return 0; | 841 | return 0; |
835 | 842 | ||
843 | exit_detach: | ||
844 | i2c_detach_client(new_client); | ||
836 | exit_free: | 845 | exit_free: |
837 | kfree(data); | 846 | kfree(data); |
838 | exit: | 847 | exit: |
@@ -841,11 +850,14 @@ exit: | |||
841 | 850 | ||
842 | static int adm1031_detach_client(struct i2c_client *client) | 851 | static int adm1031_detach_client(struct i2c_client *client) |
843 | { | 852 | { |
853 | struct adm1031_data *data = i2c_get_clientdata(client); | ||
844 | int ret; | 854 | int ret; |
855 | |||
856 | hwmon_device_unregister(data->class_dev); | ||
845 | if ((ret = i2c_detach_client(client)) != 0) { | 857 | if ((ret = i2c_detach_client(client)) != 0) { |
846 | return ret; | 858 | return ret; |
847 | } | 859 | } |
848 | kfree(i2c_get_clientdata(client)); | 860 | kfree(data); |
849 | return 0; | 861 | return 0; |
850 | } | 862 | } |
851 | 863 | ||