diff options
Diffstat (limited to 'drivers/hwmon/lm87.c')
-rw-r--r-- | drivers/hwmon/lm87.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 1921ed1af182..dca996de4c33 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -57,8 +57,9 @@ | |||
57 | #include <linux/slab.h> | 57 | #include <linux/slab.h> |
58 | #include <linux/jiffies.h> | 58 | #include <linux/jiffies.h> |
59 | #include <linux/i2c.h> | 59 | #include <linux/i2c.h> |
60 | #include <linux/i2c-sensor.h> | 60 | #include <linux/hwmon.h> |
61 | #include <linux/i2c-vid.h> | 61 | #include <linux/hwmon-vid.h> |
62 | #include <linux/err.h> | ||
62 | 63 | ||
63 | /* | 64 | /* |
64 | * Addresses to scan | 65 | * Addresses to scan |
@@ -66,13 +67,12 @@ | |||
66 | */ | 67 | */ |
67 | 68 | ||
68 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 69 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
69 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
70 | 70 | ||
71 | /* | 71 | /* |
72 | * Insmod parameters | 72 | * Insmod parameters |
73 | */ | 73 | */ |
74 | 74 | ||
75 | SENSORS_INSMOD_1(lm87); | 75 | I2C_CLIENT_INSMOD_1(lm87); |
76 | 76 | ||
77 | /* | 77 | /* |
78 | * The LM87 registers | 78 | * The LM87 registers |
@@ -175,6 +175,7 @@ static struct i2c_driver lm87_driver = { | |||
175 | 175 | ||
176 | struct lm87_data { | 176 | struct lm87_data { |
177 | struct i2c_client client; | 177 | struct i2c_client client; |
178 | struct class_device *class_dev; | ||
178 | struct semaphore update_lock; | 179 | struct semaphore update_lock; |
179 | char valid; /* zero until following fields are valid */ | 180 | char valid; /* zero until following fields are valid */ |
180 | unsigned long last_updated; /* In jiffies */ | 181 | unsigned long last_updated; /* In jiffies */ |
@@ -537,7 +538,7 @@ static int lm87_attach_adapter(struct i2c_adapter *adapter) | |||
537 | { | 538 | { |
538 | if (!(adapter->class & I2C_CLASS_HWMON)) | 539 | if (!(adapter->class & I2C_CLASS_HWMON)) |
539 | return 0; | 540 | return 0; |
540 | return i2c_detect(adapter, &addr_data, lm87_detect); | 541 | return i2c_probe(adapter, &addr_data, lm87_detect); |
541 | } | 542 | } |
542 | 543 | ||
543 | /* | 544 | /* |
@@ -608,6 +609,12 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
608 | data->in_scale[7] = 1875; | 609 | data->in_scale[7] = 1875; |
609 | 610 | ||
610 | /* Register sysfs hooks */ | 611 | /* Register sysfs hooks */ |
612 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
613 | if (IS_ERR(data->class_dev)) { | ||
614 | err = PTR_ERR(data->class_dev); | ||
615 | goto exit_detach; | ||
616 | } | ||
617 | |||
611 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 618 | device_create_file(&new_client->dev, &dev_attr_in1_input); |
612 | device_create_file(&new_client->dev, &dev_attr_in1_min); | 619 | device_create_file(&new_client->dev, &dev_attr_in1_min); |
613 | device_create_file(&new_client->dev, &dev_attr_in1_max); | 620 | device_create_file(&new_client->dev, &dev_attr_in1_max); |
@@ -673,6 +680,8 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
673 | 680 | ||
674 | return 0; | 681 | return 0; |
675 | 682 | ||
683 | exit_detach: | ||
684 | i2c_detach_client(new_client); | ||
676 | exit_free: | 685 | exit_free: |
677 | kfree(data); | 686 | kfree(data); |
678 | exit: | 687 | exit: |
@@ -685,7 +694,7 @@ static void lm87_init_client(struct i2c_client *client) | |||
685 | u8 config; | 694 | u8 config; |
686 | 695 | ||
687 | data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE); | 696 | data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE); |
688 | data->vrm = i2c_which_vrm(); | 697 | data->vrm = vid_which_vrm(); |
689 | 698 | ||
690 | config = lm87_read_value(client, LM87_REG_CONFIG); | 699 | config = lm87_read_value(client, LM87_REG_CONFIG); |
691 | if (!(config & 0x01)) { | 700 | if (!(config & 0x01)) { |
@@ -719,15 +728,15 @@ static void lm87_init_client(struct i2c_client *client) | |||
719 | 728 | ||
720 | static int lm87_detach_client(struct i2c_client *client) | 729 | static int lm87_detach_client(struct i2c_client *client) |
721 | { | 730 | { |
731 | struct lm87_data *data = i2c_get_clientdata(client); | ||
722 | int err; | 732 | int err; |
723 | 733 | ||
724 | if ((err = i2c_detach_client(client))) { | 734 | hwmon_device_unregister(data->class_dev); |
725 | dev_err(&client->dev, "Client deregistration failed, " | 735 | |
726 | "client not detached.\n"); | 736 | if ((err = i2c_detach_client(client))) |
727 | return err; | 737 | return err; |
728 | } | ||
729 | 738 | ||
730 | kfree(i2c_get_clientdata(client)); | 739 | kfree(data); |
731 | return 0; | 740 | return 0; |
732 | } | 741 | } |
733 | 742 | ||