From patchwork Wed Apr 20 09:34:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 8887871 Return-Path: X-Original-To: patchwork-linux-clk@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AE93DBF29F for ; Wed, 20 Apr 2016 10:15:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A2A0A2024C for ; Wed, 20 Apr 2016 10:15:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77A212011B for ; Wed, 20 Apr 2016 10:15:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933729AbcDTKPB (ORCPT ); Wed, 20 Apr 2016 06:15:01 -0400 Received: from mail-by2on0090.outbound.protection.outlook.com ([207.46.100.90]:48715 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933315AbcDTKO7 (ORCPT ); Wed, 20 Apr 2016 06:14:59 -0400 Received: from BN3PR0301CA0075.namprd03.prod.outlook.com (10.160.152.171) by CY1PR0301MB0713.namprd03.prod.outlook.com (10.160.159.143) with Microsoft SMTP Server (TLS) id 15.1.453.26; Wed, 20 Apr 2016 09:42:10 +0000 Received: from BN1BFFO11FD022.protection.gbl (2a01:111:f400:7c10::1:125) by BN3PR0301CA0075.outlook.office365.com (2a01:111:e400:401e::43) with Microsoft SMTP Server (TLS) id 15.1.466.19 via Frontend Transport; Wed, 20 Apr 2016 09:42:10 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD022.mail.protection.outlook.com (10.58.144.85) with Microsoft SMTP Server (TLS) id 15.1.472.8 via Frontend Transport; Wed, 20 Apr 2016 09:42:10 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u3K9g0iR016915; Wed, 20 Apr 2016 02:42:07 -0700 From: Dong Aisheng To: CC: , , , , , , Subject: [RESEND PATCH 2/8] clk: move clk_disable_unused after clk_core_disable_unprepare function Date: Wed, 20 Apr 2016 17:34:34 +0800 Message-ID: <1461144880-8724-3-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461144880-8724-1-git-send-email-aisheng.dong@nxp.com> References: <1461144880-8724-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131056189308379964; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(105606002)(85426001)(50466002)(229853001)(2351001)(33646002)(106466001)(76176999)(50986999)(50226001)(5003940100001)(48376002)(92566002)(1096002)(11100500001)(86362001)(19580405001)(19580395003)(104016004)(1220700001)(2906002)(6806005)(4326007)(189998001)(110136002)(5008740100001)(2950100001)(87936001)(586003)(77096005)(81166005)(36756003)(7059030)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0713; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD022; 1:TFofxEb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jvhg2Sjc0uXXgBq/dUp+pdXuyFDeRWLZIwH1nhRt3uWGhrLKzJJJOYp1lA1vhELDmYyPs3mhAZIrXsYZQtNfQ/fOmn4h03PrKaFaJm2VJefOm+OuqlgVOtrgUTcDgg72HeSJPQlbyEFbEfu9YiOXVK6GvAqGE= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0713; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0713; 25:LFF1YTEgIJNVxR6xHCChYsJb6VEN5n8jH8JikYobz0l6T4eYFvhAltRqH6NdPTgkFpvlyln0ij7v2GmZ9TzNXcqhsNhC5eOFu8fhPFoTvX/TUD1rxezcBoNyME5HMuJaDNnn7OfVHOeIhaWFnLRmG0rX9KQYaGetHvBhh/y2vmIxqn/7SwGcm6ki1JnNQNXMN7GPrm97BXzFm6tw059Ehla9vDmofBbSz5ZqVk1HJO27F3oyNpQ1N19nUlexn1jAaZ0KpCqWctgNcnwAiKPFYJfFlTFRkaaD3XYue5dND3J6G/h31REBohPSp1ap79i0P/JhbN8bh6NsvB3eVN68I1GDO/YUHx/tv/Bjh//9dgx1qfCQhNoPfNPjYkB0mk8y2F/q5uBi+uv4AuxdCoMp+bgi6jNHr/2Qpfact/skhPSKeoHulqo9v+DMgLEQeNbq3jojGVu+P+gPLGFsF71NCH+vW4KnK0EHwBOwCeC5NDYwJK9DhEWYmv1r3O7IouH4DkK/j+BlOaKW0Lbuj5H9ub8t763W2ufoyT3vW9Lo7qVsAN+lC50guBTK/dfT05s3ILvstuqSfkj8sdwQ+PY7akpkEpXMr8DB8ErvKIj+fYxZ3mLb6vPTUaZz8pXMA3DSEfnjs78ylUxOt5rpmroWRg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(8121501046)(5005006)(13017025)(13015025)(13023025)(13024025)(10201501046)(3002001)(6055026); SRVR:CY1PR0301MB0713; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB0713; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0713; 4:CsKD5j/ysIQ0qnVPGUMfsm0hpL6UwCU5FM3LdGTc5+JPMlCizla8O/Tc7YnB/w36/DJw9Svgem0E6/Gp7uB1xj5l3chydCoKe/pOUW1JtzGWenXisDi7gjRk2WNa+mlavLivrROZFAvRGdAPmLkz5Mxy7dN37MfybCfMfNW7rZ1kuOkU4i01tiiuuAC0W+cK3XH8Ii2iirbu6H7y0S1M7j3rXesKdMvqaSYD0wbepzJGTlgqRgmvXBtDuVh+AAPOnVMB6WyKEnbvLh2B88qXmffq5Og+n2swb2iJxoHT2WR8b+wtWV97u8QpoWtNbNQMpXkmWsRoA6PEKUYVIo7ZhBMXc4dsOzsmmbnLekeytLWKEZveuef2YEM7gPJjfjZsoleGobCmB2I90rVYVUipnxkNqGOerVpjRNT115gCJIT4/8PsqGna1lOM772kPFe5yMkjMv9hoFIuYFAzWfMiuUS0ap6FB1MrQNhwvMyRxCQ= X-Forefront-PRVS: 0918748D70 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB0713; 23:qaHLUwIkErnCjNgghbPHgRA0xB37sFy0kBSK2uu?= =?us-ascii?Q?wjTsuieDZL6AF4W5r+ljGOHVgNlBIlymXDAjy/JoPEqWygilh3sYQ3b0593o?= =?us-ascii?Q?qaeXY9B9KCNhFvcQULlmIPgN39U0BoWVk4z8znNa4/Eixq0QWL6VdzJ19qsW?= =?us-ascii?Q?KdeP47F+qjcL/FLl9/7r7jvlgCledXJFvbD5WZYi5vNNd69coAcTHm6ZlEvv?= =?us-ascii?Q?TZkYo5jlZv2n8+QclUGfCH3CVIzpTObJpphe5gM2RbrdZOZCjKGeTgOL+7Jr?= =?us-ascii?Q?hC0tzY2iSRKP2kgsxl6vpBPTJkqP7i2AehBy/DJXVMaPijcRzkJrQJnQzTxV?= =?us-ascii?Q?yG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DAChieni7xOZpCMemV9l8nSssv82kRTk=; 24:uyWvhpco6NeRK7VygkHDYM/+Tmue0ntbik3YobixKgcjeB0UqTobDWaXiYePWUBU8cj2LeNOzaIuw0SjFiSDqeOg6LzCv+4j7xPN/sFnK5w= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2016 09:42:10.6507 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0713 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP No function level change, just moving code place. clk_disable_unused function will need to call clk_core_prepare_enable/ clk_core_disable_unprepare when adding CLK_OPS_PARENT_ON features. So move it after clk_core_disable_unprepare to avoid adding forward declared functions. Cc: Michael Turquette Cc: Stephen Boyd Cc: Shawn Guo Signed-off-by: Dong Aisheng --- drivers/clk/clk.c | 196 +++++++++++++++++++++++++++--------------------------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0f9f756..9f944d4 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -172,104 +172,6 @@ static bool clk_core_is_enabled(struct clk_core *core) return core->ops->is_enabled(core->hw); } -static void clk_unprepare_unused_subtree(struct clk_core *core) -{ - struct clk_core *child; - - lockdep_assert_held(&prepare_lock); - - hlist_for_each_entry(child, &core->children, child_node) - clk_unprepare_unused_subtree(child); - - if (core->prepare_count) - return; - - if (core->flags & CLK_IGNORE_UNUSED) - return; - - if (clk_core_is_prepared(core)) { - trace_clk_unprepare(core); - if (core->ops->unprepare_unused) - core->ops->unprepare_unused(core->hw); - else if (core->ops->unprepare) - core->ops->unprepare(core->hw); - trace_clk_unprepare_complete(core); - } -} - -static void clk_disable_unused_subtree(struct clk_core *core) -{ - struct clk_core *child; - unsigned long flags; - - lockdep_assert_held(&prepare_lock); - - hlist_for_each_entry(child, &core->children, child_node) - clk_disable_unused_subtree(child); - - flags = clk_enable_lock(); - - if (core->enable_count) - goto unlock_out; - - if (core->flags & CLK_IGNORE_UNUSED) - goto unlock_out; - - /* - * some gate clocks have special needs during the disable-unused - * sequence. call .disable_unused if available, otherwise fall - * back to .disable - */ - if (clk_core_is_enabled(core)) { - trace_clk_disable(core); - if (core->ops->disable_unused) - core->ops->disable_unused(core->hw); - else if (core->ops->disable) - core->ops->disable(core->hw); - trace_clk_disable_complete(core); - } - -unlock_out: - clk_enable_unlock(flags); -} - -static bool clk_ignore_unused; -static int __init clk_ignore_unused_setup(char *__unused) -{ - clk_ignore_unused = true; - return 1; -} -__setup("clk_ignore_unused", clk_ignore_unused_setup); - -static int clk_disable_unused(void) -{ - struct clk_core *core; - - if (clk_ignore_unused) { - pr_warn("clk: Not disabling unused clocks\n"); - return 0; - } - - clk_prepare_lock(); - - hlist_for_each_entry(core, &clk_root_list, child_node) - clk_disable_unused_subtree(core); - - hlist_for_each_entry(core, &clk_orphan_list, child_node) - clk_disable_unused_subtree(core); - - hlist_for_each_entry(core, &clk_root_list, child_node) - clk_unprepare_unused_subtree(core); - - hlist_for_each_entry(core, &clk_orphan_list, child_node) - clk_unprepare_unused_subtree(core); - - clk_prepare_unlock(); - - return 0; -} -late_initcall_sync(clk_disable_unused); - /*** helper functions ***/ const char *__clk_get_name(const struct clk *clk) @@ -828,6 +730,104 @@ static void clk_core_disable_unprepare(struct clk_core *core) clk_core_unprepare_lock(core); } +static void clk_unprepare_unused_subtree(struct clk_core *core) +{ + struct clk_core *child; + + lockdep_assert_held(&prepare_lock); + + hlist_for_each_entry(child, &core->children, child_node) + clk_unprepare_unused_subtree(child); + + if (core->prepare_count) + return; + + if (core->flags & CLK_IGNORE_UNUSED) + return; + + if (clk_core_is_prepared(core)) { + trace_clk_unprepare(core); + if (core->ops->unprepare_unused) + core->ops->unprepare_unused(core->hw); + else if (core->ops->unprepare) + core->ops->unprepare(core->hw); + trace_clk_unprepare_complete(core); + } +} + +static void clk_disable_unused_subtree(struct clk_core *core) +{ + struct clk_core *child; + unsigned long flags; + + lockdep_assert_held(&prepare_lock); + + hlist_for_each_entry(child, &core->children, child_node) + clk_disable_unused_subtree(child); + + flags = clk_enable_lock(); + + if (core->enable_count) + goto unlock_out; + + if (core->flags & CLK_IGNORE_UNUSED) + goto unlock_out; + + /* + * some gate clocks have special needs during the disable-unused + * sequence. call .disable_unused if available, otherwise fall + * back to .disable + */ + if (clk_core_is_enabled(core)) { + trace_clk_disable(core); + if (core->ops->disable_unused) + core->ops->disable_unused(core->hw); + else if (core->ops->disable) + core->ops->disable(core->hw); + trace_clk_disable_complete(core); + } + +unlock_out: + clk_enable_unlock(flags); +} + +static bool clk_ignore_unused; +static int __init clk_ignore_unused_setup(char *__unused) +{ + clk_ignore_unused = true; + return 1; +} +__setup("clk_ignore_unused", clk_ignore_unused_setup); + +static int clk_disable_unused(void) +{ + struct clk_core *core; + + if (clk_ignore_unused) { + pr_warn("clk: Not disabling unused clocks\n"); + return 0; + } + + clk_prepare_lock(); + + hlist_for_each_entry(core, &clk_root_list, child_node) + clk_disable_unused_subtree(core); + + hlist_for_each_entry(core, &clk_orphan_list, child_node) + clk_disable_unused_subtree(core); + + hlist_for_each_entry(core, &clk_root_list, child_node) + clk_unprepare_unused_subtree(core); + + hlist_for_each_entry(core, &clk_orphan_list, child_node) + clk_unprepare_unused_subtree(core); + + clk_prepare_unlock(); + + return 0; +} +late_initcall_sync(clk_disable_unused); + static int clk_core_round_rate_nolock(struct clk_core *core, struct clk_rate_request *req) {