From patchwork Mon Jun 3 17:53:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 2654111 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id C381A3FC23 for ; Mon, 3 Jun 2013 17:54:21 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjYxS-0002Jo-K2; Mon, 03 Jun 2013 17:54:14 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjYxP-00071t-M9; Mon, 03 Jun 2013 17:54:11 +0000 Received: from mail-pb0-x230.google.com ([2607:f8b0:400e:c01::230]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjYxM-000706-Ol for linux-arm-kernel@lists.infradead.org; Mon, 03 Jun 2013 17:54:09 +0000 Received: by mail-pb0-f48.google.com with SMTP id md4so6030431pbc.35 for ; Mon, 03 Jun 2013 10:53:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=vdcEN/e7/SrerOZoEHk2fYMr81L9gOl8GffZOuYqGsc=; b=bFcwfimRSra+hay32LkXe28rcibRsfyVed9lJwW5DJ65I+ZTNLJKE40zGUW0nkk+Eg 1T38FjMYkaPaBZN0u0jNcn5/hnSbUZOC1QRoZoii+21h9DlD9+0d3yFcexbGnuNXNKGM r9EMESxAWMOunfFnmP3cQ80XmSNj+lbe8Xce0DLdRsyzCplwxIBqx1iUrExIVMiPExF+ FUxL7IcXjyQBXYimP5TKmFLxv4MGuI45psiwDnk5od2bdrK2MIp6ZuJZbrUtQg9pyrFK m+Uo88q32CQQocMtjGg1Y2YZhP9QXFBYzLrZiAL0nFARWCDyzssLd5NSRo/6m3nO3Q+C KWlg== X-Received: by 10.68.95.101 with SMTP id dj5mr25223629pbb.100.1370282023444; Mon, 03 Jun 2013 10:53:43 -0700 (PDT) Received: from localhost.localdomain (c-50-152-203-145.hsd1.ca.comcast.net. [50.152.203.145]) by mx.google.com with ESMTPSA id 6sm6888200pbn.45.2013.06.03.10.53.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Jun 2013 10:53:42 -0700 (PDT) From: Mike Turquette To: linux-kernel@vger.kernel.org Subject: [PATCH RFC 1/3] clk: of: helper for determining number of parent clocks Date: Mon, 3 Jun 2013 10:53:08 -0700 Message-Id: <1370281990-15090-2-git-send-email-mturquette@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1370281990-15090-1-git-send-email-mturquette@linaro.org> References: <1370281990-15090-1-git-send-email-mturquette@linaro.org> X-Gm-Message-State: ALoCoQmjP0kN/Ldh4E6+MRF3FM4LvPBSU6r192ui0x3XGyTxjv2/P5utyA7Kx13SF3N4tsgDKQOk X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130603_135408_997931_89BC0D4B X-CRM114-Status: UNSURE ( 8.98 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: devicetree-discuss@lists.ozlabs.org, Mike Turquette , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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 Walks the "clocks" array of parent clock phandles and returns the number. Signed-off-by: Mike Turquette --- DT gurus, please let me know if this is stupid. I am unfamiliar with parsing DT blobs and associated APIs. drivers/clk/clk.c | 6 ++++++ include/linux/clk-provider.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index af0dbcc..73e0358 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2082,6 +2082,12 @@ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) return clk; } +int of_clk_get_parent_count(struct device_node *np) +{ + return of_count_phandle_with_args(np, "clocks", "#clock-cells"); +} +EXPORT_SYMBOL_GPL(of_clk_get_parent_count); + const char *of_clk_get_parent_name(struct device_node *np, int index) { struct of_phandle_args clkspec; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 265f384..f8d38f2 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -442,6 +442,7 @@ void of_clk_del_provider(struct device_node *np); struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, void *data); struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data); +int of_clk_get_parent_count(struct device_node *np); const char *of_clk_get_parent_name(struct device_node *np, int index); void of_clk_init(const struct of_device_id *matches);