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/lm77.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/lm77.c')
-rw-r--r-- | drivers/hwmon/lm77.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index b98f44952997..15f30fdc75c6 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -31,7 +31,8 @@ | |||
31 | #include <linux/jiffies.h> | 31 | #include <linux/jiffies.h> |
32 | #include <linux/i2c.h> | 32 | #include <linux/i2c.h> |
33 | #include <linux/i2c-sensor.h> | 33 | #include <linux/i2c-sensor.h> |
34 | 34 | #include <linux/hwmon.h> | |
35 | #include <linux/err.h> | ||
35 | 36 | ||
36 | /* Addresses to scan */ | 37 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; | 38 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; |
@@ -51,6 +52,7 @@ SENSORS_INSMOD_1(lm77); | |||
51 | /* Each client has this additional data */ | 52 | /* Each client has this additional data */ |
52 | struct lm77_data { | 53 | struct lm77_data { |
53 | struct i2c_client client; | 54 | struct i2c_client client; |
55 | struct class_device *class_dev; | ||
54 | struct semaphore update_lock; | 56 | struct semaphore update_lock; |
55 | char valid; | 57 | char valid; |
56 | unsigned long last_updated; /* In jiffies */ | 58 | unsigned long last_updated; /* In jiffies */ |
@@ -317,6 +319,12 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) | |||
317 | lm77_init_client(new_client); | 319 | lm77_init_client(new_client); |
318 | 320 | ||
319 | /* Register sysfs hooks */ | 321 | /* Register sysfs hooks */ |
322 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
323 | if (IS_ERR(data->class_dev)) { | ||
324 | err = PTR_ERR(data->class_dev); | ||
325 | goto exit_detach; | ||
326 | } | ||
327 | |||
320 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 328 | device_create_file(&new_client->dev, &dev_attr_temp1_input); |
321 | device_create_file(&new_client->dev, &dev_attr_temp1_crit); | 329 | device_create_file(&new_client->dev, &dev_attr_temp1_crit); |
322 | device_create_file(&new_client->dev, &dev_attr_temp1_min); | 330 | device_create_file(&new_client->dev, &dev_attr_temp1_min); |
@@ -327,6 +335,8 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) | |||
327 | device_create_file(&new_client->dev, &dev_attr_alarms); | 335 | device_create_file(&new_client->dev, &dev_attr_alarms); |
328 | return 0; | 336 | return 0; |
329 | 337 | ||
338 | exit_detach: | ||
339 | i2c_detach_client(new_client); | ||
330 | exit_free: | 340 | exit_free: |
331 | kfree(data); | 341 | kfree(data); |
332 | exit: | 342 | exit: |
@@ -335,8 +345,10 @@ exit: | |||
335 | 345 | ||
336 | static int lm77_detach_client(struct i2c_client *client) | 346 | static int lm77_detach_client(struct i2c_client *client) |
337 | { | 347 | { |
348 | struct lm77_data *data = i2c_get_clientdata(client); | ||
349 | hwmon_device_unregister(data->class_dev); | ||
338 | i2c_detach_client(client); | 350 | i2c_detach_client(client); |
339 | kfree(i2c_get_clientdata(client)); | 351 | kfree(data); |
340 | return 0; | 352 | return 0; |
341 | } | 353 | } |
342 | 354 | ||