summaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5521.c
diff options
context:
space:
mode:
authorMilo(Woogyom) Kim <milo.kim@ti.com>2013-02-05 17:58:01 +0900
committerBryan Wu <cooloney@gmail.com>2013-02-06 15:59:26 -0800
commitf6c64c6fc8d793b414446f1a655a37b7bfce68e3 (patch)
tree4190d716484d160738eecddf33e98aa162bc5f1b /drivers/leds/leds-lp5521.c
parent86eb7748cef00faa3eaefc8fc450ed30281a09e7 (diff)
downloadblackbird-op-linux-f6c64c6fc8d793b414446f1a655a37b7bfce68e3.tar.gz
blackbird-op-linux-f6c64c6fc8d793b414446f1a655a37b7bfce68e3.zip
leds-lp55xx: do chip specific configuration on device init
Chip specific function is configured when the device is initialized. So _configure() is moved to each device init function. If chip configuration gets failed, the device is de-initialized in each _init_device(), not probe(). For compile error fix, function type declarations are added. 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.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index ec89ed641005..e042a094a07f 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -694,6 +694,7 @@ static void lp5521_reset_device(struct lp5521_chip *chip)
lp5521_write(client, LP5521_REG_RESET, 0xff);
}
+static void lp5521_deinit_device(struct lp5521_chip *chip);
static int lp5521_init_device(struct lp5521_chip *chip)
{
struct lp5521_platform_data *pdata = chip->pdata;
@@ -742,9 +743,22 @@ static int lp5521_init_device(struct lp5521_chip *chip)
usleep_range(10000, 20000);
ret = lp5521_detect(client);
- if (ret)
+ if (ret) {
dev_err(&client->dev, "Chip not found\n");
+ goto err;
+ }
+
+ ret = lp5521_configure(client);
+ if (ret < 0) {
+ dev_err(&client->dev, "error configuring chip\n");
+ goto err_config;
+ }
+ return 0;
+
+err_config:
+ lp5521_deinit_device(chip);
+err:
return ret;
}
@@ -882,16 +896,10 @@ static int lp5521_probe(struct i2c_client *client,
ret = lp5521_init_device(chip);
if (ret)
- goto fail1;
+ goto err_init;
dev_info(&client->dev, "%s programmable led chip found\n", id->name);
- ret = lp5521_configure(client);
- if (ret < 0) {
- dev_err(&client->dev, "error configuring chip\n");
- goto fail1;
- }
-
ret = lp5521_register_leds(chip);
if (ret)
goto fail2;
@@ -904,8 +912,8 @@ static int lp5521_probe(struct i2c_client *client,
return ret;
fail2:
lp5521_unregister_leds(chip);
-fail1:
lp5521_deinit_device(chip);
+err_init:
return ret;
}
OpenPOWER on IntegriCloud