From patchwork Mon Jan 8 22:16:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jolly Shah X-Patchwork-Id: 10150687 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 58DB0601BE for ; Mon, 8 Jan 2018 22:16:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EACA28478 for ; Mon, 8 Jan 2018 22:16:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 438EC2851D; Mon, 8 Jan 2018 22:16:54 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 A4ED728478 for ; Mon, 8 Jan 2018 22:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757951AbeAHWQv (ORCPT ); Mon, 8 Jan 2018 17:16:51 -0500 Received: from mail-bn3nam01on0086.outbound.protection.outlook.com ([104.47.33.86]:2496 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757759AbeAHWQs (ORCPT ); Mon, 8 Jan 2018 17:16:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=B2DhgoQRh0cFh9uKDlKwSEnVbrgvroK7v0mC5OJmUw8=; b=zIdLOUyq5S59yguJGINnbmty9bXl17dtD6TiGuVTw25Xy0+WPK0mX/ie6Ll6UBA9yTXtaOwQfqQ7yyJKJSuGr5HN9e2cParIkMcLXvyngtcLcX3KOnyTXKmWFmb53T57Aek3jeGk2IydOnEmbwxWfe8EN+oqt//CSU8u4e8OuJo= Received: from MWHPR02CA0015.namprd02.prod.outlook.com (10.168.209.153) by BY2PR02MB1329.namprd02.prod.outlook.com (10.162.79.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Mon, 8 Jan 2018 22:16:45 +0000 Received: from SN1NAM02FT036.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::205) by MWHPR02CA0015.outlook.office365.com (2603:10b6:300:4b::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.386.5 via Frontend Transport; Mon, 8 Jan 2018 22:16:45 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; baylibre.com; dkim=none (message not signed) header.d=none;baylibre.com; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.100 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.100; helo=xsj-pvapsmtpgw02; Received: from xsj-pvapsmtpgw02 (149.199.60.100) by SN1NAM02FT036.mail.protection.outlook.com (10.152.72.149) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Mon, 8 Jan 2018 22:16:44 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:53982 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1eYfim-000828-9N; Mon, 08 Jan 2018 14:16:44 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1eYfim-0005e4-6v; Mon, 08 Jan 2018 14:16:44 -0800 Received: from [172.19.2.91] (helo=xsjjollys50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1eYfii-0005dh-Lt; Mon, 08 Jan 2018 14:16:40 -0800 From: Jolly Shah To: , , , CC: , , Jolly Shah , Tejas Patel , Shubhrajyoti Datta Subject: [RFC PATCH 1/2] drivers: clk: Add clk_get_children support Date: Mon, 8 Jan 2018 14:16:36 -0800 Message-ID: <1515449797-5629-2-git-send-email-jollys@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515449797-5629-1-git-send-email-jollys@xilinx.com> References: <1515449797-5629-1-git-send-email-jollys@xilinx.com> X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23582.004 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.100; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(39380400002)(39860400002)(2980300002)(438002)(189003)(199004)(9786002)(48376002)(2950100002)(5660300001)(50466002)(47776003)(8936002)(50226002)(305945005)(81156014)(2906002)(8676002)(81166006)(4326008)(107886003)(6666003)(106466001)(77096006)(72206003)(356003)(36386004)(478600001)(36756003)(54906003)(110136005)(76176011)(63266004)(106002)(51416003)(316002)(16586007)(2201001)(7696005)(107986001)(5001870100001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR02MB1329; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; PTR:xapps1.xilinx.com,unknown-60-100.xilinx.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1NAM02FT036; 1:14qebA+UqYz9TSdkzTlvZ25d8vM38dhIPzCnQ/Ls0TdE7wi4WWnd2pDLivtk1UZuzQfMY75NKolS2u4Zgg70tGuHnc7rkcMxlXC4GQpepnnUsVsJGoOu3vJstzwo8s4t MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 68951a14-ea3c-4a3d-756c-08d556e580b3 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307)(7153060); SRVR:BY2PR02MB1329; X-Microsoft-Exchange-Diagnostics: 1; BY2PR02MB1329; 3:DG6ZBH/OyVVSmEKcY1MlGKNAUqlcoEV2JVVqW9QJoivrLS8ak8YsbYHeec1ZRYMsvMsJZ9N3a48YBLcTQPazlH1J7z1YfmpXmfQ7fxQMH6qVvKWvfhzsrFwnSDE/rSe+qyG4KPRjSgou1VvksDCUXu7DAJQjPbTa3B8mVpYhtcrY7rj7SfETJ1DawuHXz24KhKJejaRWuQZvSQTbcsFzL4wINlFVv7/nRZs2whlnTmN+aKzTnRLaKxD3WUYulKMaHezOAb782GCMfNC8HGlToBQd0YccVMNHWppHY/Vf6OQKLByA7RiRqskTzrUriKYwdjhtDsCPMB/xbLQYhSw9Y3+X4Ib1DDcOMKBjPLE0h7E=; 25:XPbqyQAQzCTXDx5sIJiijf4UJPbeGK0vw51Ad3scHowm2jqPBRgWEVf01tUAzVBTltMMoZkRWbVA6dAwhN3LvDzSRtFrNq0hnTMFDarsUzeRI/3k7uMwYjRsbjDvq8vPBozAYfiy7NpDvYj1vbTUnNGyitpbiBYzKWCX6Dv6u7voILR7fJc6N/VXdTNrWgiQ2mSufqO+OT57plJsC/8xzeOESCaEfNc1URuU844H+x+PwQ5YMM4Rj6jy9YDDdmFvDzuK6YkF9syW4fdP2iMs4bNEy+dRIkJZmen22t/gAlN8lCxkDZoh1XpSPxAnr4k3ZFPDyNKs+g3gWW0nsFGljA== X-MS-TrafficTypeDiagnostic: BY2PR02MB1329: X-Microsoft-Exchange-Diagnostics: 1; BY2PR02MB1329; 31:F+wFehOzjpq1848Q8jNBT50ia/PZebbscUs8TWYGDttB4wFKBhsVyjCCrz+5cHBDvWlBrfXqsPKNwfpWoXk4g+Bq3ppA0UKuFgjghk59/rAYtQ5sKjuQdAbUZt5fN8IRG+V5CebohHmoTdFNlfcohs95aQ+09xO54X3GRuJjzmZOakZyoS+55yoL5AakA6Y3/RcFGD/3T1c7u7yk/4i+iXi9RG24qHPdG2GrJE9ifXI=; 20:kL2F35Lp1H1l5uSetxu1ivgwwFjeFv0SN88SXrAA9SSbxjzmDLT65XRje9Q6vckURZ+7EHDI/u8W7VU+Y6n6ITjVGYxwTKmpfmDlyCJ1gohstdatqZd+L2Gnjg++0XiP4fkq+9WbClNZiC4vYFJP0QbzzUgm3NGS5JrltT18dZv5VjJdPGqC+pNr+y3QjlhVioHUVdt8Btx8iF/kw/YXP7Lhw3nJYBkOrgmZF8PzCDwY9V8tEe0fpqFUk9DBBAdbcdYuvcxDQUCAoqqjFxy9lJQ8klpGG8rMISHCSjK5V3RISqOXVaj+8k8SOjXyV81pt6tZQLNs/8xJ1HL69T0PeMUOQMb08jKbvCJH/ptC/iowSjvU421G8Sgep+MZacn5iRLiGNmw9Udb5yYyVQ/p3OvbbnEzgWhiphadCAHX4/Vvxz5nLbe+tCnRXr/UB9vFm5bq/VDkVea2OdCsj9cHhrWfnXrTe+AQ42TTff7cL+7B9fHdVgJ94hhBb+tjVBoo X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3231023)(944501075)(3002001)(10201501046)(93006095)(93004095)(6055026)(6041268)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:BY2PR02MB1329; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BY2PR02MB1329; X-Microsoft-Exchange-Diagnostics: 1; BY2PR02MB1329; 4:lD1mI0G01c8ddXymi8YNXshjjSww0JTAF8YBOUg71CKTc8nFtZwr+r1W5nWaghrxy17rhw3HZvpWSIfPWMyHY27E9TZwQOvIpmIO/aiRsyw67UOxC2zwSPKc0Fszu7mjlFUei3ytncjW99wOtTkDGh5ewSZlo81Gl50qSKCeAxQAI3PGYdCu/1TEbaJmRCzypq25dNOiINu0Px0ADjqOHA4NNZofmD3BPdqf1ysGTOND7SjnWIAgC1zbUUnJ8OXU///aiBJAIfOoKK2GhfO8eQP3VG4uHfEFf8RwvmfpvA2TYfY1YLp6Nf9YZp8XFM5h X-Forefront-PRVS: 054642504A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR02MB1329; 23:GLR1kTD8AlA33CLnzolTJTDkYInv87Eo7wju5ymO+?= =?us-ascii?Q?TP/owbG86N3Hs6dVZvFvlsw6uIYUc41OBiqUB+p5/nP8s7lstuRNO/RRL+Jt?= =?us-ascii?Q?+r7E0h1gmunYkXSZ5MD7vnEx2VxJ2QQ48Ww0rEDRsxD4BxQ9uIVgEyqAyF/m?= =?us-ascii?Q?7Khu2CYRQ8Pj+ZJlwXB3cu3e27VGHbfQyVqx+j7jWc3wjYqp+Te8OSWX+YQJ?= =?us-ascii?Q?gF6JF5roN0iqf1ZmBKkHAxnab/HvB+qcdmi8i69JxOfDZUjjLh7SsZdJfKTj?= =?us-ascii?Q?pjOycimYw5zxT0DXWmqvjapfsuMQlCnPY4IHjO1I/lpjRghSJoVvw+LK6e4T?= =?us-ascii?Q?AwUMDqNu7bcga4L6nA76nk1yuvNgLKhqwA5EFLNE1y6uO1U7VzQ4OICnWxaw?= =?us-ascii?Q?k2sciJSei+m18Ha+LI9d1ee0TeOXk21fdBOydasx6e7frjVu2vDgpCJ62Q/c?= =?us-ascii?Q?nZwxxs4Av1+3gS0WGVHfDIjE26h43YSHssz54fVpmCM+QTC205SR//UGRzdG?= =?us-ascii?Q?PqgIq/i8mrSUSEIdoMZns30QBVIXvpBSAI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bSCIE7hRBnykNN2ZPcdvjCZO8GW36UsMxlnJxmQkjtcyXx2awSG0sytwxL0Aizw28csBA+PzNRyrJAGmmUEi9vJzca08L63HX0LptHnNI8Yhqm0TO0CZOL8l7ZiGX9z5px+53sPdPgH1sAAcK1emghK0=; 24:ZURKiQtd2CnVFjE6lSHZO8iDmpmBH3bj8Av6N+QJWSSushRVBase9UzzwI1T0KPlJ2B2QUcokeuZMSNXA2f3C/l/4M6f4uBQJ811OTKpW7E=; 7:fiFOVOLtu+E3c4oMfSt2Zfg8safmIiOhdym2wMfH5ARSvJnNNDr0iUpxsZLK+DxQrHydHEtiGgUoT+DxIyBxiLQsGUfXwOAl7pq4AyWi5X0Sj2QzihOgv7GtwfwOJTsPphMmXwGjhDM0DU0MiZCPiSmVbiJhqujUSgtcpZiq8BbjyLnKkgdPdlAHqqqPpgDquDP8gqjh6vqVLS79UomhYDO5DudPZt/Je/3+00nNyxg+UYtUtBsWhSh9waT3i4/7 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2018 22:16:44.7506 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 68951a14-ea3c-4a3d-756c-08d556e580b3 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.100]; Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR02MB1329 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 This API helps to determine the users for any clock. Signed-off-by: Jolly Shah Signed-off-by: Tejas Patel Signed-off-by: Shubhrajyoti Datta --- drivers/clk/clk.c | 28 ++++++++++++++++++++++++++++ include/linux/clk-provider.h | 1 + 2 files changed, 29 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b56c11f..7488787 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -258,6 +258,34 @@ struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw) } EXPORT_SYMBOL_GPL(clk_hw_get_parent); +static unsigned int sibling; + +static void clk_show_subtree(struct clk_core *c, + int level) +{ + struct clk_core *child; + + if (!c) + return; + + if (level == 1) + sibling++; + + hlist_for_each_entry(child, &c->children, child_node) + clk_show_subtree(child, level + 1); +} + +unsigned int clk_get_children(char *name) +{ + struct clk_core *core; + struct clk *pclk = __clk_lookup(name); + + sibling = 0; + core = pclk->core; + clk_show_subtree(core, 0); + return sibling; +} + static struct clk_core *__clk_lookup_subtree(const char *name, struct clk_core *core) { diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 7c925e6..8191a32a 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -743,6 +743,7 @@ unsigned int __clk_get_enable_count(struct clk *clk); unsigned long clk_hw_get_rate(const struct clk_hw *hw); unsigned long __clk_get_flags(struct clk *clk); unsigned long clk_hw_get_flags(const struct clk_hw *hw); +unsigned int clk_get_children(char *name); bool clk_hw_is_prepared(const struct clk_hw *hw); bool clk_hw_is_enabled(const struct clk_hw *hw); bool __clk_is_enabled(struct clk *clk);