From patchwork Thu Jun 30 14:13:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 71250 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp417606qgy; Thu, 30 Jun 2016 07:14:51 -0700 (PDT) X-Received: by 10.66.2.131 with SMTP id 3mr17838740pau.108.1467296089317; Thu, 30 Jun 2016 07:14:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g185si4658273pfc.294.2016.06.30.07.14.49; Thu, 30 Jun 2016 07:14:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752549AbcF3OOg (ORCPT + 3 others); Thu, 30 Jun 2016 10:14:36 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:43859 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932202AbcF3OOe (ORCPT ); Thu, 30 Jun 2016 10:14:34 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id u5UECihI007038; Thu, 30 Jun 2016 09:12:44 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5UEDt4f004418; Thu, 30 Jun 2016 09:13:55 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.294.0; Thu, 30 Jun 2016 09:13:55 -0500 Received: from gomoku.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u5UEDnVV002253; Thu, 30 Jun 2016 09:13:53 -0500 From: Tero Kristo To: , , , , , CC: , Russell King Subject: [PATCHv3 1/7] clkdev: add helper registration API Date: Thu, 30 Jun 2016 17:13:32 +0300 Message-ID: <1467296018-25086-2-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467296018-25086-1-git-send-email-t-kristo@ti.com> References: <1467296018-25086-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org In certain cases, it is desirable to extend the implementation of the clkdev lookup, to avoid registering massive amounts of clkdev aliases. A simple helper implementation can instead be used to search and automatically create the clkdev entries. A sample of this is the TI clock implementation, which currently registers a large number of clkdev entries with a very simple mapping strategy. This patch adds an API to register a helper function that gets called during clk_get(), in case everything else fails to look up the clock. Individual clock drivers are then free to register the helper and implement it the way they want. Signed-off-by: Tero Kristo Cc: Russell King --- drivers/clk/clkdev.c | 22 +++++++++++++++++++++- include/linux/clkdev.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 89cc700..788c0b2 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -26,6 +26,8 @@ static LIST_HEAD(clocks); static DEFINE_MUTEX(clocks_mutex); +static struct clk * (*clkdev_get_helper)(const char *dev_id, + const char *con_id); #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) static struct clk *__of_clk_get(struct device_node *np, int index, @@ -190,7 +192,13 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id) out: mutex_unlock(&clocks_mutex); - return cl ? clk : ERR_PTR(-ENOENT); + if (cl) + return clk; + + if (clkdev_get_helper) + return clkdev_get_helper(dev_id, con_id); + + return ERR_PTR(-ENOENT); } EXPORT_SYMBOL(clk_get_sys); @@ -209,6 +217,18 @@ struct clk *clk_get(struct device *dev, const char *con_id) } EXPORT_SYMBOL(clk_get); +int clkdev_helper_register(struct clk * (*helper)(const char *, + const char *)) +{ + if (clkdev_get_helper) + return -EBUSY; + + clkdev_get_helper = helper; + + return 0; +} +EXPORT_SYMBOL(clkdev_helper_register); + void clk_put(struct clk *clk) { __clk_put(clk); diff --git a/include/linux/clkdev.h b/include/linux/clkdev.h index 2eabc86..173e2fa 100644 --- a/include/linux/clkdev.h +++ b/include/linux/clkdev.h @@ -51,6 +51,7 @@ int clk_add_alias(const char *, const char *, const char *, struct device *); int clk_register_clkdev(struct clk *, const char *, const char *); int clk_hw_register_clkdev(struct clk_hw *, const char *, const char *); +int clkdev_helper_register(struct clk * (*)(const char *, const char *)); #ifdef CONFIG_COMMON_CLK int __clk_get(struct clk *clk);