From patchwork Wed Jun 8 10:19:59 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: 9164139 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 A5FC560832 for ; Wed, 8 Jun 2016 10:24:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96DD22835E for ; Wed, 8 Jun 2016 10:24:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BA0928373; Wed, 8 Jun 2016 10:24:11 +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=unavailable 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 3A1082835E for ; Wed, 8 Jun 2016 10:24:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424205AbcFHKXs (ORCPT ); Wed, 8 Jun 2016 06:23:48 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:35111 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424661AbcFHKUK (ORCPT ); Wed, 8 Jun 2016 06:20:10 -0400 Received: by mail-lf0-f65.google.com with SMTP id s186so353363lfs.2; Wed, 08 Jun 2016 03:20:09 -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=ShpGWFjxz2dvi4EbUNAzc9P6Bw3qFkUSb6FyfWo0SCp8PCBhuW9eaZ5v14Oupme/L/ /u1LNRzooetnRtPRcIisAKbexizp073Ye4KXUPEViWBlNf5q08PH5FiBaHkGPC3jW4S1 nHwi85JL2VTwZ1Q8I88QXZO/WjvwomaVQaCgEs3ZbTObocWNgeS5borOroMBnUB1Q7JX orvuiYKP5sQuEl9DHvWXzoCSfEd7lBcCtf7tsx0QLSLARvLuybqa6e+mcPd+T8f+d0OA 2jylvso/otLqwcSRanslNp6608H2NxRiOBHlFCFTesZJVVz7yPzj9DLVBaoCGcj0mc+F PG8g== 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=ckI+faCojYq3Kt9Wp7t5n1oGz4qsln04k+QchPykDznSSRVnhda1ELQwZ+iueUC2WY iCkZKBZYUxxJcP2cbgOorneT7x10TdZ+8d4W7II7O0YxRla/V6Ot8ajCEXyZprWO9ON1 Mzn6arqdZ9H+qQd1tmaEALoLYssZ60Ur3qNT/rIfpDIUu/YgUo6wgEFoCTc6xBysKk9G RUolg68m/dnOlloHsXHArXfiaw0WcN946yoa45Okq/djQakEmwfz1mtm60ebUAi/f1P0 jalY0TvMivD6ltiLzHPLfd1MGxHuzJdKIo9OH1o6W21YI80XYW1aDnQYiCGjth05VAls b6PQ== X-Gm-Message-State: ALyK8tIDc+nhKZF9O6y/dh6HBLKjtDkarwGExb3Vx5AMNMBI31b/YSVV2yqXoj6oc3r0dg== X-Received: by 10.25.163.8 with SMTP id m8mr3773735lfe.144.1465381205549; Wed, 08 Jun 2016 03:20:05 -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 m8sm66864lfe.15.2016.06.08.03.20.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jun 2016 03:20:04 -0700 (PDT) From: Ricardo Ribalda Delgado To: Michael Turquette , Stephen Boyd , s.hauer@pengutronix.de, jeremy.kerr@canonical.com, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH 1/3] clk: Add new function of_clk_is_provider() Date: Wed, 8 Jun 2016 12:19:59 +0200 Message-Id: <1465381201-11537-2-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1465381201-11537-1-git-send-email-ricardo.ribalda@gmail.com> References: <1465381201-11537-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) {