diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-09-08 05:39:55 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-09-08 05:39:55 -0400 |
commit | c324b44c34050cf2a9b58830e11c974806bd85d8 (patch) | |
tree | 3ac45a783221283925cd698334a8f5e7dd4c1df8 /drivers/hwmon/atxp1.c | |
parent | 2fcf522509cceea524b6e7ece8fd6759b682175a (diff) | |
parent | caf39e87cc1182f7dae84eefc43ca14d54c78ef9 (diff) |
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'drivers/hwmon/atxp1.c')
-rw-r--r-- | drivers/hwmon/atxp1.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index fca3fc1cef72..deb4d34c9539 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c | |||
@@ -23,8 +23,9 @@ | |||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/jiffies.h> | 24 | #include <linux/jiffies.h> |
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/i2c-sensor.h> | 26 | #include <linux/hwmon.h> |
27 | #include <linux/i2c-vid.h> | 27 | #include <linux/hwmon-vid.h> |
28 | #include <linux/err.h> | ||
28 | 29 | ||
29 | MODULE_LICENSE("GPL"); | 30 | MODULE_LICENSE("GPL"); |
30 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); | 31 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); |
@@ -40,9 +41,8 @@ MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>"); | |||
40 | #define ATXP1_GPIO1MASK 0x0f | 41 | #define ATXP1_GPIO1MASK 0x0f |
41 | 42 | ||
42 | static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END }; | 43 | static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END }; |
43 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
44 | 44 | ||
45 | SENSORS_INSMOD_1(atxp1); | 45 | I2C_CLIENT_INSMOD_1(atxp1); |
46 | 46 | ||
47 | static int atxp1_attach_adapter(struct i2c_adapter * adapter); | 47 | static int atxp1_attach_adapter(struct i2c_adapter * adapter); |
48 | static int atxp1_detach_client(struct i2c_client * client); | 48 | static int atxp1_detach_client(struct i2c_client * client); |
@@ -59,6 +59,7 @@ static struct i2c_driver atxp1_driver = { | |||
59 | 59 | ||
60 | struct atxp1_data { | 60 | struct atxp1_data { |
61 | struct i2c_client client; | 61 | struct i2c_client client; |
62 | struct class_device *class_dev; | ||
62 | struct semaphore update_lock; | 63 | struct semaphore update_lock; |
63 | unsigned long last_updated; | 64 | unsigned long last_updated; |
64 | u8 valid; | 65 | u8 valid; |
@@ -252,7 +253,7 @@ static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); | |||
252 | 253 | ||
253 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) | 254 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) |
254 | { | 255 | { |
255 | return i2c_detect(adapter, &addr_data, &atxp1_detect); | 256 | return i2c_probe(adapter, &addr_data, &atxp1_detect); |
256 | }; | 257 | }; |
257 | 258 | ||
258 | static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | 259 | static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) |
@@ -295,7 +296,7 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | |||
295 | } | 296 | } |
296 | 297 | ||
297 | /* Get VRM */ | 298 | /* Get VRM */ |
298 | data->vrm = i2c_which_vrm(); | 299 | data->vrm = vid_which_vrm(); |
299 | 300 | ||
300 | if ((data->vrm != 90) && (data->vrm != 91)) { | 301 | if ((data->vrm != 90) && (data->vrm != 91)) { |
301 | dev_err(&new_client->dev, "Not supporting VRM %d.%d\n", | 302 | dev_err(&new_client->dev, "Not supporting VRM %d.%d\n", |
@@ -317,6 +318,12 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | |||
317 | goto exit_free; | 318 | goto exit_free; |
318 | } | 319 | } |
319 | 320 | ||
321 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
322 | if (IS_ERR(data->class_dev)) { | ||
323 | err = PTR_ERR(data->class_dev); | ||
324 | goto exit_detach; | ||
325 | } | ||
326 | |||
320 | device_create_file(&new_client->dev, &dev_attr_gpio1); | 327 | device_create_file(&new_client->dev, &dev_attr_gpio1); |
321 | device_create_file(&new_client->dev, &dev_attr_gpio2); | 328 | device_create_file(&new_client->dev, &dev_attr_gpio2); |
322 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | 329 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); |
@@ -326,6 +333,8 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | |||
326 | 333 | ||
327 | return 0; | 334 | return 0; |
328 | 335 | ||
336 | exit_detach: | ||
337 | i2c_detach_client(new_client); | ||
329 | exit_free: | 338 | exit_free: |
330 | kfree(data); | 339 | kfree(data); |
331 | exit: | 340 | exit: |
@@ -334,14 +343,17 @@ exit: | |||
334 | 343 | ||
335 | static int atxp1_detach_client(struct i2c_client * client) | 344 | static int atxp1_detach_client(struct i2c_client * client) |
336 | { | 345 | { |
346 | struct atxp1_data * data = i2c_get_clientdata(client); | ||
337 | int err; | 347 | int err; |
338 | 348 | ||
349 | hwmon_device_unregister(data->class_dev); | ||
350 | |||
339 | err = i2c_detach_client(client); | 351 | err = i2c_detach_client(client); |
340 | 352 | ||
341 | if (err) | 353 | if (err) |
342 | dev_err(&client->dev, "Failed to detach client.\n"); | 354 | dev_err(&client->dev, "Failed to detach client.\n"); |
343 | else | 355 | else |
344 | kfree(i2c_get_clientdata(client)); | 356 | kfree(data); |
345 | 357 | ||
346 | return err; | 358 | return err; |
347 | }; | 359 | }; |