aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorMilo(Woogyom) Kim <milo.kim@ti.com>2013-02-05 03:56:23 -0500
committerBryan Wu <cooloney@gmail.com>2013-02-06 18:59:26 -0500
commit1904f83d568dba794be9de1311bafb5a4424812a (patch)
tree31517e43b89b28e0deed39780fa8994d15be752a /drivers/leds
parentf652480802b636f86e194f9680347676b655d856 (diff)
leds-lp55xx: clean up deinit leds in lp5521/5523
To make LED unregistration code simple, new function, _unregister_leds() is added in each driver. This patch is a preceding step for lp55xx common driver architecture. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-lp5521.c23
-rw-r--r--drivers/leds/leds-lp5523.c21
2 files changed, 25 insertions, 19 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index f4cd0fe67fef..ec1ffe6316c1 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -837,12 +837,22 @@ static int lp5521_register_leds(struct lp5521_chip *chip)
837 return 0; 837 return 0;
838} 838}
839 839
840static void lp5521_unregister_leds(struct lp5521_chip *chip)
841{
842 int i;
843
844 for (i = 0; i < chip->num_leds; i++) {
845 led_classdev_unregister(&chip->leds[i].cdev);
846 cancel_work_sync(&chip->leds[i].brightness_work);
847 }
848}
849
840static int lp5521_probe(struct i2c_client *client, 850static int lp5521_probe(struct i2c_client *client,
841 const struct i2c_device_id *id) 851 const struct i2c_device_id *id)
842{ 852{
843 struct lp5521_chip *chip; 853 struct lp5521_chip *chip;
844 struct lp5521_platform_data *pdata; 854 struct lp5521_platform_data *pdata;
845 int ret, i; 855 int ret;
846 856
847 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); 857 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
848 if (!chip) 858 if (!chip)
@@ -885,10 +895,7 @@ static int lp5521_probe(struct i2c_client *client,
885 } 895 }
886 return ret; 896 return ret;
887fail2: 897fail2:
888 for (i = 0; i < chip->num_leds; i++) { 898 lp5521_unregister_leds(chip);
889 led_classdev_unregister(&chip->leds[i].cdev);
890 cancel_work_sync(&chip->leds[i].brightness_work);
891 }
892fail1: 899fail1:
893 lp5521_deinit_device(chip); 900 lp5521_deinit_device(chip);
894 return ret; 901 return ret;
@@ -897,15 +904,11 @@ fail1:
897static int lp5521_remove(struct i2c_client *client) 904static int lp5521_remove(struct i2c_client *client)
898{ 905{
899 struct lp5521_chip *chip = i2c_get_clientdata(client); 906 struct lp5521_chip *chip = i2c_get_clientdata(client);
900 int i;
901 907
902 lp5521_run_led_pattern(PATTERN_OFF, chip); 908 lp5521_run_led_pattern(PATTERN_OFF, chip);
903 lp5521_unregister_sysfs(client); 909 lp5521_unregister_sysfs(client);
904 910
905 for (i = 0; i < chip->num_leds; i++) { 911 lp5521_unregister_leds(chip);
906 led_classdev_unregister(&chip->leds[i].cdev);
907 cancel_work_sync(&chip->leds[i].brightness_work);
908 }
909 912
910 lp5521_deinit_device(chip); 913 lp5521_deinit_device(chip);
911 return 0; 914 return 0;
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index f5e893289816..2fc19bbddb72 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -936,6 +936,16 @@ static int lp5523_register_leds(struct lp5523_chip *chip, const char *name)
936 return 0; 936 return 0;
937} 937}
938 938
939static void lp5523_unregister_leds(struct lp5523_chip *chip)
940{
941 int i;
942
943 for (i = 0; i < chip->num_leds; i++) {
944 led_classdev_unregister(&chip->leds[i].cdev);
945 flush_work(&chip->leds[i].brightness_work);
946 }
947}
948
939static int lp5523_init_device(struct lp5523_chip *chip) 949static int lp5523_init_device(struct lp5523_chip *chip)
940{ 950{
941 struct lp5523_platform_data *pdata = chip->pdata; 951 struct lp5523_platform_data *pdata = chip->pdata;
@@ -1029,10 +1039,7 @@ static int lp5523_probe(struct i2c_client *client,
1029 } 1039 }
1030 return ret; 1040 return ret;
1031fail2: 1041fail2:
1032 for (i = 0; i < chip->num_leds; i++) { 1042 lp5523_unregister_leds(chip);
1033 led_classdev_unregister(&chip->leds[i].cdev);
1034 flush_work(&chip->leds[i].brightness_work);
1035 }
1036fail1: 1043fail1:
1037 lp5523_deinit_device(chip); 1044 lp5523_deinit_device(chip);
1038 return ret; 1045 return ret;
@@ -1041,17 +1048,13 @@ fail1:
1041static int lp5523_remove(struct i2c_client *client) 1048static int lp5523_remove(struct i2c_client *client)
1042{ 1049{
1043 struct lp5523_chip *chip = i2c_get_clientdata(client); 1050 struct lp5523_chip *chip = i2c_get_clientdata(client);
1044 int i;
1045 1051
1046 /* Disable engine mode */ 1052 /* Disable engine mode */
1047 lp5523_write(client, LP5523_REG_OP_MODE, LP5523_CMD_DISABLED); 1053 lp5523_write(client, LP5523_REG_OP_MODE, LP5523_CMD_DISABLED);
1048 1054
1049 lp5523_unregister_sysfs(client); 1055 lp5523_unregister_sysfs(client);
1050 1056
1051 for (i = 0; i < chip->num_leds; i++) { 1057 lp5523_unregister_leds(chip);
1052 led_classdev_unregister(&chip->leds[i].cdev);
1053 flush_work(&chip->leds[i].brightness_work);
1054 }
1055 1058
1056 lp5523_deinit_device(chip); 1059 lp5523_deinit_device(chip);
1057 return 0; 1060 return 0;