aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5521.c
diff options
context:
space:
mode:
authorMilo(Woogyom) Kim <milo.kim@ti.com>2013-02-05 05:06:27 -0500
committerBryan Wu <cooloney@gmail.com>2013-02-06 18:59:28 -0500
commit9e9b3db1b2f725bacaf1b7e8708a0c78265bde97 (patch)
tree498353c79883feb33c7ea93dda7742eb7c1b7dcc /drivers/leds/leds-lp5521.c
parent6ce6176263393dd80b9a537c1e1462b8529f240b (diff)
leds-lp55xx: use lp55xx common led registration function
LED class devices are registered in lp5521_register_leds() and lp5523_register_leds(). Two separate functions are merged into consolidated lp55xx function, lp55xx_register_leds(). Error handling fix: Unregistering LEDS are handled in lp55xx_register_leds() when LED registration failure occurs. So each driver error handler is changed to 'err_register_leds' Chip dependency: 'brightness_work_fn' and 'set_led_current' To make the structure abstract, both functions are configured in each driver. Those functions should be done by each driver because register control is chip-dependant work. lp55xx_init_led: skeleton Will be filled in next patch Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds/leds-lp5521.c')
-rw-r--r--drivers/leds/leds-lp5521.c43
1 files changed, 3 insertions, 40 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index dd4526e168fa..dc58f4106d09 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -738,44 +738,6 @@ static int lp5521_init_led(struct lp5521_led *led,
738 return 0; 738 return 0;
739} 739}
740 740
741static int lp5521_register_leds(struct lp5521_chip *chip)
742{
743 struct lp5521_platform_data *pdata = chip->pdata;
744 struct i2c_client *client = chip->client;
745 int i;
746 int led;
747 int ret;
748
749 /* Initialize leds */
750 chip->num_channels = pdata->num_channels;
751 chip->num_leds = 0;
752 led = 0;
753 for (i = 0; i < pdata->num_channels; i++) {
754 /* Do not initialize channels that are not connected */
755 if (pdata->led_config[i].led_current == 0)
756 continue;
757
758 ret = lp5521_init_led(&chip->leds[led], client, i, pdata);
759 if (ret) {
760 dev_err(&client->dev, "error initializing leds\n");
761 return ret;
762 }
763 chip->num_leds++;
764
765 chip->leds[led].id = led;
766 /* Set initial LED current */
767 lp5521_set_led_current(chip, led,
768 chip->leds[led].led_current);
769
770 INIT_WORK(&(chip->leds[led].brightness_work),
771 lp5521_led_brightness_work);
772
773 led++;
774 }
775
776 return 0;
777}
778
779static void lp5521_unregister_leds(struct lp5521_chip *chip) 741static void lp5521_unregister_leds(struct lp5521_chip *chip)
780{ 742{
781 int i; 743 int i;
@@ -836,9 +798,9 @@ static int lp5521_probe(struct i2c_client *client,
836 798
837 dev_info(&client->dev, "%s programmable led chip found\n", id->name); 799 dev_info(&client->dev, "%s programmable led chip found\n", id->name);
838 800
839 ret = lp5521_register_leds(old_chip); 801 ret = lp55xx_register_leds(led, chip);
840 if (ret) 802 if (ret)
841 goto fail2; 803 goto err_register_leds;
842 804
843 ret = lp5521_register_sysfs(client); 805 ret = lp5521_register_sysfs(client);
844 if (ret) { 806 if (ret) {
@@ -848,6 +810,7 @@ static int lp5521_probe(struct i2c_client *client,
848 return ret; 810 return ret;
849fail2: 811fail2:
850 lp5521_unregister_leds(old_chip); 812 lp5521_unregister_leds(old_chip);
813err_register_leds:
851 lp55xx_deinit_device(chip); 814 lp55xx_deinit_device(chip);
852err_init: 815err_init:
853 return ret; 816 return ret;