summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm63.c
diff options
context:
space:
mode:
authorMark M. Hoffman <mhoffman@lightlink.com>2005-07-15 21:39:18 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-05 09:14:08 -0700
commit943b0830cebe4711354945ed3cb44e84152aaca0 (patch)
tree1963da8d8867069617404a8f92739035c6faca02 /drivers/hwmon/lm63.c
parent1236441f38b6a98caf4c7983e7efdecc2d1527b5 (diff)
downloadop-kernel-dev-943b0830cebe4711354945ed3cb44e84152aaca0.zip
op-kernel-dev-943b0830cebe4711354945ed3cb44e84152aaca0.tar.gz
[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/lm63.c')
-rw-r--r--drivers/hwmon/lm63.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index 7c6f9ea..cba0a40 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -44,6 +44,8 @@
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/hwmon-sysfs.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/*
* Addresses to scan
@@ -152,6 +154,7 @@ static struct i2c_driver lm63_driver = {
struct lm63_data {
struct i2c_client client;
+ struct class_device *class_dev;
struct semaphore update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
@@ -437,6 +440,12 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
lm63_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;
+ }
+
if (data->config & 0x04) { /* tachometer enabled */
device_create_file(&new_client->dev,
&sensor_dev_attr_fan1_input.dev_attr);
@@ -462,6 +471,8 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -505,15 +516,18 @@ static void lm63_init_client(struct i2c_client *client)
static int lm63_detach_client(struct i2c_client *client)
{
+ struct lm63_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");
return err;
}
- kfree(i2c_get_clientdata(client));
+ kfree(data);
return 0;
}
OpenPOWER on IntegriCloud