Skip to content

Commit 73de4b0

Browse files
morimotobroonie
authored andcommitted
ASoC: soc-card: add snd_soc_card_probe()
Card related function should be implemented at soc-card now. This patch adds it. One note here is that card has "card->probe" and "card->late_probe" callbacks. Because it needs to care "late_probe", "card->probed" flag is set under if (card->probe) at snd_soc_card_probe(). 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 27f07ca commit 73de4b0

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

include/sound/soc-card.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ int snd_soc_card_suspend_post(struct snd_soc_card *card);
2424
int snd_soc_card_resume_pre(struct snd_soc_card *card);
2525
int snd_soc_card_resume_post(struct snd_soc_card *card);
2626

27+
int snd_soc_card_probe(struct snd_soc_card *card);
28+
2729
/* device driver data */
2830
static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
2931
void *data)

sound/soc/soc-card.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,26 @@ int snd_soc_card_resume_post(struct snd_soc_card *card)
119119

120120
return soc_card_ret(card, ret);
121121
}
122+
123+
int snd_soc_card_probe(struct snd_soc_card *card)
124+
{
125+
if (card->probe) {
126+
int ret = card->probe(card);
127+
128+
if (ret < 0)
129+
return soc_card_ret(card, ret);
130+
131+
/*
132+
* It has "card->probe" and "card->late_probe" callbacks.
133+
* So, set "probed" flag here, because it needs to care
134+
* about "late_probe".
135+
*
136+
* see
137+
* snd_soc_bind_card()
138+
* snd_soc_card_late_probe()
139+
*/
140+
card->probed = 1;
141+
}
142+
143+
return 0;
144+
}

sound/soc/soc-core.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,12 +1825,9 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
18251825
goto probe_end;
18261826

18271827
/* initialise the sound card only once */
1828-
if (card->probe) {
1829-
ret = card->probe(card);
1830-
if (ret < 0)
1831-
goto probe_end;
1832-
card->probed = 1;
1833-
}
1828+
ret = snd_soc_card_probe(card);
1829+
if (ret < 0)
1830+
goto probe_end;
18341831

18351832
/* probe all components used by DAI links on this card */
18361833
ret = soc_probe_link_components(card);

0 commit comments

Comments
 (0)