linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: soc-core.c: Prefer to return dai->driver->name in snd_soc_dai_name_get()
@ 2024-01-29  7:18 Chancel Liu
  2024-01-29 23:46 ` Kuninori Morimoto
  0 siblings, 1 reply; 2+ messages in thread
From: Chancel Liu @ 2024-01-29  7:18 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, kuninori.morimoto.gx,
	linux-sound, linux-kernel
  Cc: Chancel Liu

ASoC machine driver can use snd_soc_{of_}get_dlc() (A) to get DAI name
for dlc (snd_soc_dai_link_component). In this function call
dlc->dai_name is parsed via snd_soc_dai_name_get() (B).

(A)	int snd_soc_get_dlc(...)
	{
		...
(B)		dlc->dai_name = snd_soc_dai_name_get(dai);
		...
	}

(B) has a priority to return dai->name as dlc->dai_name. In most cases
card can probe successfully. However it has an issue that ASoC tries to
rebind card. Here is a simplified flow for example:

 |	a) Card probes successfully at first
 |	b) One of the component bound to this card is removed for some
 |	   reason the component->dev is released
 |	c) That component is re-registered
 v	d) ASoC calls snd_soc_try_rebind_card()

a) points dlc->dai_name to dai->name. b) releases all resource of the
old DAI. c) creates new DAI structure. In result d) can not use
dlc->dai_name to add new created DAI.

So it's reasonable that prefer to return dai->driver->name in
snd_soc_dai_name_get() because dai->driver is a pre-defined global
variable.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 sound/soc/soc-core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 516350533e73..09467c693627 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -300,12 +300,12 @@ static int snd_soc_is_matching_dai(const struct snd_soc_dai_link_component *dlc,
 const char *snd_soc_dai_name_get(struct snd_soc_dai *dai)
 {
 	/* see snd_soc_is_matching_dai() */
-	if (dai->name)
-		return dai->name;
-
 	if (dai->driver->name)
 		return dai->driver->name;
 
+	if (dai->name)
+		return dai->name;
+
 	if (dai->component->name)
 		return dai->component->name;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASoC: soc-core.c: Prefer to return dai->driver->name in snd_soc_dai_name_get()
  2024-01-29  7:18 [PATCH] ASoC: soc-core.c: Prefer to return dai->driver->name in snd_soc_dai_name_get() Chancel Liu
@ 2024-01-29 23:46 ` Kuninori Morimoto
  0 siblings, 0 replies; 2+ messages in thread
From: Kuninori Morimoto @ 2024-01-29 23:46 UTC (permalink / raw)
  To: Chancel Liu; +Cc: lgirdwood, broonie, perex, tiwai, linux-sound, linux-kernel


Hi Chancel

Thank you for the patch

> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 516350533e73..09467c693627 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -300,12 +300,12 @@ static int snd_soc_is_matching_dai(const struct snd_soc_dai_link_component *dlc,
>  const char *snd_soc_dai_name_get(struct snd_soc_dai *dai)
>  {
>  	/* see snd_soc_is_matching_dai() */
> -	if (dai->name)
> -		return dai->name;
> -
>  	if (dai->driver->name)
>  		return dai->driver->name;
>  
> +	if (dai->name)
> +		return dai->name;
> +
>  	if (dai->component->name)
>  		return dai->component->name;
>  
> -- 

As above comment indicated, snd_soc_dai_name_get() and
snd_soc_is_matching_dai() are paired.
If you want to update snd_soc_dai_name_get(), updating
snd_soc_is_matching_dai() also is good idea.


Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-29 23:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-29  7:18 [PATCH] ASoC: soc-core.c: Prefer to return dai->driver->name in snd_soc_dai_name_get() Chancel Liu
2024-01-29 23:46 ` Kuninori Morimoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).