aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5521.c
diff options
context:
space:
mode:
authorMilo(Woogyom) Kim <milo.kim@ti.com>2013-02-05 03:58:01 -0500
committerBryan Wu <cooloney@gmail.com>2013-02-06 18:59:26 -0500
commitf6c64c6fc8d793b414446f1a655a37b7bfce68e3 (patch)
tree4190d716484d160738eecddf33e98aa162bc5f1b /drivers/leds/leds-lp5521.c
parent86eb7748cef00faa3eaefc8fc450ed30281a09e7 (diff)
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)
694 lp5521_write(client, LP5521_REG_RESET, 0xff); 694 lp5521_write(client, LP5521_REG_RESET, 0xff);
695} 695}
696 696
697static void lp5521_deinit_device(struct lp5521_chip *chip);
697static int lp5521_init_device(struct lp5521_chip *chip) 698static int lp5521_init_device(struct lp5521_chip *chip)
698{ 699{
699 struct lp5521_platform_data *pdata = chip->pdata; 700 struct lp5521_platform_data *pdata = chip->pdata;
@@ -742,9 +743,22 @@ static int lp5521_init_device(struct lp5521_chip *chip)
742 usleep_range(10000, 20000); 743 usleep_range(10000, 20000);
743 744
744 ret = lp5521_detect(client); 745 ret = lp5521_detect(client);
745 if (ret) 746 if (ret) {
746 dev_err(&client->dev, "Chip not found\n"); 747 dev_err(&client->dev, "Chip not found\n");
748 goto err;
749 }
750
751 ret = lp5521_configure(client);
752 if (ret < 0) {
753 dev_err(&client->dev, "error configuring chip\n");
754 goto err_config;
755 }
747 756
757 return 0;
758
759err_config:
760 lp5521_deinit_device(chip);
761err:
748 return ret; 762 return ret;
749} 763}
750 764
@@ -882,16 +896,10 @@ static int lp5521_probe(struct i2c_client *client,
882 896
883 ret = lp5521_init_device(chip); 897 ret = lp5521_init_device(chip);
884 if (ret) 898 if (ret)
885 goto fail1; 899 goto err_init;
886 900
887 dev_info(&client->dev, "%s programmable led chip found\n", id->name); 901 dev_info(&client->dev, "%s programmable led chip found\n", id->name);
888 902
889 ret = lp5521_configure(client);
890 if (ret < 0) {
891 dev_err(&client->dev, "error configuring chip\n");
892 goto fail1;
893 }
894
895 ret = lp5521_register_leds(chip); 903 ret = lp5521_register_leds(chip);
896 if (ret) 904 if (ret)
897 goto fail2; 905 goto fail2;
@@ -904,8 +912,8 @@ static int lp5521_probe(struct i2c_client *client,
904 return ret; 912 return ret;
905fail2: 913fail2:
906 lp5521_unregister_leds(chip); 914 lp5521_unregister_leds(chip);
907fail1:
908 lp5521_deinit_device(chip); 915 lp5521_deinit_device(chip);
916err_init:
909 return ret; 917 return ret;
910} 918}
911 919