diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-08-19 09:51:24 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-08-19 11:59:46 -0400 |
commit | 70090bbb8b7d7da7a6f64969b43a61c493c560ff (patch) | |
tree | 409d673410355aae7fdbf952b01147de47f7b81d | |
parent | 57bf772687700e206c760ba2e4097f78bde97887 (diff) |
ASoC: Move component->probed check into soc_{remove,probe}_component()
Having the check in a centralized place makes the code a bit cleaner and
shorter.
Note: There is a slight semantic change in this patch. soc_probe_aux_dev() will
no longer return -EBUSY if the AUX dev has already been probed before. This is
fine though since it will simply do nothing in that case and return success.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | sound/soc/soc-core.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4393bc33d3af..2fbfbfca48dc 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -1004,6 +1004,9 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num) | |||
1004 | 1004 | ||
1005 | static void soc_remove_component(struct snd_soc_component *component) | 1005 | static void soc_remove_component(struct snd_soc_component *component) |
1006 | { | 1006 | { |
1007 | if (!component->probed) | ||
1008 | return; | ||
1009 | |||
1007 | /* This is a HACK and will be removed soon */ | 1010 | /* This is a HACK and will be removed soon */ |
1008 | if (component->codec) | 1011 | if (component->codec) |
1009 | list_del(&component->codec->card_list); | 1012 | list_del(&component->codec->card_list); |
@@ -1079,22 +1082,19 @@ static void soc_remove_link_components(struct snd_soc_card *card, int num, | |||
1079 | int i; | 1082 | int i; |
1080 | 1083 | ||
1081 | /* remove the platform */ | 1084 | /* remove the platform */ |
1082 | if (platform && platform->component.probed && | 1085 | if (platform && platform->component.driver->remove_order == order) |
1083 | platform->component.driver->remove_order == order) | ||
1084 | soc_remove_component(&platform->component); | 1086 | soc_remove_component(&platform->component); |
1085 | 1087 | ||
1086 | /* remove the CODEC-side CODEC */ | 1088 | /* remove the CODEC-side CODEC */ |
1087 | for (i = 0; i < rtd->num_codecs; i++) { | 1089 | for (i = 0; i < rtd->num_codecs; i++) { |
1088 | component = rtd->codec_dais[i]->component; | 1090 | component = rtd->codec_dais[i]->component; |
1089 | if (component->probed && | 1091 | if (component->driver->remove_order == order) |
1090 | component->driver->remove_order == order) | ||
1091 | soc_remove_component(component); | 1092 | soc_remove_component(component); |
1092 | } | 1093 | } |
1093 | 1094 | ||
1094 | /* remove any CPU-side CODEC */ | 1095 | /* remove any CPU-side CODEC */ |
1095 | if (cpu_dai) { | 1096 | if (cpu_dai) { |
1096 | if (cpu_dai->component->probed && | 1097 | if (cpu_dai->component->driver->remove_order == order) |
1097 | cpu_dai->component->driver->remove_order == order) | ||
1098 | soc_remove_component(cpu_dai->component); | 1098 | soc_remove_component(cpu_dai->component); |
1099 | } | 1099 | } |
1100 | } | 1100 | } |
@@ -1145,6 +1145,9 @@ static int soc_probe_component(struct snd_soc_card *card, | |||
1145 | struct snd_soc_dai *dai; | 1145 | struct snd_soc_dai *dai; |
1146 | int ret; | 1146 | int ret; |
1147 | 1147 | ||
1148 | if (component->probed) | ||
1149 | return 0; | ||
1150 | |||
1148 | component->card = card; | 1151 | component->card = card; |
1149 | dapm->card = card; | 1152 | dapm->card = card; |
1150 | soc_set_name_prefix(card, component); | 1153 | soc_set_name_prefix(card, component); |
@@ -1306,8 +1309,7 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num, | |||
1306 | 1309 | ||
1307 | /* probe the CPU-side component, if it is a CODEC */ | 1310 | /* probe the CPU-side component, if it is a CODEC */ |
1308 | component = rtd->cpu_dai->component; | 1311 | component = rtd->cpu_dai->component; |
1309 | if (!component->probed && | 1312 | if (component->driver->probe_order == order) { |
1310 | component->driver->probe_order == order) { | ||
1311 | ret = soc_probe_component(card, component); | 1313 | ret = soc_probe_component(card, component); |
1312 | if (ret < 0) | 1314 | if (ret < 0) |
1313 | return ret; | 1315 | return ret; |
@@ -1316,8 +1318,7 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num, | |||
1316 | /* probe the CODEC-side components */ | 1318 | /* probe the CODEC-side components */ |
1317 | for (i = 0; i < rtd->num_codecs; i++) { | 1319 | for (i = 0; i < rtd->num_codecs; i++) { |
1318 | component = rtd->codec_dais[i]->component; | 1320 | component = rtd->codec_dais[i]->component; |
1319 | if (!component->probed && | 1321 | if (component->driver->probe_order == order) { |
1320 | component->driver->probe_order == order) { | ||
1321 | ret = soc_probe_component(card, component); | 1322 | ret = soc_probe_component(card, component); |
1322 | if (ret < 0) | 1323 | if (ret < 0) |
1323 | return ret; | 1324 | return ret; |
@@ -1325,8 +1326,7 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num, | |||
1325 | } | 1326 | } |
1326 | 1327 | ||
1327 | /* probe the platform */ | 1328 | /* probe the platform */ |
1328 | if (!platform->component.probed && | 1329 | if (platform->component.driver->probe_order == order) { |
1329 | platform->component.driver->probe_order == order) { | ||
1330 | ret = soc_probe_component(card, &platform->component); | 1330 | ret = soc_probe_component(card, &platform->component); |
1331 | if (ret < 0) | 1331 | if (ret < 0) |
1332 | return ret; | 1332 | return ret; |
@@ -1621,11 +1621,6 @@ static int soc_probe_aux_dev(struct snd_soc_card *card, int num) | |||
1621 | struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; | 1621 | struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; |
1622 | int ret; | 1622 | int ret; |
1623 | 1623 | ||
1624 | if (rtd->component->probed) { | ||
1625 | dev_err(rtd->dev, "ASoC: codec already probed\n"); | ||
1626 | return -EBUSY; | ||
1627 | } | ||
1628 | |||
1629 | ret = soc_probe_component(card, rtd->component); | 1624 | ret = soc_probe_component(card, rtd->component); |
1630 | if (ret < 0) | 1625 | if (ret < 0) |
1631 | return ret; | 1626 | return ret; |