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/lm78.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/lm78.c')
-rw-r--r-- | drivers/hwmon/lm78.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index cf7a2a7f54b5..570098e15366 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.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 <asm/io.h> | 29 | #include <asm/io.h> |
28 | 30 | ||
29 | /* Addresses to scan */ | 31 | /* Addresses to scan */ |
@@ -134,6 +136,7 @@ static inline int VID_FROM_REG(u8 val) | |||
134 | allocated. */ | 136 | allocated. */ |
135 | struct lm78_data { | 137 | struct lm78_data { |
136 | struct i2c_client client; | 138 | struct i2c_client client; |
139 | struct class_device *class_dev; | ||
137 | struct semaphore lock; | 140 | struct semaphore lock; |
138 | enum chips type; | 141 | enum chips type; |
139 | 142 | ||
@@ -602,6 +605,12 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | |||
602 | } | 605 | } |
603 | 606 | ||
604 | /* Register sysfs hooks */ | 607 | /* Register sysfs hooks */ |
608 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
609 | if (IS_ERR(data->class_dev)) { | ||
610 | err = PTR_ERR(data->class_dev); | ||
611 | goto ERROR3; | ||
612 | } | ||
613 | |||
605 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 614 | device_create_file(&new_client->dev, &dev_attr_in0_input); |
606 | device_create_file(&new_client->dev, &dev_attr_in0_min); | 615 | device_create_file(&new_client->dev, &dev_attr_in0_min); |
607 | device_create_file(&new_client->dev, &dev_attr_in0_max); | 616 | device_create_file(&new_client->dev, &dev_attr_in0_max); |
@@ -640,6 +649,8 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) | |||
640 | 649 | ||
641 | return 0; | 650 | return 0; |
642 | 651 | ||
652 | ERROR3: | ||
653 | i2c_detach_client(new_client); | ||
643 | ERROR2: | 654 | ERROR2: |
644 | kfree(data); | 655 | kfree(data); |
645 | ERROR1: | 656 | ERROR1: |
@@ -651,8 +662,11 @@ ERROR0: | |||
651 | 662 | ||
652 | static int lm78_detach_client(struct i2c_client *client) | 663 | static int lm78_detach_client(struct i2c_client *client) |
653 | { | 664 | { |
665 | struct lm78_data *data = i2c_get_clientdata(client); | ||
654 | int err; | 666 | int err; |
655 | 667 | ||
668 | hwmon_device_unregister(data->class_dev); | ||
669 | |||
656 | if ((err = i2c_detach_client(client))) { | 670 | if ((err = i2c_detach_client(client))) { |
657 | dev_err(&client->dev, | 671 | dev_err(&client->dev, |
658 | "Client deregistration failed, client not detached.\n"); | 672 | "Client deregistration failed, client not detached.\n"); |
@@ -662,7 +676,7 @@ static int lm78_detach_client(struct i2c_client *client) | |||
662 | if(i2c_is_isa_client(client)) | 676 | if(i2c_is_isa_client(client)) |
663 | release_region(client->addr, LM78_EXTENT); | 677 | release_region(client->addr, LM78_EXTENT); |
664 | 678 | ||
665 | kfree(i2c_get_clientdata(client)); | 679 | kfree(data); |
666 | 680 | ||
667 | return 0; | 681 | return 0; |
668 | } | 682 | } |