From patchwork Thu Jul 20 04:48:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajendra Nayak X-Patchwork-Id: 9853775 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 91A1660392 for ; Thu, 20 Jul 2017 04:49:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AB00286D6 for ; Thu, 20 Jul 2017 04:49:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BE1728702; Thu, 20 Jul 2017 04:49:58 +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 00849286D6 for ; Thu, 20 Jul 2017 04:49:57 +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=wX1J7OeXzVTYDq8dyyEMFA+Xk2G/QObnt9NfDP7877I=; b=EAE+cAMm0n+qoketT4H91GoukE Mdk4HYo0mnssH6KAi/2OFfY1QLM35dTUTNXWGxjUvi7xMhLkmla3fbJ+Gv7YpnoG7pa9dvazZcWrE tIewsu1v5xSagQEX9jvRQhu5W52oOkRy/rZpLh4iXOA2H3/QDSUUAx1VNvo7h1lDIBjUOe5wF1Qhw ah+niQ84SXI6mXAnRhuprJHaYUerfxvgI6HLg6WZxjfWbz1lAc/LeRRg3uMdS6OaxgGfTAnxucQBH ajZii/n/eFWVW2T7F9xG+yHJFyMp+hVJso+obL17xZLNAOoS1FbsfCIXRktnjkDj04Im68Q8kA+Ew XB+gVyqQ==; 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 1dY3PP-0006NN-Ov; Thu, 20 Jul 2017 04:49:55 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dY3Of-0005kN-NK for linux-arm-kernel@lists.infradead.org; Thu, 20 Jul 2017 04:49:11 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id AF541611CF; Thu, 20 Jul 2017 04:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1500526130; bh=K5fO9/dzDZMl5j580o4Kcnci4G3TEJt+JFnRZPW6s9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hLRe/CgnPl124XMiCp4h0v1AQJXyCJz77pcFAHyz5sI9r2uy6Njxsv3YPmNSw9OiM ZAvhgJnh5dWy4bZBS+l8EP9dyDqGCc3K3e3Mw+LpEQMM9GEAg/eAc8WaI7GiVQxJrO du38FWMbAAj0Sovwo5NPOb8UrHmrR9I2qLRtTTXQ= Received: from blr-ubuntu-173.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (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 4205D611C5; Thu, 20 Jul 2017 04:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1500526129; bh=K5fO9/dzDZMl5j580o4Kcnci4G3TEJt+JFnRZPW6s9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q2036d+Ci7O6DUdj1InY5JoDSXiQAW3LNkuyYKK2CGkmF2PcmZi9IFzVLTAS/Tdrx WDNWUwYoLvOewQXTCCmQfAtY5a5eW57hbdg0zrO/DM0pvj/+FjaRK+bvVp1bLa+isX xbGS+RDFbogYVTPc9P6p40VN3XnirEscQ7+tm0pk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4205D611C5 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 v2 2/5] clk: Add clk_hw_get_clk() helper API to be used by clk providers Date: Thu, 20 Jul 2017 10:18:16 +0530 Message-Id: <1500526099-9935-3-git-send-email-rnayak@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1500526099-9935-1-git-send-email-rnayak@codeaurora.org> References: <1500526099-9935-1-git-send-email-rnayak@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170719_214909_924366_96C0A961 X-CRM114-Status: GOOD ( 12.66 ) 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: Rajendra Nayak , linux-arm-msm@vger.kernel.org, stanimir.varbanov@linaro.org, vivek.gautam@codeaurora.org, 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 fc58c52..c9bbfb3 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 c59c625..c85bfed 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -730,6 +730,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);