From patchwork Tue Mar 21 06:15:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajendra Nayak X-Patchwork-Id: 9636069 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 F2DC9601E9 for ; Tue, 21 Mar 2017 06:16:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3B50279E0 for ; Tue, 21 Mar 2017 06:16:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D859527CEA; Tue, 21 Mar 2017 06:16:50 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 850B1279E0 for ; Tue, 21 Mar 2017 06:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ka8RmAh8pAJIN8eLwx1nltp5H+YV9lMRc7nrfpgB1VY=; b=SVa+e+M4IFzg2zRfWJkgiypSWb +MhAu4Qa54+RThTscYxarEpWvBVkioz9ONzmY8NJ19TfYbLmYbFGT/yrgIbDoP02v8SQqvNYK6HUn iIiUpq8IKuYhS/dXdGfS7X5Tmt9ClvocTySPN4hjtlxpl+dysJ3feeW1fuKn+HckKG7qylsiZ+9bM cCVaxHuV4z9amxAjytlnWM/gKQwAQU5PjAUpvRTO/dcQZtXibOc7Nq74g49GkY3sax7LpU8hccnlF CRMbc91T4mgllJZXAJbkVxwu0c0+locYwAiQukujIiLJ+Uy9hWtGHAlZVkKKCdLoaMHCDKuHGl6gI zD0P/jLg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqD69-0001rZ-DN; Tue, 21 Mar 2017 06:16:49 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqD5O-0000yu-Bi for linux-arm-kernel@lists.infradead.org; Tue, 21 Mar 2017 06:16:05 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 07D1960CE4; Tue, 21 Mar 2017 06:15:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1490076943; bh=Jajnst0Dm6KEQa63Wwoefr4xwyMvZ/idCIPzGoZdbLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bwtecVL2wtqc9xuXUvJ5K/a9bDg2NLBrs5at5HoGfl0z+TnRqDLMjY986I12a4UhI 6AYb00byEAVSk7zppFWC173QjdAxBrYG8TpRltGsbU8VZE7tm8Bb/kdfPSLmVyuCWm 5hhtsGUzImZjNXiqao6K9E1CRTxlma27VvkwgDGE= Received: from blr-ubuntu-173.qualcomm.com (unknown [202.46.23.61]) (using TLSv1.1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: rnayak@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3B33660CDE; Tue, 21 Mar 2017 06:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1490076942; bh=Jajnst0Dm6KEQa63Wwoefr4xwyMvZ/idCIPzGoZdbLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZKfRXDT9jPit40skByKJq8ZUVlJUGvo6dONlUEPstjPQAzeThU1VmcPkSKx9NyvXU CfsERZ8fEuSCmh2lOOGdBdlbC4SnkpQgmi+ld7eUn9juURsNpYMYy9+8VkVPROSgNp CjqYuDtN4GlWGcS2Eymp+RYeWAUBkvjfMvH811iQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3B33660CDE Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=rnayak@codeaurora.org From: Rajendra Nayak To: sboyd@codeaurora.org, mturquette@baylibre.com Subject: [PATCH 2/5] clk: Add clk_hw_get_clk() helper API to be used by clk providers Date: Tue, 21 Mar 2017 11:45:20 +0530 Message-Id: <1490076923-20194-3-git-send-email-rnayak@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490076923-20194-1-git-send-email-rnayak@codeaurora.org> References: <1490076923-20194-1-git-send-email-rnayak@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170320_231602_565610_CF2F64F8 X-CRM114-Status: GOOD ( 11.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, Rajendra Nayak , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP As we move towards a cleaner split to have clock providers use clk_hw for all clock operations, while consumers operate on the (per-user) struct clk handles, we still have cases where in a clock provider might want to call into high level clk apis which only operate on a struct clk handle. To facilitate such needs, have a clk_hw_get_clk() api which can be used from within clock providers to get access to struct clk handles. Signed-off-by: Rajendra Nayak --- drivers/clk/clk.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/clk-provider.h | 5 +++++ 2 files changed, 44 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0fb39fe..a6ba77c 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -186,6 +186,45 @@ const char *clk_hw_get_name(const struct clk_hw *hw) } EXPORT_SYMBOL_GPL(clk_hw_get_name); +struct clk *clk_hw_get_clk(struct clk_hw *hw, const char *dev_id, + const char *con_id) +{ + return __clk_create_clk(hw, dev_id, con_id); +} +EXPORT_SYMBOL_GPL(clk_hw_get_clk); + +void clk_hw_put_clk(struct clk *clk) +{ + __clk_free_clk(clk); +} +EXPORT_SYMBOL_GPL(clk_hw_put_clk); + +static void devm_clk_hw_put(struct device *dev, void *res) +{ + clk_hw_put_clk(*(struct clk **)res); +} + +struct clk *devm_clk_hw_get_clk(struct device *dev, struct clk_hw *hw, + const char *con_id) +{ + struct clk **ptr, *clk; + + ptr = devres_alloc(devm_clk_hw_put, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + clk = clk_hw_get_clk(hw, dev_name(dev), con_id); + if (!IS_ERR(clk)) { + *ptr = clk; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return clk; +} +EXPORT_SYMBOL_GPL(devm_clk_hw_get_clk); + struct clk_hw *__clk_get_hw(struct clk *clk) { return !clk ? NULL : clk->core->hw; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index a428aec..feddf95 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -729,6 +729,11 @@ struct clk_hw *clk_hw_register_gpio_mux(struct device *dev, const char *name, /* helper functions */ const char *__clk_get_name(const struct clk *clk); const char *clk_hw_get_name(const struct clk_hw *hw); +struct clk *clk_hw_get_clk(struct clk_hw *hw, const char *dev_id, + const char *con_id); +void clk_hw_put_clk(struct clk *clk); +struct clk *devm_clk_hw_get_clk(struct device *dev, struct clk_hw *hw, + const char *con_id); struct clk_hw *__clk_get_hw(struct clk *clk); unsigned int clk_hw_get_num_parents(const struct clk_hw *hw); struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw);