From patchwork Thu Mar 12 00:35:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 5989321 Return-Path: X-Original-To: patchwork-linux-arm@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 C2818BF90F for ; Thu, 12 Mar 2015 00:39:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3A9B203B0 for ; Thu, 12 Mar 2015 00:39:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A1CC1202FF for ; Thu, 12 Mar 2015 00:39:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YVr6f-0002kL-2G; Thu, 12 Mar 2015 00:36:09 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YVr6c-0002io-AX for linux-arm-kernel@lists.infradead.org; Thu, 12 Mar 2015 00:36:07 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 2458D1400EF; Thu, 12 Mar 2015 00:35:44 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 13D051400FB; Thu, 12 Mar 2015 00:35:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 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 04B521400EF; Thu, 12 Mar 2015 00:35:42 +0000 (UTC) Message-ID: <5500DF5E.7010404@codeaurora.org> Date: Wed, 11 Mar 2015 17:35:42 -0700 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: Russell King - ARM Linux , =?windows-1252?Q?Uwe_Kleine-K=F6nig?= , Mike Turquette Subject: Re: [PATCH] clk: provide clk_is_match() dummy for non-common clk References: <1424876018-17852-1-git-send-email-shawn.guo@linaro.org> <1424876018-17852-2-git-send-email-shawn.guo@linaro.org> <20150225172757.421.43718@quantum> <8682755.oK0Ae34OOP@wuerfel> <20150311102208.GX8656@n2100.arm.linux.org.uk> <20150311111755.GI952@pengutronix.de> <20150311122905.GY8656@n2100.arm.linux.org.uk> In-Reply-To: <20150311122905.GY8656@n2100.arm.linux.org.uk> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150311_173606_410726_E484C479 X-CRM114-Status: GOOD ( 25.60 ) X-Spam-Score: -0.0 (/) Cc: linux-pwm@vger.kernel.org, alsa-devel@alsa-project.org, linux-serial@vger.kernel.org, Arnd Bergmann , Greg Kroah-Hartman , dri-devel@lists.freedesktop.org, Mark Brown , Thierry Reding , kernel@pengutronix.de, Shawn Guo , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 03/11/15 05:29, Russell King - ARM Linux wrote: > On Wed, Mar 11, 2015 at 12:17:55PM +0100, Uwe Kleine-König wrote: >> Hey Russell, >> >> On Wed, Mar 11, 2015 at 10:22:09AM +0000, Russell King - ARM Linux wrote: >>> On Sun, Mar 08, 2015 at 10:05:29PM +0100, Arnd Bergmann wrote: >>>> ARM randconfig build tests found a new error for configurations >>>> with COMMON_CLK disabled but HAS_CLK selected by the platform: >>>> >>>> ERROR: "clk_is_match" [sound/soc/fsl/snd-soc-fsl-spdif.ko] undefined! >>>> >>>> This moves the declaration around, so this case is covered >>>> by the existing static inline helper function. >>>> >>>> Signed-off-by: Arnd Bergmann >>>> Fixes: c69e182e51d89 ("clk: introduce clk_is_match") >>>> ---- >>>> BTW, we have a preexisting problem in clk_get_parent, >>>> clk_round_rate and clk_set_parent, which I've worked around in >>>> my randconfig builds so far. Should we do that the same way? >>> NAK, as Uwe points out, you didn't address my comment. >> You commented on the patch that is c69e182e51d8 ("clk: introduce >> clk_is_match") now in next. Arnd just moved this around. > *Sigh* > > Mike - please remove this commit until proper kernel patch process is > honoured. We'll have some order here, and mutual respect of fellow > kernel developers, rather than people selectively ignoring people. > Yes, I realise that it fixes a bug, but it's utterly disgusting that > comments on a patch are ignored and it's just picked up irrespective > of comments being addressed. > > If you don't like that, bloody well do a better job. > The patch was *not* picked up after your mail was sent. The patch was picked up the same day it was posted to the list (Feb 25). You sent review comments a week later (March 4). I don't see any selective ignoring here. I'll fold the const comments from Geert, your comments, and Arnd's fix into the patch. Here's the new patch: ----8<---- From: Michael Turquette Subject: [PATCH] clk: introduce clk_is_match Some drivers compare struct clk pointers as a means of knowing if the two pointers reference the same clock hardware. This behavior is dubious (drivers must not dereference struct clk), but did not cause any regressions until the per-user struct clk patch was merged. Now the test for matching clk's will always fail with per-user struct clk's. clk_is_match is introduced to fix the regression and prevent drivers from comparing the pointers manually. Fixes: 035a61c314eb ("clk: Make clk API return per-user struct clk instances") Cc: Russell King Cc: Shawn Guo Cc: Tomeu Vizoso Signed-off-by: Michael Turquette [arnd@arndb.de: Fix COMMON_CLK=N && HAS_CLK=Y config] Signed-off-by: Arnd Bergmann [sboyd@codeaurora.org: const arguments to clk_is_match() and remove unnecessary ternary operation] Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 26 ++++++++++++++++++++++++++ include/linux/clk.h | 18 ++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b9f85fc2ce3f..237f23f68bfc 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2170,6 +2170,32 @@ int clk_get_phase(struct clk *clk) } /** + * clk_is_match - check if two clk's point to the same hardware clock + * @p: clk compared against q + * @q: clk compared against p + * + * Returns true if the two struct clk pointers both point to the same hardware + * clock node. Put differently, returns true if struct clk *p and struct clk *q + * share the same struct clk_core object. + * + * Returns false otherwise. Note that two NULL clks are treated as matching. + */ +bool clk_is_match(const struct clk *p, const struct clk *q) +{ + /* trivial case: identical struct clk's or both NULL */ + if (p == q) + return true; + + /* true if clk->core pointers match. Avoid derefing garbage */ + if (!IS_ERR_OR_NULL(p) && !IS_ERR_OR_NULL(q)) + if (p->core == q->core) + return true; + + return false; +} +EXPORT_SYMBOL_GPL(clk_is_match); + +/** * __clk_init - initialize the data structures in a struct clk * @dev: device initializing this clk, placeholder for now * @clk: clk being initialized diff --git a/include/linux/clk.h b/include/linux/clk.h index 8381bbfbc308..68c16a6bedb3 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -125,6 +125,19 @@ int clk_set_phase(struct clk *clk, int degrees); */ int clk_get_phase(struct clk *clk); +/** + * clk_is_match - check if two clk's point to the same hardware clock + * @p: clk compared against q + * @q: clk compared against p + * + * Returns true if the two struct clk pointers both point to the same hardware + * clock node. Put differently, returns true if struct clk *p and struct clk *q + * share the same struct clk_core object. + * + * Returns false otherwise. Note that two NULL clks are treated as matching. + */ +bool clk_is_match(const struct clk *p, const struct clk *q); + #else static inline long clk_get_accuracy(struct clk *clk) @@ -142,6 +155,11 @@ static inline long clk_get_phase(struct clk *clk) return -ENOTSUPP; } +static inline bool clk_is_match(const struct clk *p, const struct clk *q) +{ + return p == q; +} + #endif /**