diff options
Diffstat (limited to 'drivers/hwmon/adm1025.c')
-rw-r--r-- | drivers/hwmon/adm1025.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index e452d0daf906..526b7ff179eb 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c | |||
@@ -50,8 +50,9 @@ | |||
50 | #include <linux/slab.h> | 50 | #include <linux/slab.h> |
51 | #include <linux/jiffies.h> | 51 | #include <linux/jiffies.h> |
52 | #include <linux/i2c.h> | 52 | #include <linux/i2c.h> |
53 | #include <linux/i2c-sensor.h> | 53 | #include <linux/hwmon.h> |
54 | #include <linux/i2c-vid.h> | 54 | #include <linux/hwmon-vid.h> |
55 | #include <linux/err.h> | ||
55 | 56 | ||
56 | /* | 57 | /* |
57 | * Addresses to scan | 58 | * Addresses to scan |
@@ -60,13 +61,12 @@ | |||
60 | */ | 61 | */ |
61 | 62 | ||
62 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 63 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
63 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
64 | 64 | ||
65 | /* | 65 | /* |
66 | * Insmod parameters | 66 | * Insmod parameters |
67 | */ | 67 | */ |
68 | 68 | ||
69 | SENSORS_INSMOD_2(adm1025, ne1619); | 69 | I2C_CLIENT_INSMOD_2(adm1025, ne1619); |
70 | 70 | ||
71 | /* | 71 | /* |
72 | * The ADM1025 registers | 72 | * The ADM1025 registers |
@@ -132,6 +132,7 @@ static struct i2c_driver adm1025_driver = { | |||
132 | 132 | ||
133 | struct adm1025_data { | 133 | struct adm1025_data { |
134 | struct i2c_client client; | 134 | struct i2c_client client; |
135 | struct class_device *class_dev; | ||
135 | struct semaphore update_lock; | 136 | struct semaphore update_lock; |
136 | char valid; /* zero until following fields are valid */ | 137 | char valid; /* zero until following fields are valid */ |
137 | unsigned long last_updated; /* in jiffies */ | 138 | unsigned long last_updated; /* in jiffies */ |
@@ -312,7 +313,7 @@ static int adm1025_attach_adapter(struct i2c_adapter *adapter) | |||
312 | { | 313 | { |
313 | if (!(adapter->class & I2C_CLASS_HWMON)) | 314 | if (!(adapter->class & I2C_CLASS_HWMON)) |
314 | return 0; | 315 | return 0; |
315 | return i2c_detect(adapter, &addr_data, adm1025_detect); | 316 | return i2c_probe(adapter, &addr_data, adm1025_detect); |
316 | } | 317 | } |
317 | 318 | ||
318 | /* | 319 | /* |
@@ -416,6 +417,12 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) | |||
416 | adm1025_init_client(new_client); | 417 | adm1025_init_client(new_client); |
417 | 418 | ||
418 | /* Register sysfs hooks */ | 419 | /* Register sysfs hooks */ |
420 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
421 | if (IS_ERR(data->class_dev)) { | ||
422 | err = PTR_ERR(data->class_dev); | ||
423 | goto exit_detach; | ||
424 | } | ||
425 | |||
419 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 426 | device_create_file(&new_client->dev, &dev_attr_in0_input); |
420 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 427 | device_create_file(&new_client->dev, &dev_attr_in1_input); |
421 | device_create_file(&new_client->dev, &dev_attr_in2_input); | 428 | device_create_file(&new_client->dev, &dev_attr_in2_input); |
@@ -452,6 +459,8 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) | |||
452 | 459 | ||
453 | return 0; | 460 | return 0; |
454 | 461 | ||
462 | exit_detach: | ||
463 | i2c_detach_client(new_client); | ||
455 | exit_free: | 464 | exit_free: |
456 | kfree(data); | 465 | kfree(data); |
457 | exit: | 466 | exit: |
@@ -464,7 +473,7 @@ static void adm1025_init_client(struct i2c_client *client) | |||
464 | struct adm1025_data *data = i2c_get_clientdata(client); | 473 | struct adm1025_data *data = i2c_get_clientdata(client); |
465 | int i; | 474 | int i; |
466 | 475 | ||
467 | data->vrm = i2c_which_vrm(); | 476 | data->vrm = vid_which_vrm(); |
468 | 477 | ||
469 | /* | 478 | /* |
470 | * Set high limits | 479 | * Set high limits |
@@ -502,15 +511,15 @@ static void adm1025_init_client(struct i2c_client *client) | |||
502 | 511 | ||
503 | static int adm1025_detach_client(struct i2c_client *client) | 512 | static int adm1025_detach_client(struct i2c_client *client) |
504 | { | 513 | { |
514 | struct adm1025_data *data = i2c_get_clientdata(client); | ||
505 | int err; | 515 | int err; |
506 | 516 | ||
507 | if ((err = i2c_detach_client(client))) { | 517 | hwmon_device_unregister(data->class_dev); |
508 | dev_err(&client->dev, "Client deregistration failed, " | 518 | |
509 | "client not detached.\n"); | 519 | if ((err = i2c_detach_client(client))) |
510 | return err; | 520 | return err; |
511 | } | ||
512 | 521 | ||
513 | kfree(i2c_get_clientdata(client)); | 522 | kfree(data); |
514 | return 0; | 523 | return 0; |
515 | } | 524 | } |
516 | 525 | ||