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/lm63.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/lm63.c')
-rw-r--r-- | drivers/hwmon/lm63.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 7c6f9ea5a254..cba0a40ad667 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -44,6 +44,8 @@ | |||
44 | #include <linux/i2c.h> | 44 | #include <linux/i2c.h> |
45 | #include <linux/i2c-sensor.h> | 45 | #include <linux/i2c-sensor.h> |
46 | #include <linux/hwmon-sysfs.h> | 46 | #include <linux/hwmon-sysfs.h> |
47 | #include <linux/hwmon.h> | ||
48 | #include <linux/err.h> | ||
47 | 49 | ||
48 | /* | 50 | /* |
49 | * Addresses to scan | 51 | * Addresses to scan |
@@ -152,6 +154,7 @@ static struct i2c_driver lm63_driver = { | |||
152 | 154 | ||
153 | struct lm63_data { | 155 | struct lm63_data { |
154 | struct i2c_client client; | 156 | struct i2c_client client; |
157 | struct class_device *class_dev; | ||
155 | struct semaphore update_lock; | 158 | struct semaphore update_lock; |
156 | char valid; /* zero until following fields are valid */ | 159 | char valid; /* zero until following fields are valid */ |
157 | unsigned long last_updated; /* in jiffies */ | 160 | unsigned long last_updated; /* in jiffies */ |
@@ -437,6 +440,12 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
437 | lm63_init_client(new_client); | 440 | lm63_init_client(new_client); |
438 | 441 | ||
439 | /* Register sysfs hooks */ | 442 | /* Register sysfs hooks */ |
443 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
444 | if (IS_ERR(data->class_dev)) { | ||
445 | err = PTR_ERR(data->class_dev); | ||
446 | goto exit_detach; | ||
447 | } | ||
448 | |||
440 | if (data->config & 0x04) { /* tachometer enabled */ | 449 | if (data->config & 0x04) { /* tachometer enabled */ |
441 | device_create_file(&new_client->dev, | 450 | device_create_file(&new_client->dev, |
442 | &sensor_dev_attr_fan1_input.dev_attr); | 451 | &sensor_dev_attr_fan1_input.dev_attr); |
@@ -462,6 +471,8 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
462 | 471 | ||
463 | return 0; | 472 | return 0; |
464 | 473 | ||
474 | exit_detach: | ||
475 | i2c_detach_client(new_client); | ||
465 | exit_free: | 476 | exit_free: |
466 | kfree(data); | 477 | kfree(data); |
467 | exit: | 478 | exit: |
@@ -505,15 +516,18 @@ static void lm63_init_client(struct i2c_client *client) | |||
505 | 516 | ||
506 | static int lm63_detach_client(struct i2c_client *client) | 517 | static int lm63_detach_client(struct i2c_client *client) |
507 | { | 518 | { |
519 | struct lm63_data *data = i2c_get_clientdata(client); | ||
508 | int err; | 520 | int err; |
509 | 521 | ||
522 | hwmon_device_unregister(data->class_dev); | ||
523 | |||
510 | if ((err = i2c_detach_client(client))) { | 524 | if ((err = i2c_detach_client(client))) { |
511 | dev_err(&client->dev, "Client deregistration failed, " | 525 | dev_err(&client->dev, "Client deregistration failed, " |
512 | "client not detached\n"); | 526 | "client not detached\n"); |
513 | return err; | 527 | return err; |
514 | } | 528 | } |
515 | 529 | ||
516 | kfree(i2c_get_clientdata(client)); | 530 | kfree(data); |
517 | return 0; | 531 | return 0; |
518 | } | 532 | } |
519 | 533 | ||