aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/atxp1.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/atxp1.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/atxp1.c')
-rw-r--r--drivers/hwmon/atxp1.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c
index fca3fc1cef72..5f79f07a4ab8 100644
--- a/drivers/hwmon/atxp1.c
+++ b/drivers/hwmon/atxp1.c
@@ -25,6 +25,8 @@
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/i2c-sensor.h> 26#include <linux/i2c-sensor.h>
27#include <linux/i2c-vid.h> 27#include <linux/i2c-vid.h>
28#include <linux/hwmon.h>
29#include <linux/err.h>
28 30
29MODULE_LICENSE("GPL"); 31MODULE_LICENSE("GPL");
30MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); 32MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");
@@ -59,6 +61,7 @@ static struct i2c_driver atxp1_driver = {
59 61
60struct atxp1_data { 62struct atxp1_data {
61 struct i2c_client client; 63 struct i2c_client client;
64 struct class_device *class_dev;
62 struct semaphore update_lock; 65 struct semaphore update_lock;
63 unsigned long last_updated; 66 unsigned long last_updated;
64 u8 valid; 67 u8 valid;
@@ -317,6 +320,12 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
317 goto exit_free; 320 goto exit_free;
318 } 321 }
319 322
323 data->class_dev = hwmon_device_register(&new_client->dev);
324 if (IS_ERR(data->class_dev)) {
325 err = PTR_ERR(data->class_dev);
326 goto exit_detach;
327 }
328
320 device_create_file(&new_client->dev, &dev_attr_gpio1); 329 device_create_file(&new_client->dev, &dev_attr_gpio1);
321 device_create_file(&new_client->dev, &dev_attr_gpio2); 330 device_create_file(&new_client->dev, &dev_attr_gpio2);
322 device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 331 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
@@ -326,6 +335,8 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
326 335
327 return 0; 336 return 0;
328 337
338exit_detach:
339 i2c_detach_client(new_client);
329exit_free: 340exit_free:
330 kfree(data); 341 kfree(data);
331exit: 342exit:
@@ -334,14 +345,17 @@ exit:
334 345
335static int atxp1_detach_client(struct i2c_client * client) 346static int atxp1_detach_client(struct i2c_client * client)
336{ 347{
348 struct atxp1_data * data = i2c_get_clientdata(client);
337 int err; 349 int err;
338 350
351 hwmon_device_unregister(data->class_dev);
352
339 err = i2c_detach_client(client); 353 err = i2c_detach_client(client);
340 354
341 if (err) 355 if (err)
342 dev_err(&client->dev, "Failed to detach client.\n"); 356 dev_err(&client->dev, "Failed to detach client.\n");
343 else 357 else
344 kfree(i2c_get_clientdata(client)); 358 kfree(data);
345 359
346 return err; 360 return err;
347}; 361};