diff options
Diffstat (limited to 'drivers/hwmon/gl520sm.c')
-rw-r--r-- | drivers/hwmon/gl520sm.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 80ae8d30c2af..12fd757066fc 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c | |||
@@ -26,8 +26,9 @@ | |||
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/jiffies.h> | 27 | #include <linux/jiffies.h> |
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/i2c-sensor.h> | 29 | #include <linux/hwmon.h> |
30 | #include <linux/i2c-vid.h> | 30 | #include <linux/hwmon-vid.h> |
31 | #include <linux/err.h> | ||
31 | 32 | ||
32 | /* Type of the extra sensor */ | 33 | /* Type of the extra sensor */ |
33 | static unsigned short extra_sensor_type; | 34 | static unsigned short extra_sensor_type; |
@@ -36,10 +37,9 @@ MODULE_PARM_DESC(extra_sensor_type, "Type of extra sensor (0=autodetect, 1=tempe | |||
36 | 37 | ||
37 | /* Addresses to scan */ | 38 | /* Addresses to scan */ |
38 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; | 39 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; |
39 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
40 | 40 | ||
41 | /* Insmod parameters */ | 41 | /* Insmod parameters */ |
42 | SENSORS_INSMOD_1(gl520sm); | 42 | I2C_CLIENT_INSMOD_1(gl520sm); |
43 | 43 | ||
44 | /* Many GL520 constants specified below | 44 | /* Many GL520 constants specified below |
45 | One of the inputs can be configured as either temp or voltage. | 45 | One of the inputs can be configured as either temp or voltage. |
@@ -120,6 +120,7 @@ static struct i2c_driver gl520_driver = { | |||
120 | /* Client data */ | 120 | /* Client data */ |
121 | struct gl520_data { | 121 | struct gl520_data { |
122 | struct i2c_client client; | 122 | struct i2c_client client; |
123 | struct class_device *class_dev; | ||
123 | struct semaphore update_lock; | 124 | struct semaphore update_lock; |
124 | char valid; /* zero until the following fields are valid */ | 125 | char valid; /* zero until the following fields are valid */ |
125 | unsigned long last_updated; /* in jiffies */ | 126 | unsigned long last_updated; /* in jiffies */ |
@@ -518,7 +519,7 @@ static int gl520_attach_adapter(struct i2c_adapter *adapter) | |||
518 | { | 519 | { |
519 | if (!(adapter->class & I2C_CLASS_HWMON)) | 520 | if (!(adapter->class & I2C_CLASS_HWMON)) |
520 | return 0; | 521 | return 0; |
521 | return i2c_detect(adapter, &addr_data, gl520_detect); | 522 | return i2c_probe(adapter, &addr_data, gl520_detect); |
522 | } | 523 | } |
523 | 524 | ||
524 | static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | 525 | static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) |
@@ -571,6 +572,12 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | |||
571 | gl520_init_client(new_client); | 572 | gl520_init_client(new_client); |
572 | 573 | ||
573 | /* Register sysfs hooks */ | 574 | /* Register sysfs hooks */ |
575 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
576 | if (IS_ERR(data->class_dev)) { | ||
577 | err = PTR_ERR(data->class_dev); | ||
578 | goto exit_detach; | ||
579 | } | ||
580 | |||
574 | device_create_file_vid(new_client, 0); | 581 | device_create_file_vid(new_client, 0); |
575 | 582 | ||
576 | device_create_file_in(new_client, 0); | 583 | device_create_file_in(new_client, 0); |
@@ -592,6 +599,8 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | |||
592 | 599 | ||
593 | return 0; | 600 | return 0; |
594 | 601 | ||
602 | exit_detach: | ||
603 | i2c_detach_client(new_client); | ||
595 | exit_free: | 604 | exit_free: |
596 | kfree(data); | 605 | kfree(data); |
597 | exit: | 606 | exit: |
@@ -608,7 +617,7 @@ static void gl520_init_client(struct i2c_client *client) | |||
608 | conf = oldconf = gl520_read_value(client, GL520_REG_CONF); | 617 | conf = oldconf = gl520_read_value(client, GL520_REG_CONF); |
609 | 618 | ||
610 | data->alarm_mask = 0xff; | 619 | data->alarm_mask = 0xff; |
611 | data->vrm = i2c_which_vrm(); | 620 | data->vrm = vid_which_vrm(); |
612 | 621 | ||
613 | if (extra_sensor_type == 1) | 622 | if (extra_sensor_type == 1) |
614 | conf &= ~0x10; | 623 | conf &= ~0x10; |
@@ -639,15 +648,15 @@ static void gl520_init_client(struct i2c_client *client) | |||
639 | 648 | ||
640 | static int gl520_detach_client(struct i2c_client *client) | 649 | static int gl520_detach_client(struct i2c_client *client) |
641 | { | 650 | { |
651 | struct gl520_data *data = i2c_get_clientdata(client); | ||
642 | int err; | 652 | int err; |
643 | 653 | ||
644 | if ((err = i2c_detach_client(client))) { | 654 | hwmon_device_unregister(data->class_dev); |
645 | dev_err(&client->dev, "Client deregistration failed, " | 655 | |
646 | "client not detached.\n"); | 656 | if ((err = i2c_detach_client(client))) |
647 | return err; | 657 | return err; |
648 | } | ||
649 | 658 | ||
650 | kfree(i2c_get_clientdata(client)); | 659 | kfree(data); |
651 | return 0; | 660 | return 0; |
652 | } | 661 | } |
653 | 662 | ||