summaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5523.c
diff options
context:
space:
mode:
authorMilo(Woogyom) Kim <milo.kim@ti.com>2013-02-05 11:06:27 +0100
committerBryan Wu <cooloney@gmail.com>2013-02-07 00:59:28 +0100
commit9e9b3db1b2f725bacaf1b7e8708a0c78265bde97 (patch)
tree498353c79883feb33c7ea93dda7742eb7c1b7dcc /drivers/leds/leds-lp5523.c
parentleds-lp55xx: use lp55xx common deinit function (diff)
downloadlinux-9e9b3db1b2f725bacaf1b7e8708a0c78265bde97.tar.xz
linux-9e9b3db1b2f725bacaf1b7e8708a0c78265bde97.zip
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,
return 0;
}
-static int lp5523_register_leds(struct lp5523_chip *chip, const char *name)
-{
- struct lp5523_platform_data *pdata = chip->pdata;
- struct i2c_client *client = chip->client;
- int i;
- int led;
- int ret;
-
- /* Initialize leds */
- chip->num_channels = pdata->num_channels;
- chip->num_leds = 0;
- led = 0;
- for (i = 0; i < pdata->num_channels; i++) {
- /* Do not initialize channels that are not connected */
- if (pdata->led_config[i].led_current == 0)
- continue;
-
- INIT_WORK(&chip->leds[led].brightness_work,
- lp5523_led_brightness_work);
-
- ret = lp5523_init_led(&chip->leds[led], &client->dev, i, pdata,
- name);
- if (ret) {
- dev_err(&client->dev, "error initializing leds\n");
- return ret;
- }
- chip->num_leds++;
-
- chip->leds[led].id = led;
- /* Set LED current */
- lp5523_write(client,
- LP5523_REG_LED_CURRENT_BASE + chip->leds[led].chan_nr,
- chip->leds[led].led_current);
-
- led++;
- }
-
- return 0;
-}
-
static void lp5523_unregister_leds(struct lp5523_chip *chip)
{
int i;
@@ -922,9 +882,9 @@ static int lp5523_probe(struct i2c_client *client,
dev_info(&client->dev, "%s Programmable led chip found\n", id->name);
- ret = lp5523_register_leds(old_chip, id->name);
+ ret = lp55xx_register_leds(led, chip);
if (ret)
- goto fail2;
+ goto err_register_leds;
ret = lp5523_register_sysfs(client);
if (ret) {
@@ -934,6 +894,7 @@ static int lp5523_probe(struct i2c_client *client,
return ret;
fail2:
lp5523_unregister_leds(old_chip);
+err_register_leds:
lp55xx_deinit_device(chip);
err_init:
return ret;