aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1025.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/adm1025.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/adm1025.c')
-rw-r--r--drivers/hwmon/adm1025.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c
index e452d0daf906..b68b292c00d4 100644
--- a/drivers/hwmon/adm1025.c
+++ b/drivers/hwmon/adm1025.c
@@ -52,6 +52,8 @@
52#include <linux/i2c.h> 52#include <linux/i2c.h>
53#include <linux/i2c-sensor.h> 53#include <linux/i2c-sensor.h>
54#include <linux/i2c-vid.h> 54#include <linux/i2c-vid.h>
55#include <linux/hwmon.h>
56#include <linux/err.h>
55 57
56/* 58/*
57 * Addresses to scan 59 * Addresses to scan
@@ -132,6 +134,7 @@ static struct i2c_driver adm1025_driver = {
132 134
133struct adm1025_data { 135struct adm1025_data {
134 struct i2c_client client; 136 struct i2c_client client;
137 struct class_device *class_dev;
135 struct semaphore update_lock; 138 struct semaphore update_lock;
136 char valid; /* zero until following fields are valid */ 139 char valid; /* zero until following fields are valid */
137 unsigned long last_updated; /* in jiffies */ 140 unsigned long last_updated; /* in jiffies */
@@ -416,6 +419,12 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
416 adm1025_init_client(new_client); 419 adm1025_init_client(new_client);
417 420
418 /* Register sysfs hooks */ 421 /* Register sysfs hooks */
422 data->class_dev = hwmon_device_register(&new_client->dev);
423 if (IS_ERR(data->class_dev)) {
424 err = PTR_ERR(data->class_dev);
425 goto exit_detach;
426 }
427
419 device_create_file(&new_client->dev, &dev_attr_in0_input); 428 device_create_file(&new_client->dev, &dev_attr_in0_input);
420 device_create_file(&new_client->dev, &dev_attr_in1_input); 429 device_create_file(&new_client->dev, &dev_attr_in1_input);
421 device_create_file(&new_client->dev, &dev_attr_in2_input); 430 device_create_file(&new_client->dev, &dev_attr_in2_input);
@@ -452,6 +461,8 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
452 461
453 return 0; 462 return 0;
454 463
464exit_detach:
465 i2c_detach_client(new_client);
455exit_free: 466exit_free:
456 kfree(data); 467 kfree(data);
457exit: 468exit:
@@ -502,15 +513,18 @@ static void adm1025_init_client(struct i2c_client *client)
502 513
503static int adm1025_detach_client(struct i2c_client *client) 514static int adm1025_detach_client(struct i2c_client *client)
504{ 515{
516 struct adm1025_data *data = i2c_get_clientdata(client);
505 int err; 517 int err;
506 518
519 hwmon_device_unregister(data->class_dev);
520
507 if ((err = i2c_detach_client(client))) { 521 if ((err = i2c_detach_client(client))) {
508 dev_err(&client->dev, "Client deregistration failed, " 522 dev_err(&client->dev, "Client deregistration failed, "
509 "client not detached.\n"); 523 "client not detached.\n");
510 return err; 524 return err;
511 } 525 }
512 526
513 kfree(i2c_get_clientdata(client)); 527 kfree(data);
514 return 0; 528 return 0;
515} 529}
516 530