linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] ASoC: clock provider clean-up
@ 2021-04-10 11:13 Jerome Brunet
  2021-04-10 11:13 ` [PATCH 1/5] ASoC: stm32: properly get clk from the provider Jerome Brunet
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Jerome Brunet @ 2021-04-10 11:13 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, Stephen Boyd

The purpose of this patchset it remove the use the clk member of
'struct clk_hw' in ASoC. 'struct clk' is a per-user reference to an actual
clock. In the future, the clk member in 'struct clk_hw' may go away.

The usage of this member by a clock provider usually falls into either of
following categories:
* Mis-usage of the clock consumer API by a clock provider.
* Clock provider also being a user of its own clocks. In this case the
  provider should request a 'struct clk' through the appropriate API
  instead of poking in 'struct clk_hw' internals.

Jerome Brunet (5):
  ASoC: stm32: properly get clk from the provider
  ASoC: wcd934x: use the clock provider API
  ASoC: rt5682: clock driver must use the clock provider API
  ASoC: lpass: use the clock provider API
  ASoC: da7219: properly get clk from the provider

 sound/soc/codecs/da7219.c          | 5 ++++-
 sound/soc/codecs/lpass-va-macro.c  | 2 +-
 sound/soc/codecs/lpass-wsa-macro.c | 9 +++------
 sound/soc/codecs/rt5682.c          | 6 +++---
 sound/soc/codecs/wcd934x.c         | 6 ++++--
 sound/soc/stm/stm32_sai_sub.c      | 5 ++++-
 6 files changed, 19 insertions(+), 14 deletions(-)

-- 
2.30.2


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

* [PATCH 1/5] ASoC: stm32: properly get clk from the provider
  2021-04-10 11:13 [PATCH 0/5] ASoC: clock provider clean-up Jerome Brunet
@ 2021-04-10 11:13 ` Jerome Brunet
  2021-04-12 20:25   ` Stephen Boyd
  2021-04-10 11:13 ` [PATCH 2/5] ASoC: wcd934x: use the clock provider API Jerome Brunet
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Jerome Brunet @ 2021-04-10 11:13 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, Stephen Boyd

Instead of using the clk embedded in the clk_hw (which is meant to go
away), a clock provider which need to interact with its own clock should
request clk reference through the clock provider API.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 sound/soc/stm/stm32_sai_sub.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index 3aa1cf262402..c1561237ee24 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -484,7 +484,10 @@ static int stm32_sai_add_mclk_provider(struct stm32_sai_sub_data *sai)
 		dev_err(dev, "mclk register returned %d\n", ret);
 		return ret;
 	}
-	sai->sai_mclk = hw->clk;
+
+	sai->sai_mclk = devm_clk_hw_get_clk(dev, hw, NULL);
+	if (IS_ERR(sai->sai_mclk))
+		return PTR_ERR(sai->sai_mclk);
 
 	/* register mclk provider */
 	return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
-- 
2.30.2


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

* [PATCH 2/5] ASoC: wcd934x: use the clock provider API
  2021-04-10 11:13 [PATCH 0/5] ASoC: clock provider clean-up Jerome Brunet
  2021-04-10 11:13 ` [PATCH 1/5] ASoC: stm32: properly get clk from the provider Jerome Brunet
@ 2021-04-10 11:13 ` Jerome Brunet
  2021-04-12 20:26   ` Stephen Boyd
  2021-04-10 11:13 ` [PATCH 3/5] ASoC: rt5682: clock driver must " Jerome Brunet
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Jerome Brunet @ 2021-04-10 11:13 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, Stephen Boyd

Clock providers should use the clk_hw API

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 sound/soc/codecs/wcd934x.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
index 5fe403307b72..ae3ea136a9f8 100644
--- a/sound/soc/codecs/wcd934x.c
+++ b/sound/soc/codecs/wcd934x.c
@@ -2116,11 +2116,13 @@ static struct clk *wcd934x_register_mclk_output(struct wcd934x_codec *wcd)
 	wcd->hw.init = &init;
 
 	hw = &wcd->hw;
