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: 6122531 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 22AFB9F387 for ; Mon, 30 Mar 2015 15:53:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5495C2034F for ; Mon, 30 Mar 2015 15:53:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6961920364 for ; Mon, 30 Mar 2015 15:53:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752503AbbC3Pxl (ORCPT ); Mon, 30 Mar 2015 11:53:41 -0400 Received: from bhuna.collabora.co.uk ([93.93.135.160]:43194 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752788AbbC3Pxj (ORCPT ); Mon, 30 Mar 2015 11:53:39 -0400 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 Cc: Mike Turquette , Sylwester Nawrocki , Tomasz Figa , Kukjin Kim , Olof Johansson , Doug Anderson , Krzysztof Kozlowski , Kevin Hilman , Tyler Baker , Abhilash Kesavan , Chanwoo Choi , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Martinez Canillas 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> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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);