From patchwork Wed Feb 25 21:04:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 5889621 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 467EFBF440 for ; Thu, 26 Feb 2015 08:25:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 617AC2038E for ; Thu, 26 Feb 2015 08:25:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0FB1D2022D for ; Thu, 26 Feb 2015 08:25:03 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id E77E22650D7; Thu, 26 Feb 2015 09:25:01 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id D9CB82606EE; Thu, 26 Feb 2015 09:24:20 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4D58C26060D; Wed, 25 Feb 2015 22:04:52 +0100 (CET) Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) by alsa0.perex.cz (Postfix) with ESMTP id 0E0B62605DC for ; Wed, 25 Feb 2015 22:04:44 +0100 (CET) Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 790AE140853; Wed, 25 Feb 2015 21:04:43 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 668A9140857; Wed, 25 Feb 2015 21:04:43 +0000 (UTC) Received: from [10.134.64.202] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: sboyd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4D0B5140853; Wed, 25 Feb 2015 21:04:42 +0000 (UTC) Message-ID: <54EE38E9.3060405@codeaurora.org> Date: Wed, 25 Feb 2015 13:04:41 -0800 From: Stephen Boyd User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Shawn Guo , Mike Turquette References: <1424876018-17852-1-git-send-email-shawn.guo@linaro.org> <1424876018-17852-8-git-send-email-shawn.guo@linaro.org> In-Reply-To: <1424876018-17852-8-git-send-email-shawn.guo@linaro.org> X-Virus-Scanned: ClamAV using ClamSMTP X-Mailman-Approved-At: Thu, 26 Feb 2015 09:24:19 +0100 Cc: linux-pwm@vger.kernel.org, alsa-devel@alsa-project.org, Russell King , linux-serial@vger.kernel.org, Greg Kroah-Hartman , dri-devel@lists.freedesktop.org, Mark Brown , Thierry Reding , kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org Subject: Re: [alsa-devel] [PATCH 7/8] ASoC: fsl_spdif: fix struct clk pointer comparing X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 > --- > 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 #include #include +#include #include #include @@ -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);