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/via686a.c | |
parent | 1236441f38b6a98caf4c7983e7efdecc2d1527b5 (diff) | |
download | blackbird-obmc-linux-943b0830cebe4711354945ed3cb44e84152aaca0.tar.gz blackbird-obmc-linux-943b0830cebe4711354945ed3cb44e84152aaca0.zip |
[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/via686a.c')
-rw-r--r-- | drivers/hwmon/via686a.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 164d47948390..8eb9d084149d 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c @@ -36,6 +36,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> @@ -297,6 +299,7 @@ static inline long TEMP_FROM_REG10(u16 val) via686a client is allocated. */ struct via686a_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* !=0 if following fields are valid */ unsigned long last_updated; /* In jiffies */ @@ -637,7 +640,7 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) { err = -ENOMEM; - goto ERROR0; + goto exit_release; } memset(data, 0, sizeof(struct via686a_data)); @@ -655,12 +658,18 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) init_MUTEX(&data->update_lock); /* Tell the I2C layer a new client has arrived */ if ((err = i2c_attach_client(new_client))) - goto ERROR3; + goto exit_free; /* Initialize the VIA686A chip */ via686a_init_client(new_client); /* 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 exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in2_input); @@ -695,17 +704,22 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) return 0; -ERROR3: +exit_detach: + i2c_detach_client(new_client); +exit_free: kfree(data); -ERROR0: +exit_release: release_region(address, VIA686A_EXTENT); return err; } static int via686a_detach_client(struct i2c_client *client) { + struct via686a_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"); @@ -713,7 +727,7 @@ static int via686a_detach_client(struct i2c_client *client) } release_region(client->addr, VIA686A_EXTENT); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } |