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/lm83.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/lm83.c')
-rw-r--r-- | drivers/hwmon/lm83.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index a49008b444c8..f3f3901c7294 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c | |||
@@ -34,6 +34,8 @@ | |||
34 | #include <linux/i2c.h> | 34 | #include <linux/i2c.h> |
35 | #include <linux/i2c-sensor.h> | 35 | #include <linux/i2c-sensor.h> |
36 | #include <linux/hwmon-sysfs.h> | 36 | #include <linux/hwmon-sysfs.h> |
37 | #include <linux/hwmon.h> | ||
38 | #include <linux/err.h> | ||
37 | 39 | ||
38 | /* | 40 | /* |
39 | * Addresses to scan | 41 | * Addresses to scan |
@@ -138,6 +140,7 @@ static struct i2c_driver lm83_driver = { | |||
138 | 140 | ||
139 | struct lm83_data { | 141 | struct lm83_data { |
140 | struct i2c_client client; | 142 | struct i2c_client client; |
143 | struct class_device *class_dev; | ||
141 | struct semaphore update_lock; | 144 | struct semaphore update_lock; |
142 | char valid; /* zero until following fields are valid */ | 145 | char valid; /* zero until following fields are valid */ |
143 | unsigned long last_updated; /* in jiffies */ | 146 | unsigned long last_updated; /* in jiffies */ |
@@ -312,6 +315,12 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) | |||
312 | */ | 315 | */ |
313 | 316 | ||
314 | /* Register sysfs hooks */ | 317 | /* Register sysfs hooks */ |
318 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
319 | if (IS_ERR(data->class_dev)) { | ||
320 | err = PTR_ERR(data->class_dev); | ||
321 | goto exit_detach; | ||
322 | } | ||
323 | |||
315 | device_create_file(&new_client->dev, | 324 | device_create_file(&new_client->dev, |
316 | &sensor_dev_attr_temp1_input.dev_attr); | 325 | &sensor_dev_attr_temp1_input.dev_attr); |
317 | device_create_file(&new_client->dev, | 326 | device_create_file(&new_client->dev, |
@@ -340,6 +349,8 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) | |||
340 | 349 | ||
341 | return 0; | 350 | return 0; |
342 | 351 | ||
352 | exit_detach: | ||
353 | i2c_detach_client(new_client); | ||
343 | exit_free: | 354 | exit_free: |
344 | kfree(data); | 355 | kfree(data); |
345 | exit: | 356 | exit: |
@@ -348,15 +359,18 @@ exit: | |||
348 | 359 | ||
349 | static int lm83_detach_client(struct i2c_client *client) | 360 | static int lm83_detach_client(struct i2c_client *client) |
350 | { | 361 | { |
362 | struct lm83_data *data = i2c_get_clientdata(client); | ||
351 | int err; | 363 | int err; |
352 | 364 | ||
365 | hwmon_device_unregister(data->class_dev); | ||
366 | |||
353 | if ((err = i2c_detach_client(client))) { | 367 | if ((err = i2c_detach_client(client))) { |
354 | dev_err(&client->dev, | 368 | dev_err(&client->dev, |
355 | "Client deregistration failed, client not detached.\n"); | 369 | "Client deregistration failed, client not detached.\n"); |
356 | return err; | 370 | return err; |
357 | } | 371 | } |
358 | 372 | ||
359 | kfree(i2c_get_clientdata(client)); | 373 | kfree(data); |
360 | return 0; | 374 | return 0; |
361 | } | 375 | } |
362 | 376 | ||