From patchwork Mon Jun 20 13:43:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 9187437 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1D8FC6075F for ; Mon, 20 Jun 2016 13:44:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 096CF22B1F for ; Mon, 20 Jun 2016 13:44:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F22772766D; Mon, 20 Jun 2016 13:44:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1D4B22B1F for ; Mon, 20 Jun 2016 13:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754596AbcFTNox (ORCPT ); Mon, 20 Jun 2016 09:44:53 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35985 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754012AbcFTNou (ORCPT ); Mon, 20 Jun 2016 09:44:50 -0400 Received: by mail-lf0-f68.google.com with SMTP id a2so5508731lfe.3; Mon, 20 Jun 2016 06:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YLqEj9YCYU/ryuFyPTkpMU8EEU5mDZXg5Z+Sb3RWEF0=; b=CUqsHOsP+lkfKBdYuz2Rj40kAj8krQZwkHCi/ZumIzVt3mhtsPuvKZbv28okhrst7c XyS5SCm/a2BGeEJM74w68ev5LB13d5ku9yw2U+uGtuUUurndpwvBMOUsuwWo820W0zCq CJJJ6bx2/xaJcyp4GfHP/JSsa9Abi1xaciLNNWC6u7EjlOEopMXuGXT9aCg9yR2y0YtS 89g+AQykD4fGgpkJ9kDL5r4M5qxZpXhU94pTjoopc3RubsO2maSz8y7+CDL7SQP5Mshm e7hj7OfQPFZKe5wCT49aoTkdsKxOrL/QgIJYNuq/tjoJbgcvenqOnC4ISPXU9jidomTf spiw== 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=YLqEj9YCYU/ryuFyPTkpMU8EEU5mDZXg5Z+Sb3RWEF0=; b=CBvIdZv0+pbfMm+BaqNBlB1cPhW6HXebi9uYQDoeUJ91VWjVIlAShOzy9dOxEEeZf5 cg7gsiKC77VAwgvGvp7dPa40/C0AZEv2QAAiDDo+OyGLY25gNaFwdL7AIZaE8W6nOvmi XLUhNtvUU+dyWgwCvG/w2AbpBsXsYYXtGczW3ACLqyak3SaojCQhZc0UUeZ/yHAgaIWw mj1UXiNy1NDqqoJb5medXEWzFHL85oHKMPdm9Oxf1I2N92TKZ5nUKUdPcaDr61nzkbMz FYMAUXq0Ph3Y0zhdulCbGRtbG0e+To/tLWDwb6UaSrri45sHyO8s907XMTlXLlSBzBsH P/Iw== X-Gm-Message-State: ALyK8tIgRlbVa0LcFpHAt0YjGLQZZCdqD76oa8NWj1iOOCn1wSD3LRYnr+6m64d/HR4afA== X-Received: by 10.25.219.130 with SMTP id t2mr4529685lfi.26.1466430222469; Mon, 20 Jun 2016 06:43:42 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id p10sm3452594lbr.22.2016.06.20.06.43.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jun 2016 06:43:41 -0700 (PDT) From: Ricardo Ribalda Delgado To: Stephen Boyd , Michael Turquette , s.hauer@pengutronix.de, jeremy.kerr@canonical.com, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v2 1/3] clk: Add new function of_clk_is_provider() Date: Mon, 20 Jun 2016 15:43:36 +0200 Message-Id: <1466430218-6561-2-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1466430218-6561-1-git-send-email-ricardo.ribalda@gmail.com> References: <1466430218-6561-1-git-send-email-ricardo.ribalda@gmail.com> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP of_clk_is_provider() checks if a device_node has already been added to the clk provider list. This can be used to avoid adding the same clock provider twice. Signed-off-by: Ricardo Ribalda Delgado --- drivers/clk/clk.c | 20 ++++++++++++++++++++ include/linux/clk-provider.h | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d584004f7af7..2423c6373906 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3120,6 +3120,26 @@ __of_clk_get_hw_from_provider(struct of_clk_provider *provider, return hw; } +/** + * of_clk_is_provider() - Reports if a device node is already a clk provider + * @np: Device node pointer under test + */ +bool of_clk_is_provider(struct device_node *np) +{ + struct of_clk_provider *cp; + + mutex_lock(&of_clk_mutex); + list_for_each_entry(cp, &of_clk_providers, link) { + if (cp->node == np) { + mutex_unlock(&of_clk_mutex); + return true; + } + } + mutex_unlock(&of_clk_mutex); + return false; +} +EXPORT_SYMBOL_GPL(of_clk_is_provider); + struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec, const char *dev_id, const char *con_id) { diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index fb39d5add173..a01b18797418 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -787,6 +787,7 @@ int of_clk_add_hw_provider(struct device_node *np, void *data), void *data); void of_clk_del_provider(struct device_node *np); +bool of_clk_is_provider(struct device_node *np); struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, void *data); struct clk_hw *of_clk_hw_simple_get(struct of_phandle_args *clkspec, @@ -819,6 +820,10 @@ static inline int of_clk_add_hw_provider(struct device_node *np, return 0; } static inline void of_clk_del_provider(struct device_node *np) {} +static inline bool of_clk_is_provider(struct device_node *np) +{ + return false; +} static inline struct clk *of_clk_src_simple_get( struct of_phandle_args *clkspec, void *data) {