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 09:14:08 -0700 |
commit | 943b0830cebe4711354945ed3cb44e84152aaca0 (patch) | |
tree | 1963da8d8867069617404a8f92739035c6faca02 /drivers/hwmon/smsc47m1.c | |
parent | 1236441f38b6a98caf4c7983e7efdecc2d1527b5 (diff) | |
download | kernel_samsung_smdk4412-943b0830cebe4711354945ed3cb44e84152aaca0.zip kernel_samsung_smdk4412-943b0830cebe4711354945ed3cb44e84152aaca0.tar.gz kernel_samsung_smdk4412-943b0830cebe4711354945ed3cb44e84152aaca0.tar.bz2 |
[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/smsc47m1.c')
-rw-r--r-- | drivers/hwmon/smsc47m1.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index 7166ad0..de7c7f8 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -31,6 +31,8 @@ #include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-sensor.h> +#include <linux/hwmon.h> +#include <linux/err.h> #include <linux/init.h> #include <asm/io.h> @@ -108,6 +110,7 @@ superio_exit(void) struct smsc47m1_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; struct semaphore update_lock; @@ -461,6 +464,13 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind) function. */ smsc47m1_update_device(&new_client->dev, 1); + /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto error_detach; + } + if (fan1) { device_create_file(&new_client->dev, &dev_attr_fan1_input); device_create_file(&new_client->dev, &dev_attr_fan1_min); @@ -494,6 +504,8 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +error_detach: + i2c_detach_client(new_client); error_free: kfree(data); error_release: @@ -503,8 +515,11 @@ error_release: static int smsc47m1_detach_client(struct i2c_client *client) { + struct smsc47m1_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); @@ -512,7 +527,7 @@ static int smsc47m1_detach_client(struct i2c_client *client) } release_region(client->addr, SMSC_EXTENT); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } |