diff options
Diffstat (limited to 'drivers/hwmon/gl520sm.c')
-rw-r--r-- | drivers/hwmon/gl520sm.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 80ae8d30c2af..ce482e17e03c 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/i2c-sensor.h> | 29 | #include <linux/i2c-sensor.h> |
30 | #include <linux/i2c-vid.h> | 30 | #include <linux/i2c-vid.h> |
31 | #include <linux/hwmon.h> | ||
32 | #include <linux/err.h> | ||
31 | 33 | ||
32 | /* Type of the extra sensor */ | 34 | /* Type of the extra sensor */ |
33 | static unsigned short extra_sensor_type; | 35 | static unsigned short extra_sensor_type; |
@@ -120,6 +122,7 @@ static struct i2c_driver gl520_driver = { | |||
120 | /* Client data */ | 122 | /* Client data */ |
121 | struct gl520_data { | 123 | struct gl520_data { |
122 | struct i2c_client client; | 124 | struct i2c_client client; |
125 | struct class_device *class_dev; | ||
123 | struct semaphore update_lock; | 126 | struct semaphore update_lock; |
124 | char valid; /* zero until the following fields are valid */ | 127 | char valid; /* zero until the following fields are valid */ |
125 | unsigned long last_updated; /* in jiffies */ | 128 | unsigned long last_updated; /* in jiffies */ |
@@ -571,6 +574,12 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | |||
571 | gl520_init_client(new_client); | 574 | gl520_init_client(new_client); |
572 | 575 | ||
573 | /* Register sysfs hooks */ | 576 | /* Register sysfs hooks */ |
577 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
578 | if (IS_ERR(data->class_dev)) { | ||
579 | err = PTR_ERR(data->class_dev); | ||
580 | goto exit_detach; | ||
581 | } | ||
582 | |||
574 | device_create_file_vid(new_client, 0); | 583 | device_create_file_vid(new_client, 0); |
575 | 584 | ||
576 | device_create_file_in(new_client, 0); | 585 | device_create_file_in(new_client, 0); |
@@ -592,6 +601,8 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | |||
592 | 601 | ||
593 | return 0; | 602 | return 0; |
594 | 603 | ||
604 | exit_detach: | ||
605 | i2c_detach_client(new_client); | ||
595 | exit_free: | 606 | exit_free: |
596 | kfree(data); | 607 | kfree(data); |
597 | exit: | 608 | exit: |
@@ -639,15 +650,18 @@ static void gl520_init_client(struct i2c_client *client) | |||
639 | 650 | ||
640 | static int gl520_detach_client(struct i2c_client *client) | 651 | static int gl520_detach_client(struct i2c_client *client) |
641 | { | 652 | { |
653 | struct gl520_data *data = i2c_get_clientdata(client); | ||
642 | int err; | 654 | int err; |
643 | 655 | ||
656 | hwmon_device_unregister(data->class_dev); | ||
657 | |||
644 | if ((err = i2c_detach_client(client))) { | 658 | if ((err = i2c_detach_client(client))) { |
645 | dev_err(&client->dev, "Client deregistration failed, " | 659 | dev_err(&client->dev, "Client deregistration failed, " |
646 | "client not detached.\n"); | 660 | "client not detached.\n"); |
647 | return err; | 661 | return err; |
648 | } | 662 | } |
649 | 663 | ||
650 | kfree(i2c_get_clientdata(client)); | 664 | kfree(data); |
651 | return 0; | 665 | return 0; |
652 | } | 666 | } |
653 | 667 | ||