Commit 70090bbb authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown

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: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 57bf7726
...@@ -1004,6 +1004,9 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num) ...@@ -1004,6 +1004,9 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
static void soc_remove_component(struct snd_soc_component *component) static void soc_remove_component(struct snd_soc_component *component)
{ {
if (!component->probed)
return;
/* This is a HACK and will be removed soon */ /* This is a HACK and will be removed soon */
if (component->codec) if (component->codec)
list_del(&component->codec->card_list); list_del(&component->codec->card_list);
...@@ -1079,22 +1082,19 @@ static void soc_remove_link_components(struct snd_soc_card *card, int num, ...@@ -1079,22 +1082,19 @@ static void soc_remove_link_components(struct snd_soc_card *card, int num,
int i; int i;
/* remove the platform */ /* remove the platform */
if (platform && platform->component.probed && if (platform && platform->component.driver->remove_order == order)
platform->component.driver->remove_order == order)
soc_remove_component(&platform->component); soc_remove_component(&platform->component);
/* remove the CODEC-side CODEC */ /* remove the CODEC-side CODEC */
for (i = 0; i < rtd->num_codecs; i++) { for (i = 0; i < rtd->num_codecs; i++) {
component = rtd->codec_dais[i]->component; component = rtd->codec_dais[i]->component;
if (component->probed && if (component->driver->remove_order == order)
component->driver->remove_order == order)
soc_remove_component(component); soc_remove_component(component);
} }
/* remove any CPU-side CODEC */ /* remove any CPU-side CODEC */
if (cpu_dai) { if (cpu_dai) {
if (cpu_dai->component->probed && if (cpu_dai->component->driver->remove_order == order)
cpu_dai->component->driver->remove_order == order)
soc_remove_component(cpu_dai->component); soc_remove_component(cpu_dai->component);
} }
} }
...@@ -1145,6 +1145,9 @@ static int soc_probe_component(struct snd_soc_card *card, ...@@ -1145,6 +1145,9 @@ static int soc_probe_component(struct snd_soc_card *card,
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
int ret; int ret;
if (component->probed)
return 0;
component->card = card; component->card = card;
dapm->card = card; dapm->card = card;
soc_set_name_prefix(card, component); soc_set_name_prefix(card, component);
...@@ -1306,8 +1309,7 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num, ...@@ -1306,8 +1309,7 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num,
/* probe the CPU-side component, if it is a CODEC */ /* probe the CPU-side component, if it is a CODEC */
component = rtd->cpu_dai->component; component = rtd->cpu_dai->component;
if (!component->probed && if (component->driver->probe_order == order) {
component->driver->probe_order == order) {
ret = soc_probe_component(card, component); ret = soc_probe_component(card, component);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1316,8 +1318,7 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num, ...@@ -1316,8 +1318,7 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num,
/* probe the CODEC-side components */ /* probe the CODEC-side components */
for (i = 0; i < rtd->num_codecs; i++) { for (i = 0; i < rtd->num_codecs; i++) {
component = rtd->codec_dais[i]->component; component = rtd->codec_dais[i]->component;
if (!component->probed && if (component->driver->probe_order == order) {
component->driver->probe_order == order) {
ret = soc_probe_component(card, component); ret = soc_probe_component(card, component);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1325,8 +1326,7 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num, ...@@ -1325,8 +1326,7 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num,
} }
/* probe the platform */ /* probe the platform */
if (!platform->component.probed && if (platform->component.driver->probe_order == order) {
platform->component.driver->probe_order == order) {
ret = soc_probe_component(card, &platform->component); ret = soc_probe_component(card, &platform->component);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1621,11 +1621,6 @@ static int soc_probe_aux_dev(struct snd_soc_card *card, int num) ...@@ -1621,11 +1621,6 @@ static int soc_probe_aux_dev(struct snd_soc_card *card, int num)
struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
int ret; int ret;
if (rtd->component->probed) {
dev_err(rtd->dev, "ASoC: codec already probed\n");
return -EBUSY;
}
ret = soc_probe_component(card, rtd->component); ret = soc_probe_component(card, rtd->component);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment