linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoC: rt5682: Use clk APIs better
@ 2020-08-04  0:05 Stephen Boyd
  2020-08-04  0:05 ` [PATCH 1/3] ASoC: rt5682: Use dev_dbg() in rt5682_clk_check() Stephen Boyd
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Stephen Boyd @ 2020-08-04  0:05 UTC (permalink / raw)
  To: Mark Brown, Oder Chiou
  Cc: linux-kernel, alsa-devel, Takashi Iwai, Jaroslav Kysela,
	Cheng-Yi Chiang, Shuming Fan

This patch series drops a printk message down to dev_dbg() because it
was noisy and then migrates this driver to use clk_hw based APIs instead
of clk based APIs because this device is a clk provider, not a clk
consumer. I've only lightly tested the last two patches but I don't have
all combinations of clks for this device.

Cc: Cheng-Yi Chiang <cychiang@chromium.org>
Cc: Shuming Fan <shumingf@realtek.com>

Stephen Boyd (3):
  ASoC: rt5682: Use dev_dbg() in rt5682_clk_check()
  ASoC: rt5682: Drop usage of __clk_get_name()
  ASoC: rt5682: Use clk_hw based APIs for registration

 sound/soc/codecs/rt5682.c | 73 ++++++++++++---------------------------
 sound/soc/codecs/rt5682.h |  2 --
 2 files changed, 23 insertions(+), 52 deletions(-)

Based on the last patch to this driver in linux-next.

base-commit: 6301adf942a31bed65e026a554e5bd55d9e731e1
-- 
Sent by a computer, using git, on the internet


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

* [PATCH 1/3] ASoC: rt5682: Use dev_dbg() in rt5682_clk_check()
  2020-08-04  0:05 [PATCH 0/3] ASoC: rt5682: Use clk APIs better Stephen Boyd
@ 2020-08-04  0:05 ` Stephen Boyd
  2020-08-04  0:05 ` [PATCH 2/3] ASoC: rt5682: Drop usage of __clk_get_name() Stephen Boyd
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2020-08-04  0:05 UTC (permalink / raw)
  To: Mark Brown, Oder Chiou
  Cc: linux-kernel, alsa-devel, Takashi Iwai, Jaroslav Kysela,
	Cheng-Yi Chiang, Shuming Fan

I see a spew of "sysclk/dai not set correctly" whenever I cat
/sys/kernel/debug/clk/clk_summary on my device. This is because the
master pointer isn't set yet in this driver. A user isn't going to be
able to do much if this check is failing so this error message isn't
really an error, it's more of a kernel debug message. Lower the priority
to dev_dbg() so that it isn't so noisy.

Cc: Cheng-Yi Chiang <cychiang@chromium.org>
Cc: Shuming Fan <shumingf@realtek.com>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 sound/soc/codecs/rt5682.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index fab066a75ce0..ed9475f24aec 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -2482,7 +2482,7 @@ static int rt5682_set_bias_level(struct snd_soc_component *component,
 static bool rt5682_clk_check(struct rt5682_priv *rt5682)
 {
 	if (!rt5682->master[RT5682_AIF1]) {
-		dev_err(rt5682->component->dev, "sysclk/dai not set correctly\n");
+		dev_dbg(rt5682->component->dev, "sysclk/dai not set correctly\n");
 		return false;
 	}
 	return true;
-- 
Sent by a computer, using git, on the internet


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

* [PATCH 2/3] ASoC: rt5682: Drop usage of __clk_get_name()
  2020-08-04  0:05 [PATCH 0/3] ASoC: rt5682: Use clk APIs better Stephen Boyd
  2020-08-04  0:05 ` [PATCH 1/3] ASoC: rt5682: Use dev_dbg() in rt5682_clk_check() Stephen Boyd