-	ret = clk_hw_register(wcd->dev->parent, hw);
+	ret = devm_clk_hw_register(wcd->dev->parent, hw);
 	if (ret)
 		return ERR_PTR(ret);
 
-	of_clk_add_provider(np, of_clk_src_simple_get, hw->clk);
+	ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
+	if (ret)
+		return ERR_PTR(ret);
 
 	return NULL;
 }
-- 
2.30.2


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

* [PATCH 3/5] ASoC: rt5682: clock driver must use the clock provider API
  2021-04-10 11:13 [PATCH 0/5] ASoC: clock provider clean-up Jerome Brunet
  2021-04-10 11:13 ` [PATCH 1/5] ASoC: stm32: properly get clk from the provider Jerome Brunet
  2021-04-10 11:13 ` [PATCH 2/5] ASoC: wcd934x: use the clock provider API Jerome Brunet
@ 2021-04-10 11:13 ` Jerome Brunet
  2021-04-12 20:27   ` Stephen Boyd
  2021-04-10 11:13 ` [PATCH 4/5] ASoC: lpass: " Jerome Brunet
  2021-04-10 11:13 ` [PATCH 5/5] ASoC: da7219: properly get clk from the provider Jerome Brunet
  4 siblings, 1 reply; 14+ messages in thread
From: Jerome Brunet @ 2021-04-10 11:13 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, Stephen Boyd

Clock drivers ops should not the clk API but the clock provider (clk_hw)
instead.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 sound/soc/codecs/rt5682.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 0e2a10ed11da..2eee02ac8d49 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -2634,7 +2634,7 @@ static int rt5682_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
 		container_of(hw, struct rt5682_priv,
 			     dai_clks_hw[RT5682_DAI_WCLK_IDX]);
 	struct snd_soc_component *component = rt5682->component;
-	struct clk *parent_clk;
+	struct clk_hw *parent_hw;
 	const char * const clk_name = clk_hw_get_name(hw);
 	int pre_div;
 	unsigned int clk_pll2_out;
@@ -2649,8 +2649,8 @@ static int rt5682_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
 	 *
 	 * It will set the codec anyway by assuming mclk is 48MHz.
 	 */
-	parent_clk = clk_get_parent(hw->clk);
-	if (!parent_clk)
+	parent_hw = clk_hw_get_parent(hw);
+	if (!parent_hw)
 		dev_warn(component->dev,
 			"Parent mclk of wclk not acquired in driver. Please ensure mclk was provided as %d Hz.\n",
 			CLK_PLL2_FIN);
-- 
2.30.2


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

* [PATCH 4/5] ASoC: lpass: use the clock provider API
  2021-04-10 11:13 [PATCH 0/5] ASoC: clock provider clean-up Jerome Brunet
                   ` (2 preceding siblings ...)
  2021-04-10 11:13 ` [PATCH 3/5] ASoC: rt5682: clock driver must " Jerome Brunet
