diff options
author | Milo(Woogyom) Kim <milo.kim@ti.com> | 2013-02-05 04:58:35 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-02-06 18:59:27 -0500 |
commit | 22ebeb488b3dbbb64b81146b366551107ae34af8 (patch) | |
tree | 74eef8d5dcbc48c39b5452560bda094a0e8718ea | |
parent | ffbdccdbbaee814963a09d25b1cc598cfe131366 (diff) |
leds-lp55xx: clean up init function
lp5521/5523_init_device() are replaced with lp55xx common function,
lp55xx_init_device().
Error handler in init_device:
deinit function are matched with 'err_post_init' section in
lp55xx_init_device().
Remove LP5523 engine intialization code:
Engine functionality is not mandatory but optional.
Moreover engine initialization is done internally with device reset command.
Therefore, this code is unnecessary.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
-rw-r--r-- | drivers/leds/leds-lp5521.c | 22 | ||||
-rw-r--r-- | drivers/leds/leds-lp5523.c | 46 | ||||
-rw-r--r-- | drivers/leds/leds-lp55xx-common.c | 9 |
3 files changed, 12 insertions, 65 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index faab44900c23..74dc208fb99f 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -689,26 +689,6 @@ static void lp5521_unregister_sysfs(struct i2c_client *client) | |||
689 | &lp5521_led_attribute_group); | 689 | &lp5521_led_attribute_group); |
690 | } | 690 | } |
691 | 691 | ||
692 | static void lp5521_deinit_device(struct lp5521_chip *chip); | ||
693 | static int lp5521_init_device(struct lp5521_chip *chip) | ||
694 | { | ||
695 | struct i2c_client *client = chip->client; | ||
696 | struct lp55xx_chip *temp; | ||
697 | int ret; | ||
698 | |||
699 | ret = lp5521_post_init_device(temp); | ||
700 | if (ret < 0) { | ||
701 | dev_err(&client->dev, "error configuring chip\n"); | ||
702 | goto err_config; | ||
703 | } | ||
704 | |||
705 | return 0; | ||
706 | |||
707 | err_config: | ||
708 | lp5521_deinit_device(chip); | ||
709 | return ret; | ||
710 | } | ||
711 | |||
712 | static void lp5521_deinit_device(struct lp5521_chip *chip) | 692 | static void lp5521_deinit_device(struct lp5521_chip *chip) |
713 | { | 693 | { |
714 | struct lp5521_platform_data *pdata = chip->pdata; | 694 | struct lp5521_platform_data *pdata = chip->pdata; |
@@ -860,7 +840,7 @@ static int lp5521_probe(struct i2c_client *client, | |||
860 | 840 | ||
861 | i2c_set_clientdata(client, led); | 841 | i2c_set_clientdata(client, led); |
862 | 842 | ||
863 | ret = lp5521_init_device(old_chip); | 843 | ret = lp55xx_init_device(chip); |
864 | if (ret) | 844 | if (ret) |
865 | goto err_init; | 845 | goto err_init; |
866 | 846 | ||
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 110565b066e2..80b7fb4a3ad6 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c | |||
@@ -773,18 +773,6 @@ static void lp5523_set_mode(struct lp5523_engine *engine, u8 mode) | |||
773 | /*--------------------------------------------------------------*/ | 773 | /*--------------------------------------------------------------*/ |
774 | /* Probe, Attach, Remove */ | 774 | /* Probe, Attach, Remove */ |
775 | /*--------------------------------------------------------------*/ | 775 | /*--------------------------------------------------------------*/ |
776 | static int __init lp5523_init_engine(struct lp5523_engine *engine, int id) | ||
777 | { | ||
778 | if (id < 1 || id > LP5523_ENGINES) | ||
779 | return -1; | ||
780 | engine->id = id; | ||
781 | engine->engine_mask = LP5523_ENG_MASK_BASE >> SHIFT_MASK(id); | ||
782 | engine->prog_page = id - 1; | ||
783 | engine->mux_page = id + 2; | ||
784 | |||
785 | return 0; | ||
786 | } | ||
787 | |||
788 | static int lp5523_init_led(struct lp5523_led *led, struct device *dev, | 776 | static int lp5523_init_led(struct lp5523_led *led, struct device *dev, |
789 | int chan, struct lp5523_platform_data *pdata, | 777 | int chan, struct lp5523_platform_data *pdata, |
790 | const char *chip_name) | 778 | const char *chip_name) |
@@ -884,26 +872,6 @@ static void lp5523_unregister_leds(struct lp5523_chip *chip) | |||
884 | } | 872 | } |
885 | } | 873 | } |
886 | 874 | ||
887 | static void lp5523_deinit_device(struct lp5523_chip *chip); | ||
888 | static int lp5523_init_device(struct lp5523_chip *chip) | ||
889 | { | ||
890 | struct i2c_client *client = chip->client; | ||
891 | struct lp55xx_chip *temp; | ||
892 | int ret; | ||
893 | |||
894 | ret = lp5523_post_init_device(temp); | ||
895 | if (ret < 0) { | ||
896 | dev_err(&client->dev, "error configuring chip\n"); | ||
897 | goto err_config; | ||
898 | } | ||
899 | |||
900 | return 0; | ||
901 | |||
902 | err_config: | ||
903 | lp5523_deinit_device(chip); | ||
904 | return ret; | ||
905 | } | ||
906 | |||
907 | static void lp5523_deinit_device(struct lp5523_chip *chip) | 875 | static void lp5523_deinit_device(struct lp5523_chip *chip) |
908 | { | 876 | { |
909 | struct lp5523_platform_data *pdata = chip->pdata; | 877 | struct lp5523_platform_data *pdata = chip->pdata; |
@@ -931,7 +899,7 @@ static int lp5523_probe(struct i2c_client *client, | |||
931 | const struct i2c_device_id *id) | 899 | const struct i2c_device_id *id) |
932 | { | 900 | { |
933 | struct lp5523_chip *old_chip = NULL; | 901 | struct lp5523_chip *old_chip = NULL; |
934 | int ret, i; | 902 | int ret; |
935 | struct lp55xx_chip *chip; | 903 | struct lp55xx_chip *chip; |
936 | struct lp55xx_led *led; | 904 | struct lp55xx_led *led; |
937 | struct lp55xx_platform_data *pdata = client->dev.platform_data; | 905 | struct lp55xx_platform_data *pdata = client->dev.platform_data; |
@@ -958,21 +926,12 @@ static int lp5523_probe(struct i2c_client *client, | |||
958 | 926 | ||
959 | i2c_set_clientdata(client, led); | 927 | i2c_set_clientdata(client, led); |
960 | 928 | ||
961 | ret = lp5523_init_device(old_chip); | 929 | ret = lp55xx_init_device(chip); |
962 | if (ret) | 930 | if (ret) |
963 | goto err_init; | 931 | goto err_init; |
964 | 932 | ||
965 | dev_info(&client->dev, "%s Programmable led chip found\n", id->name); | 933 | dev_info(&client->dev, "%s Programmable led chip found\n", id->name); |
966 | 934 | ||
967 | /* Initialize engines */ | ||
968 | for (i = 0; i < ARRAY_SIZE(old_chip->engines); i++) { | ||
969 | ret = lp5523_init_engine(&old_chip->engines[i], i + 1); | ||
970 | if (ret) { | ||
971 | dev_err(&client->dev, "error initializing engine\n"); | ||
972 | goto fail1; | ||
973 | } | ||
974 | } | ||
975 | |||
976 | ret = lp5523_register_leds(old_chip, id->name); | 935 | ret = lp5523_register_leds(old_chip, id->name); |
977 | if (ret) | 936 | if (ret) |
978 | goto fail2; | 937 | goto fail2; |
@@ -985,7 +944,6 @@ static int lp5523_probe(struct i2c_client *client, | |||
985 | return ret; | 944 | return ret; |
986 | fail2: | 945 | fail2: |
987 | lp5523_unregister_leds(old_chip); | 946 | lp5523_unregister_leds(old_chip); |
988 | fail1: | ||
989 | lp5523_deinit_device(old_chip); | 947 | lp5523_deinit_device(old_chip); |
990 | err_init: | 948 | err_init: |
991 | return ret; | 949 | return ret; |
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 74beb363b787..c06745f160c3 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c | |||
@@ -144,9 +144,18 @@ int lp55xx_init_device(struct lp55xx_chip *chip) | |||
144 | 144 | ||
145 | /* chip specific initialization */ | 145 | /* chip specific initialization */ |
146 | ret = lp55xx_post_init_device(chip); | 146 | ret = lp55xx_post_init_device(chip); |
147 | if (ret) { | ||
148 | dev_err(dev, "post init device err: %d\n", ret); | ||
149 | goto err_post_init; | ||
150 | } | ||
147 | 151 | ||
148 | return 0; | 152 | return 0; |
149 | 153 | ||
154 | err_post_init: | ||
155 | if (pdata->enable) | ||
156 | pdata->enable(0); | ||
157 | if (pdata->release_resources) | ||
158 | pdata->release_resources(); | ||
150 | err: | 159 | err: |
151 | return ret; | 160 | return ret; |
152 | } | 161 | } |