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: 45069 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9647020502 for ; Wed, 25 Feb 2015 14:54:53 +0000 (UTC) Received: by lbiw7 with SMTP id w7sf3327160lbi.0 for ; Wed, 25 Feb 2015 06:54:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=7Od+6XEWnvyvKGE0gfK7PlUs8U/vDlhp9oLtsZGrOKQ=; b=IXS58dBTeMDyqUSn/17K0Y+ZAATiZ/E/4iG818vDd0p9UuwoTwj1RBadpdDP8nA7kI RqHma1kSop5ww7KfqKE/8b4q56IVGjbk72tzkmBP9RIIbz1VO3UaFiBCU56cEjHz/RPb F+ALT20ha+JPSxsbchTXz5eyZ/62s2e3dZPxJnA0F4P6q0jfWcCOlEMJFTOi+Cp8c76p T323ZgHojxSatmTnWr0hzis19F9o+k1A8U++1zVxg+J8JNq6IuDJHTBIQgMDErR6g8gu Vj7pGYqikrnrTEMcZAQo6CLPK4oBQTGVTg7gLwsxM2uqNserVKR3OZuAsdWsI3TcIVGy TPjA== X-Gm-Message-State: ALoCoQmH4AgjK/3eSZDA5MnpVC+59bTQOtoc2AwdYOhpLvPELLZtM014DXQcoMAOY20YrZOKnvKh X-Received: by 10.112.40.81 with SMTP id v17mr549831lbk.5.1424876092032; Wed, 25 Feb 2015 06:54:52 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.169 with SMTP id x9ls396929lal.108.gmail; Wed, 25 Feb 2015 06:54:51 -0800 (PST) X-Received: by 10.112.46.201 with SMTP id x9mr3101506lbm.65.1424876091887; Wed, 25 Feb 2015 06:54:51 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id zg5si7200666lbb.82.2015.02.25.06.54.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 06:54:51 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lamq1 with SMTP id q1so4403682lam.5 for ; Wed, 25 Feb 2015 06:54:51 -0800 (PST) X-Received: by 10.152.21.100 with SMTP id u4mr3038363lae.41.1424876091601; Wed, 25 Feb 2015 06:54:51 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2668324lbj; Wed, 25 Feb 2015 06:54:50 -0800 (PST) X-Received: by 10.66.124.225 with SMTP id ml1mr6018397pab.142.1424876089832; Wed, 25 Feb 2015 06:54:49 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xt17si24191169pac.212.2015.02.25.06.54.49 for ; Wed, 25 Feb 2015 06:54:49 -0800 (PST) Received-SPF: none (google.com: linux-serial-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752593AbbBYOys (ORCPT ); Wed, 25 Feb 2015 09:54:48 -0500 Received: from mail-pd0-f182.google.com ([209.85.192.182]:45492 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752516AbbBYOyr (ORCPT ); Wed, 25 Feb 2015 09:54:47 -0500 Received: by pdjz10 with SMTP id z10so5313709pdj.12 for ; Wed, 25 Feb 2015 06:54:47 -0800 (PST) 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 Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de, Russell King , Stephen Boyd , Thierry Reding , Greg Kroah-Hartman , Mark Brown , linux-pwm@vger.kernel.org, alsa-devel@alsa-project.org, dri-devel@lists.freedesktop.org, linux-serial@vger.kernel.org, Shawn Guo 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> Sender: linux-serial-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-serial@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shawn.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Tested-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. */