diff mbox series

[v2,6/8] ASoC: meson: switch to use snd_soc_daifmt_parse_format/clock_provider()

Message ID 874ke7dbpj.wl-kuninori.morimoto.gx@renesas.com
State New
Headers show
Series ASoC: tidyup snd_soc_of_parse_daifmt() | expand

Commit Message

Kuninori Morimoto June 9, 2021, 2:16 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch switch to use snd_soc_daifmt_parse_format/clock_provider() from
snd_soc_of_parse_daifmt().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/meson/meson-card-utils.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Jerome Brunet June 9, 2021, 7:11 a.m. UTC | #1
On Wed 09 Jun 2021 at 04:16, Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> wrote:

> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> This patch switch to use snd_soc_daifmt_parse_format/clock_provider() from
> snd_soc_of_parse_daifmt().
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  sound/soc/meson/meson-card-utils.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c
> index 300ac8be46ef..779ac282e36d 100644
> --- a/sound/soc/meson/meson-card-utils.c
> +++ b/sound/soc/meson/meson-card-utils.c
> @@ -118,24 +118,25 @@ unsigned int meson_card_parse_daifmt(struct device_node *node,
>  	struct device_node *bitclkmaster = NULL;
>  	struct device_node *framemaster = NULL;
>  	unsigned int daifmt;
> +	unsigned int daiclk;

Why did you need to add this local ? 

>  
> -	daifmt = snd_soc_of_parse_daifmt(node, "",
> -					 &bitclkmaster, &framemaster);
> -	daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
> +	daifmt = snd_soc_daifmt_parse_format(node, NULL);
> +
> +	snd_soc_daifmt_parse_clock_provider_as_phandle(node, NULL, &bitclkmaster, &framemaster);
>

Thanks for this

>  	/* If no master is provided, default to cpu master */
>  	if (!bitclkmaster || bitclkmaster == cpu_node) {
> -		daifmt |= (!framemaster || framemaster == cpu_node) ?
> +		daiclk = (!framemaster || framemaster == cpu_node) ?
>  			SND_SOC_DAIFMT_CBS_CFS : SND_SOC_DAIFMT_CBS_CFM;
>  	} else {
> -		daifmt |= (!framemaster || framemaster == cpu_node) ?
> +		daiclk = (!framemaster || framemaster == cpu_node) ?
>  			SND_SOC_DAIFMT_CBM_CFS : SND_SOC_DAIFMT_CBM_CFM;
>  	}
>  
>  	of_node_put(bitclkmaster);
>  	of_node_put(framemaster);
>  
> -	return daifmt;
> +	return daifmt | daiclk;

These 3 last changes does seem to necessary

>  }
>  EXPORT_SYMBOL_GPL(meson_card_parse_daifmt);
Kuninori Morimoto June 9, 2021, 11:02 p.m. UTC | #2
Hi Jerome

Thank you for your feedback

> > @@ -118,24 +118,25 @@ unsigned int meson_card_parse_daifmt(struct device_node *node,
> >  	struct device_node *bitclkmaster = NULL;
> >  	struct device_node *framemaster = NULL;
> >  	unsigned int daifmt;
> > +	unsigned int daiclk;
> 
> Why did you need to add this local ?

If you don't like using daiclk here,
I can merge these into daifmt.
I will wait other feedback, and will post patch next week.

Thank you for your help !!

Best regards
---
Kuninori Morimoto
diff mbox series

Patch

diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c
index 300ac8be46ef..779ac282e36d 100644
--- a/sound/soc/meson/meson-card-utils.c
+++ b/sound/soc/meson/meson-card-utils.c
@@ -118,24 +118,25 @@  unsigned int meson_card_parse_daifmt(struct device_node *node,
 	struct device_node *bitclkmaster = NULL;
 	struct device_node *framemaster = NULL;
 	unsigned int daifmt;
+	unsigned int daiclk;
 
-	daifmt = snd_soc_of_parse_daifmt(node, "",
-					 &bitclkmaster, &framemaster);
-	daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
+	daifmt = snd_soc_daifmt_parse_format(node, NULL);
+
+	snd_soc_daifmt_parse_clock_provider_as_phandle(node, NULL, &bitclkmaster, &framemaster);
 
 	/* If no master is provided, default to cpu master */
 	if (!bitclkmaster || bitclkmaster == cpu_node) {
-		daifmt |= (!framemaster || framemaster == cpu_node) ?
+		daiclk = (!framemaster || framemaster == cpu_node) ?
 			SND_SOC_DAIFMT_CBS_CFS : SND_SOC_DAIFMT_CBS_CFM;
 	} else {
-		daifmt |= (!framemaster || framemaster == cpu_node) ?
+		daiclk = (!framemaster || framemaster == cpu_node) ?
 			SND_SOC_DAIFMT_CBM_CFS : SND_SOC_DAIFMT_CBM_CFM;
 	}
 
 	of_node_put(bitclkmaster);
 	of_node_put(framemaster);
 
-	return daifmt;
+	return daifmt | daiclk;
 }
 EXPORT_SYMBOL_GPL(meson_card_parse_daifmt);