From patchwork Wed Feb 25 14:53:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 5880661 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 70782BF440 for ; Wed, 25 Feb 2015 14:59:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 85E0A20263 for ; Wed, 25 Feb 2015 14:59:09 +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 A7A0C2025B for ; Wed, 25 Feb 2015 14:59:08 +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 1YQdOF-00053w-NY; Wed, 25 Feb 2015 14:56:43 +0000 Received: from mail-pd0-f181.google.com ([209.85.192.181]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YQdMi-00031K-Lc for linux-arm-kernel@lists.infradead.org; Wed, 25 Feb 2015 14:55:09 +0000 Received: by pdev10 with SMTP id v10so5362005pde.7 for ; Wed, 25 Feb 2015 06:54:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WdQzAYHMkZmqOKH9GJ6PxrA2AmT18G3kGaelnERchaE=; b=JxL9c02EZXbTAEugK01ZPhzwmc4DJVA5ujnVtsZR0f72O3B8NPG7fOS9CKBH25AZCF s1kd0CFquxymVx4tO2rTGTnddwe2qxnkL5n6sCsXT4H1IFX2YCJrDAq5qcPL7n/dCGVR OBAz/0c5Bz/4q3RLK3yuVrXtdEYxnO343tNfAYmTbL2bFMuDG9ROghSgZYDNBwSCXTFB aoDkvdCfITspeXLzGnRVgNW7q12fQgHDt/TiC38TQSqLTfohks3o3EC01lre4YrVOy+b 5xnpTL1vxbZXqCKK7E3NUlhGpQXErJumUTUtoQBYGUexp7F3OX26B7Bt2+Osd7PlRr76 HK2w== X-Gm-Message-State: ALoCoQlhaegqjNwUkR4jGL7AvpHf9/m6VbgCOgy7I4jHIiEs/XZaYvVmAxhsuDFEseqZ2E21InSu X-Received: by 10.68.183.67 with SMTP id ek3mr5871212pbc.145.1424876087492; Wed, 25 Feb 2015 06:54:47 -0800 (PST) Received: from localhost.localdomain (119.81.172.112-static.reverse.softlayer.com. [119.81.172.112]) by mx.google.com with ESMTPSA id nd5sm41502517pbc.64.2015.02.25.06.54.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Feb 2015 06:54:46 -0800 (PST) From: Shawn Guo To: Mike Turquette Subject: [PATCH 1/8] clk: add helper function clk_is_match() Date: Wed, 25 Feb 2015 22:53:31 +0800 Message-Id: <1424876018-17852-2-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424876018-17852-1-git-send-email-shawn.guo@linaro.org> References: <1424876018-17852-1-git-send-email-shawn.guo@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150225_065508_781960_83B51DC2 X-CRM114-Status: GOOD ( 13.99 ) X-Spam-Score: -0.7 (/) Cc: linux-pwm@vger.kernel.org, alsa-devel@alsa-project.org, Russell King , linux-serial@vger.kernel.org, Greg Kroah-Hartman , Mark Brown , Stephen Boyd , dri-devel@lists.freedesktop.org, 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. A number of client drivers detecting if two struct clk pointers point to the same one hardware clock by comparing the pointers are broken now. As a stop-gap solution, this patch adds a helper function clk_is_match() to test if two struct clk pointers point to the same hardware clock, so that these client drivers can use to fix the regression. Signed-off-by: Shawn Guo --- drivers/clk/clk.c | 6 ++++++ include/linux/clk.h | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index eb0152961d3c..7df4826d9c7b 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -597,6 +597,12 @@ struct clk *__clk_get_parent(struct clk *clk) } EXPORT_SYMBOL_GPL(__clk_get_parent); +bool clk_is_match(struct clk *clk1, struct clk *clk2) +{ + return __clk_get_hw(clk1) == __clk_get_hw(clk2) ? true : false; +} +EXPORT_SYMBOL_GPL(clk_is_match); + static struct clk_core *clk_core_get_parent_by_index(struct clk_core *clk, u8 index) { diff --git a/include/linux/clk.h b/include/linux/clk.h index 8381bbfbc308..f8a8a6dd6a98 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -376,6 +376,17 @@ struct clk *clk_get_parent(struct clk *clk); */ struct clk *clk_get_sys(const char *dev_id, const char *con_id); +/** + * clk_is_match - test if two given struct clk pointers point to the same + * hardware clock, i.e. struct clk_hw. + * @clk1: the first clk + * @clk2: the second clk + * + * Returns true if two clk pointers point to the same hardware clock, + * or false otherwise. + */ +bool clk_is_match(struct clk *clk1, struct clk *clk2); + #else /* !CONFIG_HAVE_CLK */ static inline struct clk *clk_get(struct device *dev, const char *id) @@ -429,6 +440,11 @@ static inline struct clk *clk_get_parent(struct clk *clk) return NULL; } +static inline bool clk_is_match(struct clk *clk1, struct clk *clk2) +{ + return clk1 == clk2 ? true : false; +} + #endif /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */