All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@codeaurora.org>
To: Shawn Guo <shawn.guo@linaro.org>, Mike Turquette <mturquette@linaro.org>
Cc: linux-pwm@vger.kernel.org, alsa-devel@alsa-project.org,
	Russell King <linux@arm.linux.org.uk>,
	linux-serial@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	dri-devel@lists.freedesktop.org, Mark Brown <broonie@kernel.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 7/8] ASoC: fsl_spdif: fix struct clk pointer comparing
Date: Wed, 25 Feb 2015 13:04:41 -0800	[thread overview]
Message-ID: <54EE38E9.3060405@codeaurora.org> (raw)
In-Reply-To: <1424876018-17852-8-git-send-email-shawn.guo@linaro.org>

On 02/25/15 06:53, Shawn Guo wrote:
> Since commit 035a61c314eb ("clk: Make clk API return per-user struct clk
> instances"), clk API users can no longer check if two struct clk
> pointers are pointing to the same hardware clock, i.e. struct clk_hw, by
> simply comparing two pointers.  That's because with the per-user clk
> change, a brand new struct clk is created whenever clients try to look
> up the clock by calling clk_get() or sister functions like clk_get_sys()
> and of_clk_get().  This changes the original behavior where the struct
> clk is only created for once when clock driver registers the clock to
> CCF in the first place.  The net change here is before commit
> 035a61c314eb the struct clk pointer is unique for given hardware
> clock, while after the commit the pointers returned by clk lookup calls
> become different for the same hardware clock.
>
> That said, the struct clk pointer comparing in the code doesn't work any
> more.  Call helper function clk_is_match() instead to fix the problem.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  sound/soc/fsl/fsl_spdif.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
> index 75870c0ea2c9..91eb3aef7f02 100644
> --- a/sound/soc/fsl/fsl_spdif.c
> +++ b/sound/soc/fsl/fsl_spdif.c
> @@ -1049,7 +1049,7 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv,
>  				enum spdif_txrate index, bool round)
>  {
>  	const u32 rate[] = { 32000, 44100, 48000, 96000, 192000 };
> -	bool is_sysclk = clk == spdif_priv->sysclk;
> +	bool is_sysclk = clk_is_match(clk, spdif_priv->sysclk);
>  	u64 rate_ideal, rate_actual, sub;
>  	u32 sysclk_dfmin, sysclk_dfmax;
>  	u32 txclk_df, sysclk_df, arate;
> @@ -1143,7 +1143,7 @@ static int fsl_spdif_probe_txclk(struct fsl_spdif_priv *spdif_priv,
>  			spdif_priv->txclk_src[index], rate[index]);
>  	dev_dbg(&pdev->dev, "use txclk df %d for %dHz sample rate\n",
>  			spdif_priv->txclk_df[index], rate[index]);
> -	if (spdif_priv->txclk[index] == spdif_priv->sysclk)
> +	if (clk_is_match(spdif_priv->txclk[index], spdif_priv->sysclk))
>  		dev_dbg(&pdev->dev, "use sysclk df %d for %dHz sample rate\n",
>  				spdif_priv->sysclk_df[index], rate[index]);
>  	dev_dbg(&pdev->dev, "the best rate for %dHz sample rate is %dHz\n",

Couldn't this be fixed like this?

----8<----

diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
index af0429421fc8..1878dd62a247 100644
--- a/sound/soc/fsl/fsl_spdif.c
+++ b/sound/soc/fsl/fsl_spdif.c
@@ -20,6 +20,7 @@
 #include <linux/of_device.h>
 #include <linux/of_irq.h>
 #include <linux/regmap.h>
+#include <linux/stringify.h>
 
 #include <sound/asoundef.h>
 #include <sound/dmaengine_pcm.h>
@@ -46,6 +47,8 @@ static u8 srpc_dpll_locked[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0xa, 0xb };
 
 #define DEFAULT_RXCLK_SRC	1
 
+#define SYSCLK_NUM		5
+
 /*
  * SPDIF control structure
  * Defines channel status, subcode and Q sub
@@ -1051,10 +1054,10 @@ static const struct regmap_config fsl_spdif_regmap_config = {
 
 static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv,
 				struct clk *clk, u64 savesub,
-				enum spdif_txrate index, bool round)
+				enum spdif_txrate index, bool round,
+				bool is_sysclk)
 {
 	const u32 rate[] = { 32000, 44100, 48000, 96000, 192000 };
-	bool is_sysclk = clk == spdif_priv->sysclk;
 	u64 rate_ideal, rate_actual, sub;
 	u32 sysclk_dfmin, sysclk_dfmax;
 	u32 txclk_df, sysclk_df, arate;
@@ -1131,7 +1134,8 @@ static int fsl_spdif_probe_txclk(struct fsl_spdif_priv *spdif_priv,
 			continue;
 
 		ret = fsl_spdif_txclk_caldiv(spdif_priv, clk, savesub, index,
-					     i == STC_TXCLK_SPDIF_ROOT);
+					     i == STC_TXCLK_SPDIF_ROOT,
+					     i == SYSCLK_NUM);
 		if (savesub == ret)
 			continue;
 
@@ -1210,7 +1214,8 @@ static int fsl_spdif_probe(struct platform_device *pdev)
 	}
 
 	/* Get system clock for rx clock rate calculation */
-	spdif_priv->sysclk = devm_clk_get(&pdev->dev, "rxtx5");
+	spdif_priv->sysclk = devm_clk_get(&pdev->dev,
+					  "rxtx" __stringify(SYSCLK_NUM));
 	if (IS_ERR(spdif_priv->sysclk)) {
 		dev_err(&pdev->dev, "no sys clock (rxtx5) in devicetree\n");
 		return PTR_ERR(spdif_priv->sysclk);


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

WARNING: multiple messages have this Message-ID (diff)
From: sboyd@codeaurora.org (Stephen Boyd)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 7/8] ASoC: fsl_spdif: fix struct clk pointer comparing
Date: Wed, 25 Feb 2015 13:04:41 -0800	[thread overview]
Message-ID: <54EE38E9.3060405@codeaurora.org> (raw)
In-Reply-To: <1424876018-17852-8-git-send-email-shawn.guo@linaro.org>

On 02/25/15 06:53, Shawn Guo wrote:
> Since commit 035a61c314eb ("clk: Make clk API return per-user struct clk
> instances"), clk API users can no longer check if two struct clk
> pointers are pointing to the same hardware clock, i.e. struct clk_hw, by
> simply comparing two pointers.  That's because with the per-user clk
> change, a brand new struct clk is created whenever clients try to look
> up the clock by calling clk_get() or sister functions like clk_get_sys()
> and of_clk_get().  This changes the original behavior where the struct
> clk is only created for once when clock driver registers the clock to
> CCF in the first place.  The net change here is before commit
> 035a61c314eb the struct clk pointer is unique for given hardware
> clock, while after the commit the pointers returned by clk lookup calls
> become different for the same hardware clock.
>
> That said, the struct clk pointer comparing in the code doesn't work any
> more.  Call helper function clk_is_match() instead to fix the problem.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  sound/soc/fsl/fsl_spdif.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
> index 75870c0ea2c9..91eb3aef7f02 100644
> --- a/sound/soc/fsl/fsl_spdif.c
> +++ b/sound/soc/fsl/fsl_spdif.c
> @@ -1049,7 +1049,7 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv,
>  				enum spdif_txrate index, bool round)
>  {
>  	const u32 rate[] = { 32000, 44100, 48000, 96000, 192000 };
> -	bool is_sysclk = clk == spdif_priv->sysclk;
> +	bool is_sysclk = clk_is_match(clk, spdif_priv->sysclk);
>  	u64 rate_ideal, rate_actual, sub;
>  	u32 sysclk_dfmin, sysclk_dfmax;
>  	u32 txclk_df, sysclk_df, arate;
> @@ -1143,7 +1143,7 @@ static int fsl_spdif_probe_txclk(struct fsl_spdif_priv *spdif_priv,
>  			spdif_priv->txclk_src[index], rate[index]);
>  	dev_dbg(&pdev->dev, "use txclk df %d for %dHz sample rate\n",
>  			spdif_priv->txclk_df[index], rate[index]);
> -	if (spdif_priv->txclk[index] == spdif_priv->sysclk)
> +	if (clk_is_match(spdif_priv->txclk[index], spdif_priv->sysclk))
>  		dev_dbg(&pdev->dev, "use sysclk df %d for %dHz sample rate\n",
>  				spdif_priv->sysclk_df[index], rate[index]);
>  	dev_dbg(&pdev->dev, "the best rate for %dHz sample rate is %dHz\n",

Couldn't this be fixed like this?

----8<----

diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
index af0429421fc8..1878dd62a247 100644
--- a/sound/soc/fsl/fsl_spdif.c
+++ b/sound/soc/fsl/fsl_spdif.c
@@ -20,6 +20,7 @@
 #include <linux/of_device.h>
 #include <linux/of_irq.h>
 #include <linux/regmap.h>
+#include <linux/stringify.h>
 
 #include <sound/asoundef.h>
 #include <sound/dmaengine_pcm.h>
@@ -46,6 +47,8 @@ static u8 srpc_dpll_locked[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0xa, 0xb };
 
 #define DEFAULT_RXCLK_SRC	1
 
+#define SYSCLK_NUM		5
+
 /*
  * SPDIF control structure
  * Defines channel status, subcode and Q sub
@@ -1051,10 +1054,10 @@ static const struct regmap_config fsl_spdif_regmap_config = {
 
 static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv,
 				struct clk *clk, u64 savesub,
-				enum spdif_txrate index, bool round)
+				enum spdif_txrate index, bool round,
+				bool is_sysclk)
 {
 	const u32 rate[] = { 32000, 44100, 48000, 96000, 192000 };
-	bool is_sysclk = clk == spdif_priv->sysclk;
 	u64 rate_ideal, rate_actual, sub;
 	u32 sysclk_dfmin, sysclk_dfmax;
 	u32 txclk_df, sysclk_df, arate;
@@ -1131,7 +1134,8 @@ static int fsl_spdif_probe_txclk(struct fsl_spdif_priv *spdif_priv,
 			continue;
 
 		ret = fsl_spdif_txclk_caldiv(spdif_priv, clk, savesub, index,
-					     i == STC_TXCLK_SPDIF_ROOT);
+					     i == STC_TXCLK_SPDIF_ROOT,
+					     i == SYSCLK_NUM);
 		if (savesub == ret)
 			continue;
 
@@ -1210,7 +1214,8 @@ static int fsl_spdif_probe(struct platform_device *pdev)
 	}
 
 	/* Get system clock for rx clock rate calculation */
-	spdif_priv->sysclk = devm_clk_get(&pdev->dev, "rxtx5");
+	spdif_priv->sysclk = devm_clk_get(&pdev->dev,
+					  "rxtx" __stringify(SYSCLK_NUM));
 	if (IS_ERR(spdif_priv->sysclk)) {
 		dev_err(&pdev->dev, "no sys clock (rxtx5) in devicetree\n");
 		return PTR_ERR(spdif_priv->sysclk);


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2015-02-25 21:04 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-25 14:53 [PATCH 0/8] Fix struct clk pointer comparing Shawn Guo
2015-02-25 14:53 ` Shawn Guo
2015-02-25 14:53 ` [PATCH 1/8] clk: add helper function clk_is_match() Shawn Guo
2015-02-25 14:53   ` Shawn Guo
2015-02-25 17:27   ` Mike Turquette
2015-02-25 17:27     ` Mike Turquette
2015-02-26  0:37     ` Shawn Guo
2015-02-26  0:37       ` Shawn Guo
2015-02-26  9:02     ` Ben Dooks
2015-02-26  9:02       ` [alsa-devel] " Ben Dooks
2015-02-26  9:56       ` Philipp Zabel
2015-02-26  9:56         ` Philipp Zabel
2015-02-26 11:25         ` Ben Dooks
2015-02-26 11:25           ` Ben Dooks
2015-02-26 11:59           ` Ricard Wanderlof
2015-02-26 11:59             ` Ricard Wanderlof
2015-03-04  8:55     ` Geert Uytterhoeven
2015-03-04  8:55       ` Geert Uytterhoeven
2015-03-04  9:51     ` Russell King - ARM Linux
2015-03-04  9:51       ` Russell King - ARM Linux
2015-03-08 21:05     ` [PATCH] clk: provide clk_is_match() dummy for non-common clk Arnd Bergmann
2015-03-08 21:05       ` Arnd Bergmann
2015-03-10 21:42       ` Geert Uytterhoeven
2015-03-10 21:42         ` Geert Uytterhoeven
2015-03-11  7:09       ` Uwe Kleine-König
2015-03-11  7:09         ` Uwe Kleine-König
2015-03-11 10:22       ` Russell King - ARM Linux
2015-03-11 10:22         ` Russell King - ARM Linux
2015-03-11 11:17         ` Uwe Kleine-König
2015-03-11 11:17           ` Uwe Kleine-König
2015-03-11 12:29           ` Russell King - ARM Linux
2015-03-11 12:29             ` Russell King - ARM Linux
2015-03-12  0:35             ` Stephen Boyd
2015-03-12  0:35               ` Stephen Boyd
2015-02-25 14:53 ` [PATCH 2/8] ARM: imx: fix struct clk pointer comparing Shawn Guo
2015-02-25 14:53   ` Shawn Guo
2015-02-25 14:53 ` [PATCH 3/8] drm: armada: " Shawn Guo
2015-02-25 14:53   ` Shawn Guo
2015-02-25 14:53 ` [PATCH 4/8] pwm: atmel-hlcdc: " Shawn Guo
2015-02-25 14:53   ` Shawn Guo
2015-02-26  9:22   ` Nicolas Ferre
2015-02-26  9:22     ` Nicolas Ferre
2015-02-26  9:31     ` Boris Brezillon
2015-02-26  9:31       ` Boris Brezillon
2015-03-11 10:54   ` Thierry Reding
2015-03-11 10:54     ` Thierry Reding
2015-02-25 14:53 ` [PATCH 5/8] serial: samsung: " Shawn Guo
2015-02-25 14:53   ` Shawn Guo
2015-02-25 14:53 ` [PATCH 6/8] ASoC: fsl_esai: " Shawn Guo
2015-02-25 14:53   ` Shawn Guo
2015-02-26  2:36   ` Mark Brown
2015-02-26  2:36     ` Mark Brown
2015-02-25 14:53 ` [PATCH 7/8] ASoC: fsl_spdif: " Shawn Guo
2015-02-25 14:53   ` Shawn Guo
2015-02-25 21:04   ` Stephen Boyd [this message]
2015-02-25 21:04     ` Stephen Boyd
2015-02-26  1:17     ` Shawn Guo
2015-02-26  1:17       ` Shawn Guo
2015-02-26  2:12   ` Mark Brown
2015-02-26  2:12     ` Mark Brown
2015-02-26  2:20     ` Shawn Guo
2015-02-26  2:20       ` Shawn Guo
2015-02-26  2:29       ` Mark Brown
2015-02-26  2:29         ` Mark Brown
2015-02-26  2:36   ` Mark Brown
2015-02-26  2:36     ` Mark Brown
2015-02-25 14:53 ` [PATCH 8/8] ASoC: kirkwood: " Shawn Guo
2015-02-25 14:53   ` Shawn Guo
2015-02-26  2:12   ` Mark Brown
2015-02-26  2:12     ` Mark Brown
2015-02-26  2:36   ` Mark Brown
2015-02-26  2:36     ` Mark Brown
2015-02-25 15:03 ` [PATCH 0/8] Fix " Russell King - ARM Linux
2015-02-25 15:03   ` Russell King - ARM Linux
2015-02-25 17:55   ` Mike Turquette
2015-02-25 17:55     ` Mike Turquette
2015-02-25 20:42     ` Stephen Boyd
2015-02-25 20:42       ` Stephen Boyd
2015-02-26  1:21       ` Shawn Guo
2015-02-26  1:21         ` Shawn Guo
2015-02-26  1:24       ` Mike Turquette
2015-02-26  1:24         ` Mike Turquette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54EE38E9.3060405@codeaurora.org \
    --to=sboyd@codeaurora.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mturquette@linaro.org \
    --cc=shawn.guo@linaro.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.