@ 2021-04-10 11:13 ` Jerome Brunet
  2021-04-12  9:38   ` Srinivas Kandagatla
  2021-04-10 11:13 ` [PATCH 5/5] ASoC: da7219: properly get clk from the provider Jerome Brunet
  4 siblings, 1 reply; 14+ messages in thread
From: Jerome Brunet @ 2021-04-10 11:13 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, Stephen Boyd

Clock providers should be registered using the clk_hw API.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 sound/soc/codecs/lpass-va-macro.c  | 2 +-
 sound/soc/codecs/lpass-wsa-macro.c | 9 +++------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c
index 5294c57b2cd4..56b887301172 100644
--- a/sound/soc/codecs/lpass-va-macro.c
+++ b/sound/soc/codecs/lpass-va-macro.c
@@ -1343,7 +1343,7 @@ static int va_macro_register_fsgen_output(struct va_macro *va)
 	if (ret)
 		return ret;
 
-	return of_clk_add_provider(np, of_clk_src_simple_get, va->hw.clk);
+	return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &va->hw);
 }
 
 static int va_macro_validate_dmic_sample_rate(u32 dmic_sample_rate,
diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c
index e79a70386b4b..acb95e83c788 100644
--- a/sound/soc/codecs/lpass-wsa-macro.c
+++ b/sound/soc/codecs/lpass-wsa-macro.c
@@ -2337,10 +2337,9 @@ static const struct clk_ops swclk_gate_ops = {
 	.recalc_rate = swclk_recalc_rate,
 };
 
-static struct clk *wsa_macro_register_mclk_output(struct wsa_macro *wsa)
+static int wsa_macro_register_mclk_output(struct wsa_macro *wsa)
 {
 	struct device *dev = wsa->dev;
-	struct device_node *np = dev->of_node;
 	const char *parent_clk_name;
 	const char *clk_name = "mclk";
 	struct clk_hw *hw;
@@ -2358,11 +2357,9 @@ static struct clk *wsa_macro_register_mclk_output(struct wsa_macro *wsa)
 	hw = &wsa->hw;
 	ret = clk_hw_register(wsa->dev, hw);
 	if (ret)
-		return ERR_PTR(ret);
-
-	of_clk_add_provider(np, of_clk_src_simple_get, hw->clk);
+		return ret;
 
-	return NULL;
+	return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
 }
 
 static const struct snd_soc_component_driver wsa_macro_component_drv = {
-- 
2.30.2


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

* [PATCH 5/5] ASoC: da7219: properly get clk from the provider
  2021-04-10 11:13 [PATCH 0/5] ASoC: clock provider clean-up Jerome Brunet
                   ` (3 preceding siblings ...)
  2021-04-10 11:13 ` [PATCH 4/5] ASoC: lpass: " Jerome Brunet
@ 2021-04-10 11:13 ` Jerome Brunet
  2021-04-12 20:27   ` Stephen Boyd
  4 siblings, 1 reply; 14+ messages in thread
From: Jerome Brunet @ 2021-04-10 11:13 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, Stephen Boyd

Instead of using the clk embedded in the clk_hw (which is meant to go
away), a clock provider which need to interact with its own clock should
request clk reference through the clock provider API.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 sound/soc/codecs/da7219.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c
index 13009d08b09a..bd3c523a8617 100644
--- a/sound/soc/codecs/da7219.c
+++ b/sound/soc/codecs/da7219.c
@@ -2181,7 +2181,10 @@ static int da7219_register_dai_clks(struct snd_soc_component *component)
 				 ret);
 			goto err;
 		}
-		da7219->dai_clks[i] = dai_clk_hw->clk;
+
+		da7219->dai_clks[i] = devm_clk_hw_get_clk(dev, dai_clk_hw, NULL);
+		if (IS_ERR(da7219->dai_clks[i]))
+			return PTR_ERR(da7219->dai_clks[i]);
 
 		/* For DT setup onecell data, otherwise create lookup */
 		if (np) {
-- 
2.30.2


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

* Re: [PATCH 4/5] ASoC: lpass: use the clock provider API
  2021-04-10 11:13 ` [PATCH 4/5] ASoC: lpass: " Jerome Brunet
@ 2021-04-12  9:38   ` Srinivas Kandagatla
  2021-04-12 12:17     ` Jerome Brunet
  0 siblings, 1 reply; 14+ messages in thread
From: Srinivas Kandagatla @ 2021-04-12  9:38 UTC (permalink / raw)
  To: Jerome Brunet, Mark Brown, Liam Girdwood
  Cc: Stephen Boyd, alsa-devel, linux-kernel

Thanks Jerome for the patch,


