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/lm75.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/lm75.c')
-rw-r--r-- | drivers/hwmon/lm75.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 79d7ebc9b14a..129c8f213331 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -24,6 +24,8 @@ | |||
24 | #include <linux/jiffies.h> | 24 | #include <linux/jiffies.h> |
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/i2c-sensor.h> | 26 | #include <linux/i2c-sensor.h> |
27 | #include <linux/hwmon.h> | ||
28 | #include <linux/err.h> | ||
27 | #include "lm75.h" | 29 | #include "lm75.h" |
28 | 30 | ||
29 | 31 | ||
@@ -46,6 +48,7 @@ SENSORS_INSMOD_1(lm75); | |||
46 | /* Each client has this additional data */ | 48 | /* Each client has this additional data */ |
47 | struct lm75_data { | 49 | struct lm75_data { |
48 | struct i2c_client client; | 50 | struct i2c_client client; |
51 | struct class_device *class_dev; | ||
49 | struct semaphore update_lock; | 52 | struct semaphore update_lock; |
50 | char valid; /* !=0 if following fields are valid */ | 53 | char valid; /* !=0 if following fields are valid */ |
51 | unsigned long last_updated; /* In jiffies */ | 54 | unsigned long last_updated; /* In jiffies */ |
@@ -208,12 +211,20 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | |||
208 | lm75_init_client(new_client); | 211 | lm75_init_client(new_client); |
209 | 212 | ||
210 | /* Register sysfs hooks */ | 213 | /* Register sysfs hooks */ |
214 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
215 | if (IS_ERR(data->class_dev)) { | ||
216 | err = PTR_ERR(data->class_dev); | ||
217 | goto exit_detach; | ||
218 | } | ||
219 | |||
211 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 220 | device_create_file(&new_client->dev, &dev_attr_temp1_max); |
212 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); | 221 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); |
213 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 222 | device_create_file(&new_client->dev, &dev_attr_temp1_input); |
214 | 223 | ||
215 | return 0; | 224 | return 0; |
216 | 225 | ||
226 | exit_detach: | ||
227 | i2c_detach_client(new_client); | ||
217 | exit_free: | 228 | exit_free: |
218 | kfree(data); | 229 | kfree(data); |
219 | exit: | 230 | exit: |
@@ -222,8 +233,10 @@ exit: | |||
222 | 233 | ||
223 | static int lm75_detach_client(struct i2c_client *client) | 234 | static int lm75_detach_client(struct i2c_client *client) |
224 | { | 235 | { |
236 | struct lm75_data *data = i2c_get_clientdata(client); | ||
237 | hwmon_device_unregister(data->class_dev); | ||
225 | i2c_detach_client(client); | 238 | i2c_detach_client(client); |
226 | kfree(i2c_get_clientdata(client)); | 239 | kfree(data); |
227 | return 0; | 240 | return 0; |
228 | } | 241 | } |
229 | 242 | ||