Commit 27f07cac authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-card: add probed bit field to snd_soc_card

We already have bit field to control snd_soc_card.
Let's add "probed" field on it instead of local variable.

One note here is that soc_cleanup_card_resources()
will be called as (A) formal cleanup or as (B) error handling,
thus, it needs to distinguish these.

In (A) case, card will have "instantiated" flag if all probe
callback functions were called without error.
Thus, snd_soc_unbind_card() is using it to judging card was probed.
But this this patch removes it, because it is no longer needed.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87r1v4zv36.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 739443d1
...@@ -1096,6 +1096,7 @@ struct snd_soc_card { ...@@ -1096,6 +1096,7 @@ struct snd_soc_card {
unsigned int topology_shortname_created:1; unsigned int topology_shortname_created:1;
unsigned int fully_routed:1; unsigned int fully_routed:1;
unsigned int disable_route_checks:1; unsigned int disable_route_checks:1;
unsigned int probed:1;
void *drvdata; void *drvdata;
}; };
......
...@@ -1723,8 +1723,7 @@ static void __soc_setup_card_name(char *name, int len, ...@@ -1723,8 +1723,7 @@ static void __soc_setup_card_name(char *name, int len,
} }
} }
static void soc_cleanup_card_resources(struct snd_soc_card *card, static void soc_cleanup_card_resources(struct snd_soc_card *card)
int card_probed)
{ {
struct snd_soc_pcm_runtime *rtd, *n; struct snd_soc_pcm_runtime *rtd, *n;
...@@ -1748,8 +1747,9 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card, ...@@ -1748,8 +1747,9 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card,
soc_cleanup_card_debugfs(card); soc_cleanup_card_debugfs(card);
/* remove the card */ /* remove the card */
if (card_probed && card->remove) if (card->probed && card->remove)
card->remove(card); card->remove(card);
card->probed = 0;
if (card->snd_card) { if (card->snd_card) {
snd_card_free(card->snd_card); snd_card_free(card->snd_card);
...@@ -1760,12 +1760,10 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card, ...@@ -1760,12 +1760,10 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card,
static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister) static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister)
{ {
if (card->instantiated) { if (card->instantiated) {
int card_probed = 1;
card->instantiated = false; card->instantiated = false;
snd_soc_flush_all_delayed_work(card); snd_soc_flush_all_delayed_work(card);
soc_cleanup_card_resources(card, card_probed); soc_cleanup_card_resources(card);
if (!unregister) if (!unregister)
list_add(&card->list, &unbind_card_list); list_add(&card->list, &unbind_card_list);
} else { } else {
...@@ -1779,7 +1777,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card) ...@@ -1779,7 +1777,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
struct snd_soc_pcm_runtime *rtd; struct snd_soc_pcm_runtime *rtd;
struct snd_soc_component *component; struct snd_soc_component *component;
struct snd_soc_dai_link *dai_link; struct snd_soc_dai_link *dai_link;
int ret, i, card_probed = 0; int ret, i;
mutex_lock(&client_mutex); mutex_lock(&client_mutex);
mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT); mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT);
...@@ -1831,7 +1829,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card) ...@@ -1831,7 +1829,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
ret = card->probe(card); ret = card->probe(card);
if (ret < 0) if (ret < 0)
goto probe_end; goto probe_end;
card_probed = 1; card->probed = 1;
} }
/* probe all components used by DAI links on this card */ /* probe all components used by DAI links on this card */
...@@ -1923,7 +1921,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card) ...@@ -1923,7 +1921,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
goto probe_end; goto probe_end;
} }
} }
card_probed = 1; card->probed = 1;
snd_soc_dapm_new_widgets(card); snd_soc_dapm_new_widgets(card);
...@@ -1945,7 +1943,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card) ...@@ -1945,7 +1943,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
probe_end: probe_end:
if (ret < 0) if (ret < 0)
soc_cleanup_card_resources(card, card_probed); soc_cleanup_card_resources(card);
mutex_unlock(&card->mutex); mutex_unlock(&card->mutex);
mutex_unlock(&client_mutex); mutex_unlock(&client_mutex);
......
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