aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm90.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 12:14:08 -0400
commit943b0830cebe4711354945ed3cb44e84152aaca0 (patch)
tree1963da8d8867069617404a8f92739035c6faca02 /drivers/hwmon/lm90.c
parent1236441f38b6a98caf4c7983e7efdecc2d1527b5 (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/lm90.c')
-rw-r--r--drivers/hwmon/lm90.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index a67dcadf7cb0..c1e8d0e965f7 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -77,6 +77,8 @@
77#include <linux/i2c.h> 77#include <linux/i2c.h>
78#include <linux/i2c-sensor.h> 78#include <linux/i2c-sensor.h>
79#include <linux/hwmon-sysfs.h> 79#include <linux/hwmon-sysfs.h>
80#include <linux/hwmon.h>
81#include <linux/err.h>
80 82
81/* 83/*
82 * Addresses to scan 84 * Addresses to scan
@@ -200,6 +202,7 @@ static struct i2c_driver lm90_driver = {
200 202
201struct lm90_data { 203struct lm90_data {
202 struct i2c_client client; 204 struct i2c_client client;
205 struct class_device *class_dev;
203 struct semaphore update_lock; 206 struct semaphore update_lock;
204 char valid; /* zero until following fields are valid */ 207 char valid; /* zero until following fields are valid */
205 unsigned long last_updated; /* in jiffies */ 208 unsigned long last_updated; /* in jiffies */
@@ -500,6 +503,12 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
500 lm90_init_client(new_client); 503 lm90_init_client(new_client);
501 504
502 /* Register sysfs hooks */ 505 /* Register sysfs hooks */
506 data->class_dev = hwmon_device_register(&new_client->dev);
507 if (IS_ERR(data->class_dev)) {
508 err = PTR_ERR(data->class_dev);
509 goto exit_detach;
510 }
511
503 device_create_file(&new_client->dev, 512 device_create_file(&new_client->dev,
504 &sensor_dev_attr_temp1_input.dev_attr); 513 &sensor_dev_attr_temp1_input.dev_attr);
505 device_create_file(&new_client->dev, 514 device_create_file(&new_client->dev,
@@ -524,6 +533,8 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
524 533
525 return 0; 534 return 0;
526 535
536exit_detach:
537 i2c_detach_client(new_client);
527exit_free: 538exit_free:
528 kfree(data); 539 kfree(data);
529exit: 540exit:
@@ -547,15 +558,18 @@ static void lm90_init_client(struct i2c_client *client)
547 558
548static int lm90_detach_client(struct i2c_client *client) 559static int lm90_detach_client(struct i2c_client *client)
549{ 560{
561 struct lm90_data *data = i2c_get_clientdata(client);
550 int err; 562 int err;
551 563
564 hwmon_device_unregister(data->class_dev);
565
552 if ((err = i2c_detach_client(client))) { 566 if ((err = i2c_detach_client(client))) {
553 dev_err(&client->dev, "Client deregistration failed, " 567 dev_err(&client->dev, "Client deregistration failed, "
554 "client not detached.\n"); 568 "client not detached.\n");
555 return err; 569 return err;
556 } 570 }
557 571
558 kfree(i2c_get_clientdata(client)); 572 kfree(data);
559 return 0; 573 return 0;
560} 574}
561 575