diff options
-rw-r--r-- | drivers/leds/leds-lp5521.c | 26 | ||||
-rw-r--r-- | drivers/leds/leds-lp5523.c | 26 |
2 files changed, 36 insertions, 16 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 | ||
697 | static void lp5521_deinit_device(struct lp5521_chip *chip); | ||
697 | static int lp5521_init_device(struct lp5521_chip *chip) | 698 | static 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 | |||
759 | err_config: | ||
760 | lp5521_deinit_device(chip); | ||
761 | err: | ||
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; |
905 | fail2: | 913 | fail2: |
906 | lp5521_unregister_leds(chip); | 914 | lp5521_unregister_leds(chip); |
907 | fail1: | ||
908 | lp5521_deinit_device(chip); | 915 | lp5521_deinit_device(chip); |
916 | err_init: | ||
909 | return ret; | 917 | return ret; |
910 | } | 918 | } |
911 | 919 | ||
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index cac492b0abf3..fefe27c3f377 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c | |||
@@ -953,6 +953,7 @@ static void lp5523_reset_device(struct lp5523_chip *chip) | |||
953 | lp5523_write(client, LP5523_REG_RESET, 0xff); | 953 | lp5523_write(client, LP5523_REG_RESET, 0xff); |
954 | } | 954 | } |
955 | 955 | ||
956 | static void lp5523_deinit_device(struct lp5523_chip *chip); | ||
956 | static int lp5523_init_device(struct lp5523_chip *chip) | 957 | static int lp5523_init_device(struct lp5523_chip *chip) |
957 | { | 958 | { |
958 | struct lp5523_platform_data *pdata = chip->pdata; | 959 | struct lp5523_platform_data *pdata = chip->pdata; |
@@ -978,7 +979,22 @@ static int lp5523_init_device(struct lp5523_chip *chip) | |||
978 | * Exact value is not available. 10 - 20ms | 979 | * Exact value is not available. 10 - 20ms |
979 | * appears to be enough for reset. | 980 | * appears to be enough for reset. |
980 | */ | 981 | */ |
981 | return lp5523_detect(client); | 982 | ret = lp5523_detect(client); |
983 | if (ret) | ||
984 | goto err; | ||
985 | |||
986 | ret = lp5523_configure(client); | ||
987 | if (ret < 0) { | ||
988 | dev_err(&client->dev, "error configuring chip\n"); | ||
989 | goto err_config; | ||
990 | } | ||
991 | |||
992 | return 0; | ||
993 | |||
994 | err_config: | ||
995 | lp5523_deinit_device(chip); | ||
996 | err: | ||
997 | return ret; | ||
982 | } | 998 | } |
983 | 999 | ||
984 | static void lp5523_deinit_device(struct lp5523_chip *chip) | 1000 | static void lp5523_deinit_device(struct lp5523_chip *chip) |
@@ -1018,7 +1034,7 @@ static int lp5523_probe(struct i2c_client *client, | |||
1018 | 1034 | ||
1019 | ret = lp5523_init_device(chip); | 1035 | ret = lp5523_init_device(chip); |
1020 | if (ret) | 1036 | if (ret) |
1021 | goto fail1; | 1037 | goto err_init; |
1022 | 1038 | ||
1023 | dev_info(&client->dev, "%s Programmable led chip found\n", id->name); | 1039 | dev_info(&client->dev, "%s Programmable led chip found\n", id->name); |
1024 | 1040 | ||
@@ -1030,11 +1046,6 @@ static int lp5523_probe(struct i2c_client *client, | |||
1030 | goto fail1; | 1046 | goto fail1; |
1031 | } | 1047 | } |
1032 | } | 1048 | } |
1033 | ret = lp5523_configure(client); | ||
1034 | if (ret < 0) { | ||
1035 | dev_err(&client->dev, "error configuring chip\n"); | ||
1036 | goto fail1; | ||
1037 | } | ||
1038 | 1049 | ||
1039 | ret = lp5523_register_leds(chip, id->name); | 1050 | ret = lp5523_register_leds(chip, id->name); |
1040 | if (ret) | 1051 | if (ret) |
@@ -1050,6 +1061,7 @@ fail2: | |||
1050 | lp5523_unregister_leds(chip); | 1061 | lp5523_unregister_leds(chip); |
1051 | fail1: | 1062 | fail1: |
1052 | lp5523_deinit_device(chip); | 1063 | lp5523_deinit_device(chip); |
1064 | err_init: | ||
1053 | return ret; | 1065 | return ret; |
1054 | } | 1066 | } |
1055 | 1067 | ||