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 12:14:08 -0400 |
commit | 943b0830cebe4711354945ed3cb44e84152aaca0 (patch) | |
tree | 1963da8d8867069617404a8f92739035c6faca02 /drivers/hwmon/smsc47m1.c | |
parent | 1236441f38b6a98caf4c7983e7efdecc2d1527b5 (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/smsc47m1.c')
-rw-r--r-- | drivers/hwmon/smsc47m1.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index 7166ad0b2fda..de7c7f804d66 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #include <linux/jiffies.h> | 31 | #include <linux/jiffies.h> |
32 | #include <linux/i2c.h> | 32 | #include <linux/i2c.h> |
33 | #include <linux/i2c-sensor.h> | 33 | #include <linux/i2c-sensor.h> |
34 | #include <linux/hwmon.h> | ||
35 | #include <linux/err.h> | ||
34 | #include <linux/init.h> | 36 | #include <linux/init.h> |
35 | #include <asm/io.h> | 37 | #include <asm/io.h> |
36 | 38 | ||
@@ -108,6 +110,7 @@ superio_exit(void) | |||
108 | 110 | ||
109 | struct smsc47m1_data { | 111 | struct smsc47m1_data { |
110 | struct i2c_client client; | 112 | struct i2c_client client; |
113 | struct class_device *class_dev; | ||
111 | struct semaphore lock; | 114 | struct semaphore lock; |
112 | 115 | ||
113 | struct semaphore update_lock; | 116 | struct semaphore update_lock; |
@@ -461,6 +464,13 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind) | |||
461 | function. */ | 464 | function. */ |
462 | smsc47m1_update_device(&new_client->dev, 1); | 465 | smsc47m1_update_device(&new_client->dev, 1); |
463 | 466 | ||
467 | /* Register sysfs hooks */ | ||
468 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
469 | if (IS_ERR(data->class_dev)) { | ||
470 | err = PTR_ERR(data->class_dev); | ||
471 | goto error_detach; | ||
472 | } | ||
473 | |||
464 | if (fan1) { | 474 | if (fan1) { |
465 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 475 | device_create_file(&new_client->dev, &dev_attr_fan1_input); |
466 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 476 | device_create_file(&new_client->dev, &dev_attr_fan1_min); |
@@ -494,6 +504,8 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind) | |||
494 | 504 | ||
495 | return 0; | 505 | return 0; |
496 | 506 | ||
507 | error_detach: | ||
508 | i2c_detach_client(new_client); | ||
497 | error_free: | 509 | error_free: |
498 | kfree(data); | 510 | kfree(data); |
499 | error_release: | 511 | error_release: |
@@ -503,8 +515,11 @@ error_release: | |||
503 | 515 | ||
504 | static int smsc47m1_detach_client(struct i2c_client *client) | 516 | static int smsc47m1_detach_client(struct i2c_client *client) |
505 | { | 517 | { |
518 | struct smsc47m1_data *data = i2c_get_clientdata(client); | ||
506 | int err; | 519 | int err; |
507 | 520 | ||
521 | hwmon_device_unregister(data->class_dev); | ||
522 | |||
508 | if ((err = i2c_detach_client(client))) { | 523 | if ((err = i2c_detach_client(client))) { |
509 | dev_err(&client->dev, "Client deregistration failed, " | 524 | dev_err(&client->dev, "Client deregistration failed, " |
510 | "client not detached.\n"); | 525 | "client not detached.\n"); |
@@ -512,7 +527,7 @@ static int smsc47m1_detach_client(struct i2c_client *client) | |||
512 | } | 527 | } |
513 | 528 | ||
514 | release_region(client->addr, SMSC_EXTENT); | 529 | release_region(client->addr, SMSC_EXTENT); |
515 | kfree(i2c_get_clientdata(client)); | 530 | kfree(data); |
516 | 531 | ||
517 | return 0; | 532 | return 0; |
518 | } | 533 | } |