diff options
author | Mark M. Hoffman <mhoffman@lightlink.com> | 2005-07-15 21:39:18 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-09-05 12:14:08 -0400 |
commit | 943b0830cebe4711354945ed3cb44e84152aaca0 (patch) | |
tree | 1963da8d8867069617404a8f92739035c6faca02 /drivers/hwmon/adm1031.c | |
parent | 1236441f38b6a98caf4c7983e7efdecc2d1527b5 (diff) |
[PATCH] I2C hwmon: add hwmon sysfs class to drivers
This patch modifies sensors chip drivers to make use of the new
sysfs class "hwmon".
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/adm1031.c')
-rw-r--r-- | drivers/hwmon/adm1031.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 936250957270..ac3b1542556e 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -27,6 +27,8 @@ | |||
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/i2c-sensor.h> |
30 | #include <linux/hwmon.h> | ||
31 | #include <linux/err.h> | ||
30 | 32 | ||
31 | /* Following macros takes channel parameter starting from 0 to 2 */ | 33 | /* Following macros takes channel parameter starting from 0 to 2 */ |
32 | #define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) | 34 | #define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) |
@@ -69,6 +71,7 @@ typedef u8 auto_chan_table_t[8][2]; | |||
69 | /* Each client has this additional data */ | 71 | /* Each client has this additional data */ |
70 | struct adm1031_data { | 72 | struct adm1031_data { |
71 | struct i2c_client client; | 73 | struct i2c_client client; |
74 | struct class_device *class_dev; | ||
72 | struct semaphore update_lock; | 75 | struct semaphore update_lock; |
73 | int chip_type; | 76 | int chip_type; |
74 | char valid; /* !=0 if following fields are valid */ | 77 | char valid; /* !=0 if following fields are valid */ |
@@ -788,6 +791,12 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) | |||
788 | adm1031_init_client(new_client); | 791 | adm1031_init_client(new_client); |
789 | 792 | ||
790 | /* Register sysfs hooks */ | 793 | /* Register sysfs hooks */ |
794 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
795 | if (IS_ERR(data->class_dev)) { | ||
796 | err = PTR_ERR(data->class_dev); | ||
797 | goto exit_detach; | ||
798 | } | ||
799 | |||
791 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 800 | device_create_file(&new_client->dev, &dev_attr_fan1_input); |
792 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | 801 | device_create_file(&new_client->dev, &dev_attr_fan1_div); |
793 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 802 | device_create_file(&new_client->dev, &dev_attr_fan1_min); |
@@ -833,6 +842,8 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) | |||
833 | 842 | ||
834 | return 0; | 843 | return 0; |
835 | 844 | ||
845 | exit_detach: | ||
846 | i2c_detach_client(new_client); | ||
836 | exit_free: | 847 | exit_free: |
837 | kfree(data); | 848 | kfree(data); |
838 | exit: | 849 | exit: |
@@ -841,11 +852,14 @@ exit: | |||
841 | 852 | ||
842 | static int adm1031_detach_client(struct i2c_client *client) | 853 | static int adm1031_detach_client(struct i2c_client *client) |
843 | { | 854 | { |
855 | struct adm1031_data *data = i2c_get_clientdata(client); | ||
844 | int ret; | 856 | int ret; |
857 | |||
858 | hwmon_device_unregister(data->class_dev); | ||
845 | if ((ret = i2c_detach_client(client)) != 0) { | 859 | if ((ret = i2c_detach_client(client)) != 0) { |
846 | return ret; | 860 | return ret; |
847 | } | 861 | } |
848 | kfree(i2c_get_clientdata(client)); | 862 | kfree(data); |
849 | return 0; | 863 | return 0; |
850 | } | 864 | } |
851 | 865 | ||