From patchwork Mon Mar 30 15:53:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 6122581 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 1FFCBBF4A6 for ; Mon, 30 Mar 2015 15:57:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4749F20373 for ; Mon, 30 Mar 2015 15:57:03 +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 717C7203A1 for ; Mon, 30 Mar 2015 15:57:02 +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 1Ycc1Z-0000oJ-6y; Mon, 30 Mar 2015 15:54:49 +0000 Received: from bhuna.collabora.co.uk ([93.93.135.160]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ycc0o-0000Ux-IO for linux-arm-kernel@lists.infradead.org; Mon, 30 Mar 2015 15:54:03 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: javier) with ESMTPSA id 99B5C600E70 From: Javier Martinez Canillas To: Stephen Boyd Subject: [RFC PATCH v3 1/2] clk: samsung: Add a clock lookup function Date: Mon, 30 Mar 2015 17:53:21 +0200 Message-Id: <1427730803-28635-2-git-send-email-javier.martinez@collabora.co.uk> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427730803-28635-1-git-send-email-javier.martinez@collabora.co.uk> References: <1427730803-28635-1-git-send-email-javier.martinez@collabora.co.uk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150330_085402_815151_B6D78B85 X-CRM114-Status: GOOD ( 10.36 ) X-Spam-Score: -0.0 (/) Cc: Krzysztof Kozlowski , Kevin Hilman , Mike Turquette , linux-kernel@vger.kernel.org, Tyler Baker , Tomasz Figa , Doug Anderson , Chanwoo Choi , Kukjin Kim , linux-samsung-soc@vger.kernel.org, Sylwester Nawrocki , Olof Johansson , Abhilash Kesavan , Javier Martinez Canillas , 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 The Samsung helpers functions to register clocks, add the clock instance returned by the common clock framework to a lookup table that is used by OF to lookup the clocks. But this table could also be useful to clock drivers if they need to get a clock instance since the helper functions don't return them. The common clock framework __clk_lookup() function from the clk provider API could be used by drivers as well. But it's more efficient to use the Samsung specific lookup table that returns the clock instance in constant time, than using the __clk_lookup() function that uses the clock name as an index so it has a linear search time. Signed-off-by: Javier Martinez Canillas --- drivers/clk/samsung/clk.c | 6 ++++++ drivers/clk/samsung/clk.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/drivers/clk/samsung/clk.c b/drivers/clk/samsung/clk.c index 9e1f88c04fd4..3b2868a70774 100644 --- a/drivers/clk/samsung/clk.c +++ b/drivers/clk/samsung/clk.c @@ -96,6 +96,12 @@ void samsung_clk_add_lookup(struct samsung_clk_provider *ctx, struct clk *clk, ctx->clk_data.clks[id] = clk; } +struct clk *samsung_clk_lookup(struct samsung_clk_provider *ctx, + unsigned int id) +{ + return ctx->clk_data.clks ? ctx->clk_data.clks[id] : NULL; +} + /* register a list of aliases */ void __init samsung_clk_register_alias(struct samsung_clk_provider *ctx, struct samsung_clock_alias *list, diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h index e4c75383cea7..ad04220bd733 100644 --- a/drivers/clk/samsung/clk.h +++ b/drivers/clk/samsung/clk.h @@ -368,6 +368,9 @@ extern void __init samsung_clk_of_register_fixed_ext( extern void samsung_clk_add_lookup(struct samsung_clk_provider *ctx, struct clk *clk, unsigned int id); +extern struct clk *samsung_clk_lookup(struct samsung_clk_provider *ctx, + unsigned int id); + extern void samsung_clk_register_alias(struct samsung_clk_provider *ctx, struct samsung_clock_alias *list, unsigned int nr_clk);