diff options
Diffstat (limited to 'drivers/hwmon/adm9240.c')
-rw-r--r-- | drivers/hwmon/adm9240.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index ce2a6eb93f6e..bc7faef162f7 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -45,17 +45,16 @@ | |||
45 | #include <linux/module.h> | 45 | #include <linux/module.h> |
46 | #include <linux/slab.h> | 46 | #include <linux/slab.h> |
47 | #include <linux/i2c.h> | 47 | #include <linux/i2c.h> |
48 | #include <linux/i2c-sensor.h> | 48 | #include <linux/hwmon.h> |
49 | #include <linux/i2c-vid.h> | 49 | #include <linux/hwmon-vid.h> |
50 | #include <linux/err.h> | ||
50 | 51 | ||
51 | /* Addresses to scan */ | 52 | /* Addresses to scan */ |
52 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, | 53 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, |
53 | I2C_CLIENT_END }; | 54 | I2C_CLIENT_END }; |
54 | 55 | ||
55 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
56 | |||
57 | /* Insmod parameters */ | 56 | /* Insmod parameters */ |
58 | SENSORS_INSMOD_3(adm9240, ds1780, lm81); | 57 | I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm81); |
59 | 58 | ||
60 | /* ADM9240 registers */ | 59 | /* ADM9240 registers */ |
61 | #define ADM9240_REG_MAN_ID 0x3e | 60 | #define ADM9240_REG_MAN_ID 0x3e |
@@ -150,6 +149,7 @@ static struct i2c_driver adm9240_driver = { | |||
150 | struct adm9240_data { | 149 | struct adm9240_data { |
151 | enum chips type; | 150 | enum chips type; |
152 | struct i2c_client client; | 151 | struct i2c_client client; |
152 | struct class_device *class_dev; | ||
153 | struct semaphore update_lock; | 153 | struct semaphore update_lock; |
154 | char valid; | 154 | char valid; |
155 | unsigned long last_updated_measure; | 155 | unsigned long last_updated_measure; |
@@ -582,6 +582,12 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
582 | adm9240_init_client(new_client); | 582 | adm9240_init_client(new_client); |
583 | 583 | ||
584 | /* populate sysfs filesystem */ | 584 | /* populate sysfs filesystem */ |
585 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
586 | if (IS_ERR(data->class_dev)) { | ||
587 | err = PTR_ERR(data->class_dev); | ||
588 | goto exit_detach; | ||
589 | } | ||
590 | |||
585 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 591 | device_create_file(&new_client->dev, &dev_attr_in0_input); |
586 | device_create_file(&new_client->dev, &dev_attr_in0_min); | 592 | device_create_file(&new_client->dev, &dev_attr_in0_min); |
587 | device_create_file(&new_client->dev, &dev_attr_in0_max); | 593 | device_create_file(&new_client->dev, &dev_attr_in0_max); |
@@ -615,6 +621,9 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
615 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | 621 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); |
616 | 622 | ||
617 | return 0; | 623 | return 0; |
624 | |||
625 | exit_detach: | ||
626 | i2c_detach_client(new_client); | ||
618 | exit_free: | 627 | exit_free: |
619 | kfree(data); | 628 | kfree(data); |
620 | exit: | 629 | exit: |
@@ -625,20 +634,20 @@ static int adm9240_attach_adapter(struct i2c_adapter *adapter) | |||
625 | { | 634 | { |
626 | if (!(adapter->class & I2C_CLASS_HWMON)) | 635 | if (!(adapter->class & I2C_CLASS_HWMON)) |
627 | return 0; | 636 | return 0; |
628 | return i2c_detect(adapter, &addr_data, adm9240_detect); | 637 | return i2c_probe(adapter, &addr_data, adm9240_detect); |
629 | } | 638 | } |
630 | 639 | ||
631 | static int adm9240_detach_client(struct i2c_client *client) | 640 | static int adm9240_detach_client(struct i2c_client *client) |
632 | { | 641 | { |
642 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
633 | int err; | 643 | int err; |
634 | 644 | ||
635 | if ((err = i2c_detach_client(client))) { | 645 | hwmon_device_unregister(data->class_dev); |
636 | dev_err(&client->dev, "Client deregistration failed, " | 646 | |
637 | "client not detached.\n"); | 647 | if ((err = i2c_detach_client(client))) |
638 | return err; | 648 | return err; |
639 | } | ||
640 | 649 | ||
641 | kfree(i2c_get_clientdata(client)); | 650 | kfree(data); |
642 | return 0; | 651 | return 0; |
643 | } | 652 | } |
644 | 653 | ||
@@ -648,7 +657,7 @@ static void adm9240_init_client(struct i2c_client *client) | |||
648 | u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); | 657 | u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); |
649 | u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; | 658 | u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; |
650 | 659 | ||
651 | data->vrm = i2c_which_vrm(); /* need this to report vid as mV */ | 660 | data->vrm = vid_which_vrm(); /* need this to report vid as mV */ |
652 | 661 | ||
653 | dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10, | 662 | dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10, |
654 | data->vrm % 10); | 663 | data->vrm % 10); |