aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/fscher.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/fscher.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/fscher.c')
-rw-r--r--drivers/hwmon/fscher.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c
index da411741c2c5..b794580a0726 100644
--- a/drivers/hwmon/fscher.c
+++ b/drivers/hwmon/fscher.c
@@ -32,6 +32,8 @@
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/i2c-sensor.h> 34#include <linux/i2c-sensor.h>
35#include <linux/hwmon.h>
36#include <linux/err.h>
35 37
36/* 38/*
37 * Addresses to scan 39 * Addresses to scan
@@ -132,6 +134,7 @@ static struct i2c_driver fscher_driver = {
132 134
133struct fscher_data { 135struct fscher_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 */
@@ -341,6 +344,12 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
341 fscher_init_client(new_client); 344 fscher_init_client(new_client);
342 345
343 /* Register sysfs hooks */ 346 /* Register sysfs hooks */
347 data->class_dev = hwmon_device_register(&new_client->dev);
348 if (IS_ERR(data->class_dev)) {
349 err = PTR_ERR(data->class_dev);
350 goto exit_detach;
351 }
352
344 device_create_file_revision(new_client); 353 device_create_file_revision(new_client);
345 device_create_file_alarms(new_client); 354 device_create_file_alarms(new_client);
346 device_create_file_control(new_client); 355 device_create_file_control(new_client);
@@ -360,6 +369,8 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
360 369
361 return 0; 370 return 0;
362 371
372exit_detach:
373 i2c_detach_client(new_client);
363exit_free: 374exit_free:
364 kfree(data); 375 kfree(data);
365exit: 376exit:
@@ -368,15 +379,18 @@ exit:
368 379
369static int fscher_detach_client(struct i2c_client *client) 380static int fscher_detach_client(struct i2c_client *client)
370{ 381{
382 struct fscher_data *data = i2c_get_clientdata(client);
371 int err; 383 int err;
372 384
385 hwmon_device_unregister(data->class_dev);
386
373 if ((err = i2c_detach_client(client))) { 387 if ((err = i2c_detach_client(client))) {
374 dev_err(&client->dev, "Client deregistration failed, " 388 dev_err(&client->dev, "Client deregistration failed, "
375 "client not detached.\n"); 389 "client not detached.\n");
376 return err; 390 return err;
377 } 391 }
378 392
379 kfree(i2c_get_clientdata(client)); 393 kfree(data);
380 return 0; 394 return 0;
381} 395}
382 396