@ 2020-08-04  0:05 ` Stephen Boyd
  2020-08-04  0:05 ` [PATCH 3/3] ASoC: rt5682: Use clk_hw based APIs for registration Stephen Boyd
  2020-08-18 16:56 ` [PATCH 0/3] ASoC: rt5682: Use clk APIs better Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2020-08-04  0:05 UTC (permalink / raw)
  To: Mark Brown, Oder Chiou
  Cc: linux-kernel, alsa-devel, Takashi Iwai, Jaroslav Kysela,
	Cheng-Yi Chiang, Shuming Fan

The __clk_get_name() API is deprecated. Use clk_hw_get_name() or
proper registration techniques to avoid it.

Cc: Cheng-Yi Chiang <cychiang@chromium.org>
Cc: Shuming Fan <shumingf@realtek.com>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 sound/soc/codecs/rt5682.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index ed9475f24aec..d8a1973a4624 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -2548,7 +2548,7 @@ static unsigned long rt5682_wclk_recalc_rate(struct clk_hw *hw,
 		container_of(hw, struct rt5682_priv,
 			     dai_clks_hw[RT5682_DAI_WCLK_IDX]);
 	struct snd_soc_component *component = rt5682->component;
-	const char * const clk_name = __clk_get_name(hw->clk);
+	const char * const clk_name = clk_hw_get_name(hw);
 
 	if (!rt5682_clk_check(rt5682))
 		return 0;
@@ -2572,7 +2572,7 @@ static long rt5682_wclk_round_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;
-	const char * const clk_name = __clk_get_name(hw->clk);
+	const char * const clk_name = clk_hw_get_name(hw);
 
 	if (!rt5682_clk_check(rt5682))
 		return -EINVAL;
@@ -2597,7 +2597,7 @@ static int rt5682_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
 			     dai_clks_hw[RT5682_DAI_WCLK_IDX]);
 	struct snd_soc_component *component = rt5682->component;
 	struct clk *parent_clk;
-	const char * const clk_name = __clk_get_name(hw->clk);
+	const char * const clk_name = clk_hw_get_name(hw);
 	int pre_div;
 	unsigned int clk_pll2_out;
 
@@ -2755,33 +2755,31 @@ static int rt5682_register_dai_clks(struct snd_soc_component *component)
 	struct device *dev = component->dev;
 	struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
 	struct rt5682_platform_data *pdata = &rt5682->pdata;
-	struct clk_init_data init;
 	struct clk *dai_clk;
 	struct clk_lookup *dai_clk_lookup;
 	struct clk_hw *dai_clk_hw;
-	const char *parent_name;
 	int i, ret;
 
 	for (i = 0; i < RT5682_DAI_NUM_CLKS; ++i) {
+		struct clk_init_data init = { };
+
 		dai_clk_hw = &rt5682->dai_clks_hw[i];
 
 		switch (i) {
 		case RT5682_DAI_WCLK_IDX:
 			/* Make MCLK the parent of WCLK */
 			if (rt5682->mclk) {
-				parent_name = __clk_get_name(rt5682->mclk);
-				init.parent_names = &parent_name;
+				init.parent_data = &(struct clk_parent_data){
+					.fw_name = "mclk",
+				};
 				init.num_parents = 1;
-			} else {
-				init.parent_names = NULL;
-				init.num_parents = 0;
 			}
 			break;
 		case RT5682_DAI_BCLK_IDX:
 			/* Make WCLK the parent of BCLK */
-			parent_name = __clk_get_name(
-				rt5682->dai_clks[RT5682_DAI_WCLK_IDX]);
-			init.parent_names = &parent_name;
+			init.parent_hws = &(const struct clk_hw *){
+				&rt5682->dai_clks_hw[RT5682_DAI_WCLK_IDX]
+			};
 			init.num_parents = 1;
 			break;
 		default:
-- 
Sent by a computer, using git, on the internet


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

* [PATCH 3/3] ASoC: rt5682: Use clk_hw based APIs for registration
  2020-08-04  0:05 [PATCH 0/3] ASoC: rt5682: Use clk APIs better Stephen Boyd
  2020-08-04  0:05 ` [PATCH 1/3] ASoC: rt5682: Use dev_dbg() in rt5682_clk_check() Stephen Boyd
  2020-08-04  0:05 ` [PATCH 2/3] ASoC: rt5682: Drop usage of __clk_get_name() Stephen Boyd
@ 2020-08-04  0:05 ` Stephen Boyd
  2020-08-18 16:56 ` [PATCH 0/3] ASoC: rt5682: Use clk APIs better Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2020-08-04  0:05 UTC (permalink / raw)
  To: Mark Brown, Oder Chiou
  Cc: linux-kernel, alsa-devel, Takashi Iwai, Jaroslav Kysela,
	Cheng-Yi Chiang, Shuming Fan

The (new?) style of clk registration uses clk_hw based APIs so that we
can more easily see the difference between clk providers and clk
consumers. Use the clk_hw based APIs to do this and migrate to devm for
the clkdev creation so that we can reduce the amount of code.

Cc: Cheng-Yi Chiang <cychiang@chromium.org>
Cc: Shuming Fan <shumingf@realtek.com>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 sound/soc/codecs/rt5682.c | 47 +++++++++------------------------------
 sound/soc/codecs/rt5682.h |  2 --
 2 files changed, 11 insertions(+), 38 deletions(-)

diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index d8a1973a4624..bfb26fec7137 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -2755,8 +2755,6 @@ static int rt5682_register_dai_clks(struct snd_soc_component *component)
 	struct device *dev = component->dev;
 	struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
 	struct rt5682_platform_data *pdata = &rt5682->pdata;
-	struct clk *dai_clk;
-	struct clk_lookup *dai_clk_lookup;
 	struct clk_hw *dai_clk_hw;
 	int i, ret;
 
@@ -2784,8 +2782,7 @@ static int rt5682_register_dai_clks(struct snd_soc_component *component)
 			break;
 		default:
 			dev_err(dev, "Invalid clock index\n");
-			ret = -EINVAL;
-			goto err;
+			return -EINVAL;
 		}
 
 		init.name = pdata->dai_clk_names[i];
@@ -2793,39 +2790,26 @@ static int rt5682_register_dai_clks(struct snd_soc_component *component)
 		init.flags = CLK_GET_RATE_NOCACHE | CLK_SET_RATE_GATE;
 		dai_clk_hw->init = &init;
 
-		dai_clk = devm_clk_register(dev, dai_clk_hw);
-		if (IS_ERR(dai_clk)) {
-			dev_warn(dev, "Failed to register %s: %ld\n",
-				 init.name, PTR_ERR(dai_clk));
-			ret = PTR_ERR(dai_clk);
-			goto err;
+		ret = devm_clk_hw_register(dev, dai_clk_hw);
+		if (ret) {
+			dev_warn(dev, "Failed to register %s: %d\n",
+				 init.name, ret);
+			return ret;
 		}
-		rt5682->dai_clks[i] = dai_clk;
 
 		if (dev->of_node) {
 			devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
 						    dai_clk_hw);
 		} else {
-			dai_clk_lookup = clkdev_create(dai_clk, init.name,
-						       "%s", dev_name(dev));
-			if (!dai_clk_lookup) {
-				ret = -ENOMEM;
-				goto err;
-			} else {
-				rt5682->dai_clks_lookup[i] = dai_clk_lookup;
-			}
+			ret = devm_clk_hw_register_clkdev(dev, dai_clk_hw,
+							  init.name,
+							  dev_name(dev));
+			if (ret)
+				return ret;
 		}
 	}
 
 	return 0;
-
-err:
-	do {
-		if (rt5682->dai_clks_lookup[i])
-			clkdev_drop(rt5682->dai_clks_lookup[i]);
-	} while (i-- > 0);
-
-	return ret;
 }
 #endif /* CONFIG_COMMON_CLK */
 
@@ -2882,15 +2866,6 @@ static void rt5682_remove(struct snd_soc_component *component)
 {
 	struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
 
-#ifdef CONFIG_COMMON_CLK
-	int i;
-
-	for (i = RT5682_DAI_NUM_CLKS - 1; i >= 0; --i) {
-		if (rt5682->dai_clks_lookup[i])
-			clkdev_drop(rt5682->dai_clks_lookup[i]);
-	}
-#endif
-
 	rt5682_reset(rt5682);
 }
 
diff --git a/sound/soc/codecs/rt5682.h b/sound/soc/codecs/rt5682.h
index 6d94327beae5..354acd735ef4 100644
--- a/sound/soc/codecs/rt5682.h
+++ b/sound/soc/codecs/rt5682.h
@@ -1411,8 +1411,6 @@ struct rt5682_priv {
 
 #ifdef CONFIG_COMMON_CLK
 	struct clk_hw dai_clks_hw[RT5682_DAI_NUM_CLKS];
-	struct clk_lookup *dai_clks_lookup[RT5682_DAI_NUM_CLKS];
-	struct clk *dai_clks[RT5682_DAI_NUM_CLKS];
 	struct clk *mclk;
 #endif
 
-- 
Sent by a computer, using git, on the internet


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

* Re: [PATCH 0/3] ASoC: rt5682: Use clk APIs better
  2020-08-04  0:05 [PATCH 0/3] ASoC: rt5682: Use clk APIs better Stephen Boyd
                   ` (2 preceding siblings ...)
  2020-08-04  0:05 ` [PATCH 3/3] ASoC: rt5682: Use clk_hw based APIs for registration Stephen Boyd
@ 2020-08-18 16:56 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2020-08-18 16:56 UTC (permalink / raw)
  To: Stephen Boyd, Oder Chiou
  Cc: Shuming Fan, Cheng-Yi Chiang, linux-kernel, alsa-devel, Takashi Iwai

On Mon, 3 Aug 2020 17:05:28 -0700, Stephen Boyd wrote:
> This patch series drops a printk message down to dev_dbg() because it
> was noisy and then migrates this driver to use clk_hw based APIs instead
> of clk based APIs because this device is a clk provider, not a clk
> consumer. I've only lightly tested the last two patches but I don't have
> all combinations of clks for this device.
> 
> Cc: Cheng-Yi Chiang <cychiang@chromium.org>
> Cc: Shuming Fan <shumingf@realtek.com>
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: rt5682: Use dev_dbg() in rt5682_clk_check()
      commit: 0b95aa8e8afa4bcd49c8fa36404e2deb02a947ed
[2/3] ASoC: rt5682: Drop usage of __clk_get_name()
      commit: edbd24ea1e5c72980b37ae2d271696b05274d509
[3/3] ASoC: rt5682: Use clk_hw based APIs for registration
      commit: 653bdab267bd8dbce9cbd16bec843ca9d20a8450

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

end of thread, other threads:[~2020-08-18 16:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04  0:05 [PATCH 0/3] ASoC: rt5682: Use clk APIs better Stephen Boyd
2020-08-04  0:05 ` [PATCH 1/3] ASoC: rt5682: Use dev_dbg() in rt5682_clk_check() Stephen Boyd
2020-08-04  0:05 ` [PATCH 2/3] ASoC: rt5682: Drop usage of __clk_get_name() Stephen Boyd
2020-08-04  0:05 ` [PATCH 3/3] ASoC: rt5682: Use clk_hw based APIs for registration Stephen Boyd
2020-08-18 16:56 ` [PATCH 0/3] ASoC: rt5682: Use clk APIs better Mark Brown

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