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/w83627ehf.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/w83627ehf.c')
-rw-r--r-- | drivers/hwmon/w83627ehf.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 250f6b059a54..956e7f830aa6 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c | |||
@@ -41,6 +41,8 @@ | |||
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
42 | #include <linux/i2c.h> | 42 | #include <linux/i2c.h> |
43 | #include <linux/i2c-sensor.h> | 43 | #include <linux/i2c-sensor.h> |
44 | #include <linux/hwmon.h> | ||
45 | #include <linux/err.h> | ||
44 | #include <asm/io.h> | 46 | #include <asm/io.h> |
45 | #include "lm75.h" | 47 | #include "lm75.h" |
46 | 48 | ||
@@ -177,6 +179,7 @@ temp1_to_reg(int temp) | |||
177 | 179 | ||
178 | struct w83627ehf_data { | 180 | struct w83627ehf_data { |
179 | struct i2c_client client; | 181 | struct i2c_client client; |
182 | struct class_device *class_dev; | ||
180 | struct semaphore lock; | 183 | struct semaphore lock; |
181 | 184 | ||
182 | struct semaphore update_lock; | 185 | struct semaphore update_lock; |
@@ -723,6 +726,12 @@ static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) | |||
723 | data->has_fan |= (1 << 4); | 726 | data->has_fan |= (1 << 4); |
724 | 727 | ||
725 | /* Register sysfs hooks */ | 728 | /* Register sysfs hooks */ |
729 | data->class_dev = hwmon_device_register(&client->dev); | ||
730 | if (IS_ERR(data->class_dev)) { | ||
731 | err = PTR_ERR(data->class_dev); | ||
732 | goto exit_detach; | ||
733 | } | ||
734 | |||
726 | device_create_file(&client->dev, &dev_attr_fan1_input); | 735 | device_create_file(&client->dev, &dev_attr_fan1_input); |
727 | device_create_file(&client->dev, &dev_attr_fan1_min); | 736 | device_create_file(&client->dev, &dev_attr_fan1_min); |
728 | device_create_file(&client->dev, &dev_attr_fan1_div); | 737 | device_create_file(&client->dev, &dev_attr_fan1_div); |
@@ -756,6 +765,8 @@ static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) | |||
756 | 765 | ||
757 | return 0; | 766 | return 0; |
758 | 767 | ||
768 | exit_detach: | ||
769 | i2c_detach_client(client); | ||
759 | exit_free: | 770 | exit_free: |
760 | kfree(data); | 771 | kfree(data); |
761 | exit_release: | 772 | exit_release: |
@@ -773,15 +784,18 @@ static int w83627ehf_attach_adapter(struct i2c_adapter *adapter) | |||
773 | 784 | ||
774 | static int w83627ehf_detach_client(struct i2c_client *client) | 785 | static int w83627ehf_detach_client(struct i2c_client *client) |
775 | { | 786 | { |
787 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
776 | int err; | 788 | int err; |
777 | 789 | ||
790 | hwmon_device_unregister(data->class_dev); | ||
791 | |||
778 | if ((err = i2c_detach_client(client))) { | 792 | if ((err = i2c_detach_client(client))) { |
779 | dev_err(&client->dev, "Client deregistration failed, " | 793 | dev_err(&client->dev, "Client deregistration failed, " |
780 | "client not detached.\n"); | 794 | "client not detached.\n"); |
781 | return err; | 795 | return err; |
782 | } | 796 | } |
783 | release_region(client->addr, REGION_LENGTH); | 797 | release_region(client->addr, REGION_LENGTH); |
784 | kfree(i2c_get_clientdata(client)); | 798 | kfree(data); |
785 | 799 | ||
786 | return 0; | 800 | return 0; |
787 | } | 801 | } |