On 10/04/2021 12:13, Jerome Brunet wrote:
> Clock providers should be registered using the clk_hw API.
> 
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---
>   sound/soc/codecs/lpass-va-macro.c  | 2 +-
>   sound/soc/codecs/lpass-wsa-macro.c | 9 +++------
>   2 files changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c
> index 5294c57b2cd4..56b887301172 100644
> --- a/sound/soc/codecs/lpass-va-macro.c
> +++ b/sound/soc/codecs/lpass-va-macro.c
> @@ -1343,7 +1343,7 @@ static int va_macro_register_fsgen_output(struct va_macro *va)
>   	if (ret)
>   		return ret;
>   
> -	return of_clk_add_provider(np, of_clk_src_simple_get, va->hw.clk);
> +	return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &va->hw);

Now that we convert this to devm, You missed error path and driver 
remove where we delete clk provider. This should be removed as well as 
part of this patch.


This applies to both wsa and va macro.

Thanks,
srini
>   }
>   
>   static int va_macro_validate_dmic_sample_rate(u32 dmic_sample_rate,
> diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c
> index e79a70386b4b..acb95e83c788 100644
> --- a/sound/soc/codecs/lpass-wsa-macro.c
> +++ b/sound/soc/codecs/lpass-wsa-macro.c
> @@ -2337,10 +2337,9 @@ static const struct clk_ops swclk_gate_ops = {
>   	.recalc_rate = swclk_recalc_rate,
>   };
>   
> -static struct clk *wsa_macro_register_mclk_output(struct wsa_macro *wsa)
> +static int wsa_macro_register_mclk_output(struct wsa_macro *wsa)
>   {
>   	struct device *dev = wsa->dev;
> -	struct device_node *np = dev->of_node;
>   	const char *parent_clk_name;
>   	const char *clk_name = "mclk";
>   	struct clk_hw *hw;
> @@ -2358,11 +2357,9 @@ static struct clk *wsa_macro_register_mclk_output(struct wsa_macro *wsa)
>   	hw = &wsa->hw;
>   	ret = clk_hw_register(wsa->dev, hw);
>   	if (ret)
> -		return ERR_PTR(ret);
> -
> -	of_clk_add_provider(np, of_clk_src_simple_get, hw->clk);
> +		return ret;
>   
> -	return NULL;
> +	return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
>   }
>   
>   static const struct snd_soc_component_driver wsa_macro_component_drv = {
> 

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

* Re: [PATCH 4/5] ASoC: lpass: use the clock provider API
  2021-04-12  9:38   ` Srinivas Kandagatla
@ 2021-04-12 12:17     ` Jerome Brunet
  2021-04-12 13:55       ` Srinivas Kandagatla
  0 siblings, 1 reply; 14+ messages in thread
From: Jerome Brunet @ 2021-04-12 12:17 UTC (permalink / raw)
  To: Srinivas Kandagatla, Mark Brown, Liam Girdwood
  Cc: Stephen Boyd, alsa-devel, linux-kernel


On Mon 12 Apr 2021 at 11:38, Srinivas Kandagatla <srinivas.kandagatla@linaro.org> wrote:

> Thanks Jerome for the patch,
>
>
> On 10/04/2021 12:13, Jerome Brunet wrote:
>> Clock providers should be registered using the clk_hw API.
>> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
>> ---
>>   sound/soc/codecs/lpass-va-macro.c  | 2 +-
>>   sound/soc/codecs/lpass-wsa-macro.c | 9 +++------
>>   2 files changed, 4 insertions(+), 7 deletions(-)
>> diff --git a/sound/soc/codecs/lpass-va-macro.c
>> b/sound/soc/codecs/lpass-va-macro.c
>> index 5294c57b2cd4..56b887301172 100644
>> --- a/sound/soc/codecs/lpass-va-macro.c
>> +++ b/sound/soc/codecs/lpass-va-macro.c
>> @@ -1343,7 +1343,7 @@ static int va_macro_register_fsgen_output(struct va_macro *va)
>>   	if (ret)
>>   		return ret;
>>   -	return of_clk_add_provider(np, of_clk_src_simple_get, va->hw.clk);
>> +	return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &va->hw);
>
> Now that we convert this to devm, You missed error path and driver remove
> where we delete clk provider. This should be removed as well as part of
> this patch.

Indeed. I should not have switched to devm here - It was not really the
purpose of the patch. Habits I guess.

Do you prefer I stick with devm (with the suggested fix) or revert to the
no-devm way for the v2 ? It makes no difference to me TBH.

>
>
> This applies to both wsa and va macro.
>
> Thanks,
> srini
>>   }
>>     static int va_macro_validate_dmic_sample_rate(u32 dmic_sample_rate,
>> diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c
>> index e79a70386b4b..acb95e83c788 100644
>> --- a/sound/soc/codecs/lpass-wsa-macro.c
>> +++ b/sound/soc/codecs/lpass-wsa-macro.c
>> @@ -2337,10 +2337,9 @@ static const struct clk_ops swclk_gate_ops = {
>>   	.recalc_rate = swclk_recalc_rate,
>>   };
>>   -static struct clk *wsa_macro_register_mclk_output(struct wsa_macro
>> *wsa)
>> +static int wsa_macro_register_mclk_output(struct wsa_macro *wsa)
>>   {
>>   	struct device *dev = wsa->dev;
>> -	struct device_node *np = dev->of_node;
>>   	const char *parent_clk_name;
>>   	const char *clk_name = "mclk";
>>   	struct clk_hw *hw;
>> @@ -2358,11 +2357,9 @@ static struct clk *wsa_macro_register_mclk_output(struct wsa_macro *wsa)
>>   	hw = &wsa->hw;
>>   	ret = clk_hw_register(wsa->dev, hw);
>>   	if (ret)
>> -		return ERR_PTR(ret);
>> -
>> -	of_clk_add_provider(np, of_clk_src_simple_get, hw->clk);
>> +		return ret;
>>   -	return NULL;
>> +	return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
>>   }
>>     static const struct snd_soc_component_driver wsa_macro_component_drv
>> = {
>> 


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

* Re: [PATCH 4/5] ASoC: lpass: use the clock provider API
  2021-04-12 12:17     ` Jerome Brunet
@ 2021-04-12 13:55       ` Srinivas Kandagatla
  0 siblings, 0 replies; 14+ messages in thread
From: Srinivas Kandagatla @ 2021-04-12 13:55 UTC (permalink / raw)
  To: Jerome Brunet, Mark Brown, Liam Girdwood
  Cc: Stephen Boyd, alsa-devel, linux-kernel



On 12/04/2021 13:17, Jerome Brunet wrote:
>>>    -	return of_clk_add_provider(np, of_clk_src_simple_get, va->hw.clk);
>>> +	return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &va->hw);
>> Now that we convert this to devm, You missed error path and driver remove
>> where we delete clk provider. This should be removed as well as part of
>> this patch.
> Indeed. I should not have switched to devm here - It was not really the
> purpose of the patch. Habits I guess.
> 
> Do you prefer I stick with devm (with the suggested fix) or revert to the
> no-devm way for the v2 ? It makes no difference to me TBH.

devm should be good.

--srini
> 

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

* Re: [PATCH 1/5] ASoC: stm32: properly get clk from the provider
  2021-04-10 11:13 ` [PATCH 1/5] ASoC: stm32: properly get clk from the provider Jerome Brunet
@ 2021-04-12 20:25   ` Stephen Boyd
  0 siblings, 0 replies; 14+ messages in thread
From: Stephen Boyd @ 2021-04-12 20:25 UTC (permalink / raw)
  To: Jerome Brunet, Liam Girdwood, Mark Brown
  Cc: Jerome Brunet, alsa-devel, linux-kernel

Quoting Jerome Brunet (2021-04-10 04:13:52)
> Instead of using the clk embedded in the clk_hw (which is meant to go
> away), a clock provider which need to interact with its own clock should
> request clk reference through the clock provider API.
> 
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---

Reviewed-by: Stephen Boyd <sboyd@kernel.org>

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

* Re: [PATCH 2/5] ASoC: wcd934x: use the clock provider API
  2021-04-10 11:13 ` [PATCH 2/5] ASoC: wcd934x: use the clock provider API Jerome Brunet
@ 2021-04-12 20:26   ` Stephen Boyd
  0 siblings, 0 replies; 14+ messages in thread
From: Stephen Boyd @ 2021-04-12 20:26 UTC (permalink / raw)
  To: Jerome Brunet, Liam Girdwood, Mark Brown
  Cc: Jerome Brunet, alsa-devel, linux-kernel

Quoting Jerome Brunet (2021-04-10 04:13:53)
> Clock providers should use the clk_hw API

It sort of already is :)

> 
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---

Reviewed-by: Stephen Boyd <sboyd@kernel.org>

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

* Re: [PATCH 3/5] ASoC: rt5682: clock driver must use the clock provider API
  2021-04-10 11:13 ` [PATCH 3/5] ASoC: rt5682: clock driver must " Jerome Brunet
@ 2021-04-12 20:27   ` Stephen Boyd
  2021-04-13  7:31     ` Jerome Brunet
  0 siblings, 1 reply; 14+ messages in thread
From: Stephen Boyd @ 2021-04-12 20:27 UTC (permalink / raw)
  To: Jerome Brunet, Liam Girdwood, Mark Brown
  Cc: Jerome Brunet, alsa-devel, linux-kernel

Quoting Jerome Brunet (2021-04-10 04:13:54)
> Clock drivers ops should not the clk API but the clock provider (clk_hw)
> instead.
> 
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---
>  sound/soc/codecs/rt5682.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
> index 0e2a10ed11da..2eee02ac8d49 100644
> --- a/sound/soc/codecs/rt5682.c
> +++ b/sound/soc/codecs/rt5682.c
> @@ -2634,7 +2634,7 @@ static int rt5682_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
>                 container_of(hw, struct rt5682_priv,
>                              dai_clks_hw[RT5682_DAI_WCLK_IDX]);
>         struct snd_soc_component *component = rt5682->component;
> -       struct clk *parent_clk;
> +       struct clk_hw *parent_hw;
>         const char * const clk_name = clk_hw_get_name(hw);
>         int pre_div;
>         unsigned int clk_pll2_out;
> @@ -2649,8 +2649,8 @@ static int rt5682_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
>          *
>          * It will set the codec anyway by assuming mclk is 48MHz.
>          */
> -       parent_clk = clk_get_parent(hw->clk);
> -       if (!parent_clk)
> +       parent_hw = clk_hw_get_parent(hw);
> +       if (!parent_hw)
>                 dev_warn(component->dev,
>                         "Parent mclk of wclk not acquired in driver. Please ensure mclk was provided as %d Hz.\n",
>                         CLK_PLL2_FIN);

Can this code be removed? I don't know why we care to check if the clk
has a parent or not.

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

* Re: [PATCH 5/5] ASoC: da7219: properly get clk from the provider
  2021-04-10 11:13 ` [PATCH 5/5] ASoC: da7219: properly get clk from the provider Jerome Brunet
@ 2021-04-12 20:27   ` Stephen Boyd
  0 siblings, 0 replies; 14+ messages in thread
From: Stephen Boyd @ 2021-04-12 20:27 UTC (permalink / raw)
  To: Jerome Brunet, Liam Girdwood, Mark Brown
  Cc: Jerome Brunet, alsa-devel, linux-kernel

Quoting Jerome Brunet (2021-04-10 04:13:56)
> Instead of using the clk embedded in the clk_hw (which is meant to go
> away), a clock provider which need to interact with its own clock should
> request clk reference through the clock provider API.
> 
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---

Reviewed-by: Stephen Boyd <sboyd@kernel.org>

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

* Re: [PATCH 3/5] ASoC: rt5682: clock driver must use the clock provider API
  2021-04-12 20:27   ` Stephen Boyd
@ 2021-04-13  7:31     ` Jerome Brunet
  0 siblings, 0 replies; 14+ messages in thread
From: Jerome Brunet @ 2021-04-13  7:31 UTC (permalink / raw)
  To: Stephen Boyd, Liam Girdwood, Mark Brown; +Cc: alsa-devel, linux-kernel


On Mon 12 Apr 2021 at 22:27, Stephen Boyd <sboyd@kernel.org> wrote:

> Quoting Jerome Brunet (2021-04-10 04:13:54)
>> Clock drivers ops should not the clk API but the clock provider (clk_hw)
>> instead.
>> 
>> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
>> ---
>>  sound/soc/codecs/rt5682.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
>> index 0e2a10ed11da..2eee02ac8d49 100644
>> --- a/sound/soc/codecs/rt5682.c
>> +++ b/sound/soc/codecs/rt5682.c
>> @@ -2634,7 +2634,7 @@ static int rt5682_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
>>                 container_of(hw, struct rt5682_priv,
>>                              dai_clks_hw[RT5682_DAI_WCLK_IDX]);
>>         struct snd_soc_component *component = rt5682->component;
>> -       struct clk *parent_clk;
>> +       struct clk_hw *parent_hw;
>>         const char * const clk_name = clk_hw_get_name(hw);
>>         int pre_div;
>>         unsigned int clk_pll2_out;
>> @@ -2649,8 +2649,8 @@ static int rt5682_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
>>          *
>>          * It will set the codec anyway by assuming mclk is 48MHz.
>>          */
>> -       parent_clk = clk_get_parent(hw->clk);
>> -       if (!parent_clk)
>> +       parent_hw = clk_hw_get_parent(hw);
>> +       if (!parent_hw)
>>                 dev_warn(component->dev,
>>                         "Parent mclk of wclk not acquired in driver. Please ensure mclk was provided as %d Hz.\n",
>>                         CLK_PLL2_FIN);
>
> Can this code be removed? I don't know why we care to check if the clk
> has a parent or not.

I'm focusing on removing "hw->clk" where they are - w/o changing too
much what the driver does. I don't have the HW nor the story behind it
and there is about 50 more drivers to be fixed ... thankfully, most are
in drivers/clk/ ;)

Here, at least the clock consummer API is not longer used within a clock
ops, which is not great considering the locking scheme (among other things)

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

end of thread, other threads:[~2021-04-13  7:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-10 11:13 [PATCH 0/5] ASoC: clock provider clean-up Jerome Brunet
2021-04-10 11:13 ` [PATCH 1/5] ASoC: stm32: properly get clk from the provider Jerome Brunet
2021-04-12 20:25   ` Stephen Boyd
2021-04-10 11:13 ` [PATCH 2/5] ASoC: wcd934x: use the clock provider API Jerome Brunet
2021-04-12 20:26   ` Stephen Boyd
2021-04-10 11:13 ` [PATCH 3/5] ASoC: rt5682: clock driver must " Jerome Brunet
2021-04-12 20:27   ` Stephen Boyd
2021-04-13  7:31     ` Jerome Brunet
2021-04-10 11:13 ` [PATCH 4/5] ASoC: lpass: " Jerome Brunet
2021-04-12  9:38   ` Srinivas Kandagatla
2021-04-12 12:17     ` Jerome Brunet
2021-04-12 13:55       ` Srinivas Kandagatla
2021-04-10 11:13 ` [PATCH 5/5] ASoC: da7219: properly get clk from the provider Jerome Brunet
2021-04-12 20:27   ` Stephen Boyd

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).