From patchwork Sun Jun 12 03:16:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Crystal Wood X-Patchwork-Id: 9171319 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 A7CBC60573 for ; Sun, 12 Jun 2016 03:16:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BE73200E7 for ; Sun, 12 Jun 2016 03:16:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EF082665D; Sun, 12 Jun 2016 03:16:41 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88F6A200E7 for ; Sun, 12 Jun 2016 03:16:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932428AbcFLDQi (ORCPT ); Sat, 11 Jun 2016 23:16:38 -0400 Received: from host.buserror.net ([209.198.135.123]:50354 "EHLO host.buserror.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932191AbcFLDQi (ORCPT ); Sat, 11 Jun 2016 23:16:38 -0400 Received: from c-75-72-173-242.hsd1.mn.comcast.net ([75.72.173.242] helo=snotra.am.freescale.net) by host.buserror.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bBvsy-0006cF-CW; Sat, 11 Jun 2016 22:16:29 -0500 From: Scott Wood To: Russell King , Michael Turquette , Stephen Boyd , Viresh Kumar , "Rafael J. Wysocki" Cc: linux-clk@vger.kernel.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, yuantian.tang@nxp.com, leoyang.li@nxp.com, xiaofeng.ren@nxp.com, Scott Wood Date: Sat, 11 Jun 2016 22:16:25 -0500 Message-Id: <1465701386-6220-1-git-send-email-oss@buserror.net> X-Mailer: git-send-email 2.5.0 X-SA-Exim-Connect-IP: 75.72.173.242 X-SA-Exim-Mail-From: oss@buserror.net Subject: [RESEND PATCH 1/2] clk: Add consumer APIs for discovering possible parent clocks X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:57:07 +0000) X-SA-Exim-Scanned: Yes (on host.buserror.net) Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Scott Wood Commit fc4a05d4b0eb ("clk: Remove unused provider APIs") removed __clk_get_num_parents() and clk_hw_get_parent_by_index(), leaving only true provider API versions that operate on struct clk_hw. qoriq-cpufreq needs these functions in order to determine the options it has for calling clk_set_parent() and thus populate the cpufreq table, so revive them as legitimate consumer APIs. Signed-off-by: Scott Wood --- Previously sent as http://patchwork.ozlabs.org/patch/519803/ Russell, could you please either ACK this or comment, as CLK API maintainer? drivers/clk/clk.c | 19 +++++++++++++++++++ include/linux/clk.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d584004..d61a3fe 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -290,6 +290,12 @@ struct clk_hw *__clk_get_hw(struct clk *clk) } EXPORT_SYMBOL_GPL(__clk_get_hw); +unsigned int clk_get_num_parents(struct clk *clk) +{ + return !clk ? 0 : clk->core->num_parents; +} +EXPORT_SYMBOL_GPL(clk_get_num_parents); + unsigned int clk_hw_get_num_parents(const struct clk_hw *hw) { return hw->core->num_parents; @@ -358,6 +364,19 @@ static struct clk_core *clk_core_get_parent_by_index(struct clk_core *core, return core->parents[index]; } +struct clk *clk_get_parent_by_index(struct clk *clk, unsigned int index) +{ + struct clk_core *parent; + + if (!clk) + return NULL; + + parent = clk_core_get_parent_by_index(clk->core, index); + + return !parent ? NULL : parent->hw->clk; +} +EXPORT_SYMBOL_GPL(clk_get_parent_by_index); + struct clk_hw * clk_hw_get_parent_by_index(const struct clk_hw *hw, unsigned int index) { diff --git a/include/linux/clk.h b/include/linux/clk.h index 0df4a51..937de0e 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -392,6 +392,26 @@ int clk_set_parent(struct clk *clk, struct clk *parent); struct clk *clk_get_parent(struct clk *clk); /** + * clk_get_parent_by_index - get a possible parent clock by index + * @clk: clock source + * @index: index into the array of possible parents of this clock + * + * Returns struct clk corresponding to the requested possible + * parent clock source, or NULL. + */ +struct clk *clk_get_parent_by_index(struct clk *clk, + unsigned int index); + +/** + * clk_get_num_parents - get number of possible parents + * @clk: clock source + * + * Returns the number of possible parents of this clock, + * which can then be enumerated using clk_get_parent_by_index(). + */ +unsigned int clk_get_num_parents(struct clk *clk); + +/** * clk_get_sys - get a clock based upon the device name * @dev_id: device name * @con_id: connection ID @@ -461,6 +481,17 @@ static inline struct clk *clk_get_parent(struct clk *clk) return NULL; } +struct clk *clk_get_parent_by_index(struct clk *clk, + unsigned int index) +{ + return NULL; +} + +unsigned int clk_get_num_parents(struct clk *clk) +{ + return 0; +} + #endif /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */