Skip to content

Commit 27f07ca

Browse files
morimotobroonie
authored andcommitted
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: Kuninori Morimoto <[email protected]> Reviewed-by: Ranjani Sridharan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 739443d commit 27f07ca

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

include/sound/soc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,7 @@ struct snd_soc_card {
10961096
unsigned int topology_shortname_created:1;
10971097
unsigned int fully_routed:1;
10981098
unsigned int disable_route_checks:1;
1099+
unsigned int probed:1;
10991100

11001101
void *drvdata;
11011102
};

sound/soc/soc-core.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,8 +1723,7 @@ static void __soc_setup_card_name(char *name, int len,
17231723
}
17241724
}
17251725

1726-
static void soc_cleanup_card_resources(struct snd_soc_card *card,
1727-
int card_probed)
1726+
static void soc_cleanup_card_resources(struct snd_soc_card *card)
17281727
{
17291728
struct snd_soc_pcm_runtime *rtd, *n;
17301729

@@ -1748,8 +1747,9 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card,
17481747
soc_cleanup_card_debugfs(card);
17491748

17501749
/* remove the card */
1751-
if (card_probed && card->remove)
1750+
if (card->probed && card->remove)
17521751
card->remove(card);
1752+
card->probed = 0;
17531753

17541754
if (card->snd_card) {
17551755
snd_card_free(card->snd_card);
@@ -1760,12 +1760,10 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card,
17601760
static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister)
17611761
{
17621762
if (card->instantiated) {
1763-
int card_probed = 1;
1764-
17651763
card->instantiated = false;
17661764
snd_soc_flush_all_delayed_work(card);
17671765

1768-
soc_cleanup_card_resources(card, card_probed);
1766+
soc_cleanup_card_resources(card);
17691767
if (!unregister)
17701768
list_add(&card->list, &unbind_card_list);
17711769
} else {
@@ -1779,7 +1777,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
17791777
struct snd_soc_pcm_runtime *rtd;
17801778
struct snd_soc_component *component;
17811779
struct snd_soc_dai_link *dai_link;
1782-
int ret, i, card_probed = 0;
1780+
int ret, i;
17831781

17841782
mutex_lock(&client_mutex);
17851783
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)
18311829
ret = card->probe(card);
18321830
if (ret < 0)
18331831
goto probe_end;
1834-
card_probed = 1;
1832+
card->probed = 1;
18351833
}
18361834

18371835
/* 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)
19231921
goto probe_end;
19241922
}
19251923
}
1926-
card_probed = 1;
1924+
card->probed = 1;
19271925

19281926
snd_soc_dapm_new_widgets(card);
19291927

@@ -1945,7 +1943,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
19451943

19461944
probe_end:
19471945
if (ret < 0)
1948-
soc_cleanup_card_resources(card, card_probed);
1946+
soc_cleanup_card_resources(card);
19491947

19501948
mutex_unlock(&card->mutex);
19511949
mutex_unlock(&client_mutex);

0 commit comments

Comments
 (0)