diff options
author | Milo(Woogyom) Kim <milo.kim@ti.com> | 2013-02-05 05:11:18 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-02-06 18:59:28 -0500 |
commit | c3a68ebfcd22abc186f2328149732c801449b297 (patch) | |
tree | 253db155491541accda86b0900dce9856213a9ab | |
parent | a96bfa135ddc8045166fc6311ce4d21bfcb8d13d (diff) |
leds-lp55xx: use lp55xx_unregister_leds()
To unregister led class devices and sysfs attributes,
LP5521 and LP5523 have each driver function.
This patch makes both drivers simple using common driver function,
lp55xx_unregister_leds().
And some unused variables are removed.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
-rw-r--r-- | drivers/leds/leds-lp5521.c | 24 | ||||
-rw-r--r-- | drivers/leds/leds-lp5523.c | 25 | ||||
-rw-r--r-- | drivers/leds/leds-lp55xx-common.c | 16 | ||||
-rw-r--r-- | drivers/leds/leds-lp55xx-common.h | 2 |
4 files changed, 22 insertions, 45 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 7133af824b5e..cec252eae716 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -567,9 +567,6 @@ static ssize_t store_led_pattern(struct device *dev, | |||
567 | return len; | 567 | return len; |
568 | } | 568 | } |
569 | 569 | ||
570 | static struct attribute_group lp5521_led_attribute_group = { | ||
571 | }; | ||
572 | |||
573 | /* device attributes */ | 570 | /* device attributes */ |
574 | static DEVICE_ATTR(engine1_mode, S_IRUGO | S_IWUSR, | 571 | static DEVICE_ATTR(engine1_mode, S_IRUGO | S_IWUSR, |
575 | show_engine1_mode, store_engine1_mode); | 572 | show_engine1_mode, store_engine1_mode); |
@@ -607,25 +604,9 @@ static int lp5521_register_sysfs(struct i2c_client *client) | |||
607 | 604 | ||
608 | static void lp5521_unregister_sysfs(struct i2c_client *client) | 605 | static void lp5521_unregister_sysfs(struct i2c_client *client) |
609 | { | 606 | { |
610 | struct lp5521_chip *chip = i2c_get_clientdata(client); | ||
611 | struct device *dev = &client->dev; | 607 | struct device *dev = &client->dev; |
612 | int i; | ||
613 | 608 | ||
614 | sysfs_remove_group(&dev->kobj, &lp5521_group); | 609 | sysfs_remove_group(&dev->kobj, &lp5521_group); |
615 | |||
616 | for (i = 0; i < chip->num_leds; i++) | ||
617 | sysfs_remove_group(&chip->leds[i].cdev.dev->kobj, | ||
618 | &lp5521_led_attribute_group); | ||
619 | } | ||
620 | |||
621 | static void lp5521_unregister_leds(struct lp5521_chip *chip) | ||
622 | { | ||
623 | int i; | ||
624 | |||
625 | for (i = 0; i < chip->num_leds; i++) { | ||
626 | led_classdev_unregister(&chip->leds[i].cdev); | ||
627 | cancel_work_sync(&chip->leds[i].brightness_work); | ||
628 | } | ||
629 | } | 610 | } |
630 | 611 | ||
631 | /* Chip specific configurations */ | 612 | /* Chip specific configurations */ |
@@ -647,7 +628,6 @@ static struct lp55xx_device_config lp5521_cfg = { | |||
647 | static int lp5521_probe(struct i2c_client *client, | 628 | static int lp5521_probe(struct i2c_client *client, |
648 | const struct i2c_device_id *id) | 629 | const struct i2c_device_id *id) |
649 | { | 630 | { |
650 | struct lp5521_chip *old_chip = NULL; | ||
651 | int ret; | 631 | int ret; |
652 | struct lp55xx_chip *chip; | 632 | struct lp55xx_chip *chip; |
653 | struct lp55xx_led *led; | 633 | struct lp55xx_led *led; |
@@ -692,7 +672,7 @@ static int lp5521_probe(struct i2c_client *client, | |||
692 | } | 672 | } |
693 | return ret; | 673 | return ret; |
694 | fail2: | 674 | fail2: |
695 | lp5521_unregister_leds(old_chip); | 675 | lp55xx_unregister_leds(led, chip); |
696 | err_register_leds: | 676 | err_register_leds: |
697 | lp55xx_deinit_device(chip); | 677 | lp55xx_deinit_device(chip); |
698 | err_init: | 678 | err_init: |
@@ -708,7 +688,7 @@ static int lp5521_remove(struct i2c_client *client) | |||
708 | lp5521_run_led_pattern(PATTERN_OFF, old_chip); | 688 | lp5521_run_led_pattern(PATTERN_OFF, old_chip); |
709 | lp5521_unregister_sysfs(client); | 689 | lp5521_unregister_sysfs(client); |
710 | 690 | ||
711 | lp5521_unregister_leds(old_chip); | 691 | lp55xx_unregister_leds(led, chip); |
712 | lp55xx_deinit_device(chip); | 692 | lp55xx_deinit_device(chip); |
713 | 693 | ||
714 | return 0; | 694 | return 0; |
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index dfb335420568..70630156eff9 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c | |||
@@ -609,9 +609,6 @@ store_mode(1) | |||
609 | store_mode(2) | 609 | store_mode(2) |
610 | store_mode(3) | 610 | store_mode(3) |
611 | 611 | ||
612 | static struct attribute_group lp5523_led_attribute_group = { | ||
613 | }; | ||
614 | |||
615 | /* device attributes */ | 612 | /* device attributes */ |
616 | static DEVICE_ATTR(engine1_mode, S_IRUGO | S_IWUSR, | 613 | static DEVICE_ATTR(engine1_mode, S_IRUGO | S_IWUSR, |
617 | show_engine1_mode, store_engine1_mode); | 614 | show_engine1_mode, store_engine1_mode); |
@@ -662,15 +659,9 @@ static int lp5523_register_sysfs(struct i2c_client *client) | |||
662 | 659 | ||
663 | static void lp5523_unregister_sysfs(struct i2c_client *client) | 660 | static void lp5523_unregister_sysfs(struct i2c_client *client) |
664 | { | 661 | { |
665 | struct lp5523_chip *chip = i2c_get_clientdata(client); | ||
666 | struct device *dev = &client->dev; | 662 | struct device *dev = &client->dev; |
667 | int i; | ||
668 | 663 | ||
669 | sysfs_remove_group(&dev->kobj, &lp5523_group); | 664 | sysfs_remove_group(&dev->kobj, &lp5523_group); |
670 | |||
671 | for (i = 0; i < chip->num_leds; i++) | ||
672 | sysfs_remove_group(&chip->leds[i].cdev.dev->kobj, | ||
673 | &lp5523_led_attribute_group); | ||
674 | } | 665 | } |
675 | 666 | ||
676 | /*--------------------------------------------------------------*/ | 667 | /*--------------------------------------------------------------*/ |
@@ -703,16 +694,6 @@ static void lp5523_set_mode(struct lp5523_engine *engine, u8 mode) | |||
703 | /*--------------------------------------------------------------*/ | 694 | /*--------------------------------------------------------------*/ |
704 | /* Probe, Attach, Remove */ | 695 | /* Probe, Attach, Remove */ |
705 | /*--------------------------------------------------------------*/ | 696 | /*--------------------------------------------------------------*/ |
706 | static void lp5523_unregister_leds(struct lp5523_chip *chip) | ||
707 | { | ||
708 | int i; | ||
709 | |||
710 | for (i = 0; i < chip->num_leds; i++) { | ||
711 | led_classdev_unregister(&chip->leds[i].cdev); | ||
712 | flush_work(&chip->leds[i].brightness_work); | ||
713 | } | ||
714 | } | ||
715 | |||
716 | /* Chip specific configurations */ | 697 | /* Chip specific configurations */ |
717 | static struct lp55xx_device_config lp5523_cfg = { | 698 | static struct lp55xx_device_config lp5523_cfg = { |
718 | .reset = { | 699 | .reset = { |
@@ -732,7 +713,6 @@ static struct lp55xx_device_config lp5523_cfg = { | |||
732 | static int lp5523_probe(struct i2c_client *client, | 713 | static int lp5523_probe(struct i2c_client *client, |
733 | const struct i2c_device_id *id) | 714 | const struct i2c_device_id *id) |
734 | { | 715 | { |
735 | struct lp5523_chip *old_chip = NULL; | ||
736 | int ret; | 716 | int ret; |
737 | struct lp55xx_chip *chip; | 717 | struct lp55xx_chip *chip; |
738 | struct lp55xx_led *led; | 718 | struct lp55xx_led *led; |
@@ -777,7 +757,7 @@ static int lp5523_probe(struct i2c_client *client, | |||
777 | } | 757 | } |
778 | return ret; | 758 | return ret; |
779 | fail2: | 759 | fail2: |
780 | lp5523_unregister_leds(old_chip); | 760 | lp55xx_unregister_leds(led, chip); |
781 | err_register_leds: | 761 | err_register_leds: |
782 | lp55xx_deinit_device(chip); | 762 | lp55xx_deinit_device(chip); |
783 | err_init: | 763 | err_init: |
@@ -786,7 +766,6 @@ err_init: | |||
786 | 766 | ||
787 | static int lp5523_remove(struct i2c_client *client) | 767 | static int lp5523_remove(struct i2c_client *client) |
788 | { | 768 | { |
789 | struct lp5523_chip *old_chip = i2c_get_clientdata(client); | ||
790 | struct lp55xx_led *led = i2c_get_clientdata(client); | 769 | struct lp55xx_led *led = i2c_get_clientdata(client); |
791 | struct lp55xx_chip *chip = led->chip; | 770 | struct lp55xx_chip *chip = led->chip; |
792 | 771 | ||
@@ -795,7 +774,7 @@ static int lp5523_remove(struct i2c_client *client) | |||
795 | 774 | ||
796 | lp5523_unregister_sysfs(client); | 775 | lp5523_unregister_sysfs(client); |
797 | 776 | ||
798 | lp5523_unregister_leds(old_chip); | 777 | lp55xx_unregister_leds(led, chip); |
799 | lp55xx_deinit_device(chip); | 778 | lp55xx_deinit_device(chip); |
800 | 779 | ||
801 | return 0; | 780 | return 0; |
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 6b3d03709f5f..dcd64f5285e8 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c | |||
@@ -353,6 +353,22 @@ err_init_led: | |||
353 | } | 353 | } |
354 | EXPORT_SYMBOL_GPL(lp55xx_register_leds); | 354 | EXPORT_SYMBOL_GPL(lp55xx_register_leds); |
355 | 355 | ||
356 | void lp55xx_unregister_leds(struct lp55xx_led *led, struct lp55xx_chip *chip) | ||
357 | { | ||
358 | int i; | ||
359 | struct lp55xx_led *each; | ||
360 | struct kobject *kobj; | ||
361 | |||
362 | for (i = 0; i < chip->num_leds; i++) { | ||
363 | each = led + i; | ||
364 | kobj = &led->cdev.dev->kobj; | ||
365 | sysfs_remove_group(kobj, &lp55xx_led_attr_group); | ||
366 | led_classdev_unregister(&each->cdev); | ||
367 | flush_work(&each->brightness_work); | ||
368 | } | ||
369 | } | ||
370 | EXPORT_SYMBOL_GPL(lp55xx_unregister_leds); | ||
371 | |||
356 | MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>"); | 372 | MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>"); |
357 | MODULE_DESCRIPTION("LP55xx Common Driver"); | 373 | MODULE_DESCRIPTION("LP55xx Common Driver"); |
358 | MODULE_LICENSE("GPL"); | 374 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h index 70d2bdf54b8e..32d96828cbc6 100644 --- a/drivers/leds/leds-lp55xx-common.h +++ b/drivers/leds/leds-lp55xx-common.h | |||
@@ -101,4 +101,6 @@ extern void lp55xx_deinit_device(struct lp55xx_chip *chip); | |||
101 | /* common LED class device functions */ | 101 | /* common LED class device functions */ |
102 | extern int lp55xx_register_leds(struct lp55xx_led *led, | 102 | extern int lp55xx_register_leds(struct lp55xx_led *led, |
103 | struct lp55xx_chip *chip); | 103 | struct lp55xx_chip *chip); |
104 | extern void lp55xx_unregister_leds(struct lp55xx_led *led, | ||
105 | struct lp55xx_chip *chip); | ||
104 | #endif /* _LEDS_LP55XX_COMMON_H */ | 106 | #endif /* _LEDS_LP55XX_COMMON_H */ |