aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5523.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-lp5523.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-lp5523.c')
-rw-r--r--drivers/leds/leds-lp5523.c45
1 files changed, 3 insertions, 42 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 3f506e3d4986..41ac502ff82f 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -822,46 +822,6 @@ static int lp5523_init_led(struct lp5523_led *led, struct device *dev,
822 return 0; 822 return 0;
823} 823}
824 824
825static int lp5523_register_leds(struct lp5523_chip *chip, const char *name)
826{
827 struct lp5523_platform_data *pdata = chip->pdata;
828 struct i2c_client *client = chip->client;
829 int i;
830 int led;
831 int ret;
832
833 /* Initialize leds */
834 chip->num_channels = pdata->num_channels;
835 chip->num_leds = 0;
836 led = 0;
837 for (i = 0; i < pdata->num_channels; i++) {
838 /* Do not initialize channels that are not connected */
839 if (pdata->led_config[i].led_current == 0)
840 continue;
841
842 INIT_WORK(&chip->leds[led].brightness_work,
843 lp5523_led_brightness_work);
844
845 ret = lp5523_init_led(&chip->leds[led], &client->dev, i, pdata,
846 name);
847 if (ret) {
848 dev_err(&client->dev, "error initializing leds\n");
849 return ret;
850 }
851 chip->num_leds++;
852
853 chip->leds[led].id = led;
854 /* Set LED current */
855 lp5523_write(client,
856 LP5523_REG_LED_CURRENT_BASE + chip->leds[led].chan_nr,
857 chip->leds[led].led_current);
858
859 led++;
860 }
861
862 return 0;
863}
864
865static void lp5523_unregister_leds(struct lp5523_chip *chip) 825static void lp5523_unregister_leds(struct lp5523_chip *chip)
866{ 826{
867 int i; 827 int i;
@@ -922,9 +882,9 @@ static int lp5523_probe(struct i2c_client *client,
922 882
923 dev_info(&client->dev, "%s Programmable led chip found\n", id->name); 883 dev_info(&client->dev, "%s Programmable led chip found\n", id->name);
924 884
925 ret = lp5523_register_leds(old_chip, id->name); 885 ret = lp55xx_register_leds(led, chip);
926 if (ret) 886 if (ret)
927 goto fail2; 887 goto err_register_leds;
928 888
929 ret = lp5523_register_sysfs(client); 889 ret = lp5523_register_sysfs(client);
930 if (ret) { 890 if (ret) {
@@ -934,6 +894,7 @@ static int lp5523_probe(struct i2c_client *client,
934 return ret; 894 return ret;
935fail2: 895fail2:
936 lp5523_unregister_leds(old_chip); 896 lp5523_unregister_leds(old_chip);
897err_register_leds:
937 lp55xx_deinit_device(chip); 898 lp55xx_deinit_device(chip);
938err_init: 899err_init:
939 return ret; 900 return ret;