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/pc87360.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/pc87360.c')
-rw-r--r-- | drivers/hwmon/pc87360.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index fa4032d53b79..496549bf96b9 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -40,6 +40,8 @@ | |||
40 | #include <linux/i2c.h> | 40 | #include <linux/i2c.h> |
41 | #include <linux/i2c-sensor.h> | 41 | #include <linux/i2c-sensor.h> |
42 | #include <linux/i2c-vid.h> | 42 | #include <linux/i2c-vid.h> |
43 | #include <linux/hwmon.h> | ||
44 | #include <linux/err.h> | ||
43 | #include <asm/io.h> | 45 | #include <asm/io.h> |
44 | 46 | ||
45 | static unsigned short normal_i2c[] = { I2C_CLIENT_END }; | 47 | static unsigned short normal_i2c[] = { I2C_CLIENT_END }; |
@@ -186,6 +188,7 @@ static inline u8 PWM_TO_REG(int val, int inv) | |||
186 | 188 | ||
187 | struct pc87360_data { | 189 | struct pc87360_data { |
188 | struct i2c_client client; | 190 | struct i2c_client client; |
191 | struct class_device *class_dev; | ||
189 | struct semaphore lock; | 192 | struct semaphore lock; |
190 | struct semaphore update_lock; | 193 | struct semaphore update_lock; |
191 | char valid; /* !=0 if following fields are valid */ | 194 | char valid; /* !=0 if following fields are valid */ |
@@ -838,6 +841,12 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind) | |||
838 | } | 841 | } |
839 | 842 | ||
840 | /* Register sysfs hooks */ | 843 | /* Register sysfs hooks */ |
844 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
845 | if (IS_ERR(data->class_dev)) { | ||
846 | err = PTR_ERR(data->class_dev); | ||
847 | goto ERROR3; | ||
848 | } | ||
849 | |||
841 | if (data->innr) { | 850 | if (data->innr) { |
842 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 851 | device_create_file(&new_client->dev, &dev_attr_in0_input); |
843 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 852 | device_create_file(&new_client->dev, &dev_attr_in1_input); |
@@ -974,6 +983,8 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind) | |||
974 | 983 | ||
975 | return 0; | 984 | return 0; |
976 | 985 | ||
986 | ERROR3: | ||
987 | i2c_detach_client(new_client); | ||
977 | ERROR2: | 988 | ERROR2: |
978 | for (i = 0; i < 3; i++) { | 989 | for (i = 0; i < 3; i++) { |
979 | if (data->address[i]) { | 990 | if (data->address[i]) { |
@@ -990,6 +1001,8 @@ static int pc87360_detach_client(struct i2c_client *client) | |||
990 | struct pc87360_data *data = i2c_get_clientdata(client); | 1001 | struct pc87360_data *data = i2c_get_clientdata(client); |
991 | int i; | 1002 | int i; |
992 | 1003 | ||
1004 | hwmon_device_unregister(data->class_dev); | ||
1005 | |||
993 | if ((i = i2c_detach_client(client))) { | 1006 | if ((i = i2c_detach_client(client))) { |
994 | dev_err(&client->dev, "Client deregistration failed, " | 1007 | dev_err(&client->dev, "Client deregistration failed, " |
995 | "client not detached.\n"); | 1008 | "client not detached.\n"); |