From patchwork Wed Jun 29 14:59:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9205579 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 3603F6089F for ; Wed, 29 Jun 2016 15:06:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 247C12861D for ; Wed, 29 Jun 2016 15:06:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19241285C3; Wed, 29 Jun 2016 15:06:28 +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=unavailable 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 A7F912861D for ; Wed, 29 Jun 2016 15:06:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752897AbcF2PGU (ORCPT ); Wed, 29 Jun 2016 11:06:20 -0400 Received: from mail-bn1on0074.outbound.protection.outlook.com ([157.56.110.74]:56262 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752793AbcF2PGS (ORCPT ); Wed, 29 Jun 2016 11:06:18 -0400 Received: from BLUPR0301CA0015.namprd03.prod.outlook.com (10.162.113.153) by BY2PR03MB1926.namprd03.prod.outlook.com (10.164.114.30) with Microsoft SMTP Server (TLS) id 15.1.447.15; Wed, 29 Jun 2016 15:06:15 +0000 Received: from BY2FFO11FD025.protection.gbl (2a01:111:f400:7c0c::112) by BLUPR0301CA0015.outlook.office365.com (2a01:111:e400:5259::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16 via Frontend Transport; Wed, 29 Jun 2016 15:06:15 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=fail action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD025.mail.protection.outlook.com (10.1.15.214) with Microsoft SMTP Server (TLS) id 15.1.523.9 via Frontend Transport; Wed, 29 Jun 2016 15:06:14 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u5TF65JW021502; Wed, 29 Jun 2016 08:06:11 -0700 From: Dong Aisheng To: CC: , , , , , , Subject: [PATCH V2 2/8] clk: move clk_disable_unused after clk_core_disable_unprepare function Date: Wed, 29 Jun 2016 22:59:05 +0800 Message-ID: <1467212351-16626-3-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467212351-16626-1-git-send-email-aisheng.dong@nxp.com> References: <1467212351-16626-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131116863746211034; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(76176999)(11100500001)(8666005)(77096005)(48376002)(50466002)(50986999)(69596002)(105606002)(87936001)(4326007)(19580395003)(104016004)(106466001)(81166006)(2906002)(81156014)(5003940100001)(8936002)(47776003)(2950100001)(2351001)(110136002)(229853001)(586003)(86362001)(19580405001)(189998001)(575784001)(33646002)(36756003)(68736007)(97736004)(356003)(92566002)(8676002)(305945005)(85426001)(6806005)(7846002)(50226002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB1926; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD025; 1:MijKveUY1/C9+KMMzo+dYoPWDLrYmZKi5Lk9Juxwn6PDkmpjdoDWMTybWH8YLRuiJRqxDP0Xfx2g2OrZE81vGFi+OuaFBEkHITysosxAu1XWEyWxJHk1AMUhhVhDPenMzb5g1D/BiMcKraVQ0Yge5BB31gkXD/Krs1/Cbc5hrNcHKcR8vwyJs2017/ltBXiTARmdZ+c9S7NYLlP1w5WV9DGxhcczAdqy3pGftWm/IzCoi/8Cbxl61JhBG7I1z7aUEYGrG4SLhfyKtYfNYAUcl4Sf4mEPIecNfA3/IY+hKVBWhnedA5cPshflzMof4yg2VIJTIfBdK4GEA2oaxrdjE0/p5csMBLdfpwvH+f1Crfqh0IuBeS6RIlV6l/K8ynLzPFzhCjoazEyh3FmvITN04nzk+0WfrL3sw1HMi2XZnipAHcaJ7Ve1dCYYnJ3VpSypcYtAn6YKGa6jrLMwTojwf8nWPBhP05vsZ2qqGV08p71ZHhyWZa8ffBx7x1b9yLS1VKF7R0dJhluURYK5iOLKu8GuoSQQX/LDl5SkR64wkXREIK/ZnlLYYm34KS4P0U1E0VGKO/RtBsOg8GkgUmftkW8cx7GeIs/IBZCAET78xYKN7dHKnXYTd3n3ohwF1U35lO4uvMUrhd/9p02ryrwZYJ6NaNCXufCsPu+ugWqqZCUezLXLcDpzNO50qzI9FtF2MdbXZnYuK2l/gTwYR/ZyES4EX8KXTHI0blT1F3pVBEw= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 19a7614e-0647-445f-4849-08d3a02ee9fb X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB1926; 2:8+RpMo/7JKdFBJtgY75dCkmS1pxvEBaacnXnz9fvFn+SFxLfaoA6Th0AmbGWnBeNltGDwCYo9uph53Tnbtdz3c/eh7TbLrRsv1mvwJqRdxgQKIDxQvLRd2x6B7Eq11al9EInUQUYn7vpAS1zMTOSTvnpEHr2oXRRHr39+kZDtd82y31tGhRpwBxCwbkuWtJD; 3:p4Oya0iVMSHS+TnoD0o/FePvZfqAZwQv3MHZn6TW9uhFXz7ZchJ8uAYAQmli9vCWqyOXYBThYf96vXIgLodAJ1CoU8iSX/YwdzXusDfWtIKT0dE72lqU2c+OUlH6IE8al2o/i1LKNO8l2vlKqL+MxOc3l0ugkgjLuGWBv8nGT/XSNsRCOuakwJ4r2IKsJEZAjpFTWQHLbp+NtkewYvbfYMT7rIOM6xHxJcl0G+62dBk=; 25:k++a7hETEt9C0v66MTWXC5B21yHjalQMQ/VBZ+SDVKXiIBVMyuoF69/H3NHgde3qFcRRrYTrvJbIZGtcBsek7gDlWdSTxPOeCMZMSd2vzdVBC4bN4pT/DtDbT0ZiPoRdlfqhZQKdyPbVmFjotbSAiRPbcndctFBGXpR01S4HWi/ISQ+9eYfuJC/SkmvFFB3g7ZsA2Dpiq3pAgllpnmJcy5OvA6pfdIdBbJQjcM47HQ6XDlWX6DvKPvZzGzPNf2rC X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB1926; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13024025)(13023025)(13017025)(13018025)(13015025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:BY2PR03MB1926; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR03MB1926; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB1926;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ih0IjowJ3Xg2UKF45KT?= =?us-ascii?Q?vs3QEt9WMkNx/ienTci3HQPVMeHRpkFNg3tl9s1cDn/lGvwAG6cO7hVSlGls?= =?us-ascii?Q?EZyADdAPi4xD1Ho+sW1Sz3IztcHEL/mysqr0/ImhrjnLoexLkuD9xVD684Oc?= =?us-ascii?Q?xGHveJ8mSw1T9AGVYuhIwj/bCfrlEou/Iby1Cxqk1Vo59kmKze/i1HccWIhY?= =?us-ascii?Q?ukYjYa+FmUJSCfGTJyNV4iBAUVcSzSHDAZD6CyVoUDImRlJCXdxoP+GsN0BE?= =?us-ascii?Q?SYOkwCEnIhd3gIGlXeEjKxFAr4InEACCPT98dDVSl6F26DlaJnZ2IWI62SFB?= =?us-ascii?Q?99FcLak5qpRpytBgNM0LFDkL7pjh8kaNWwEC/iNdNCgATqe460mdb2iznz0P?= =?us-ascii?Q?b/BBWP68BlFx51RjlySv+1paOy64LMjwpIKwHwykPIfnL4El1KSrzK5dRpFU?= =?us-ascii?Q?vc+llnyqJMZahy4YWaMu17OS4A6uGRzH20D54zMIo9yKnY8He7asbBJ9/utU?= =?us-ascii?Q?mVokRcfDpVDH0nxI9UNqRM8jE+GB8Yus9zuMcZ5IbmtqjyAqL08Ag+MZCo1d?= =?us-ascii?Q?yJUA1pRhKb9pqgRR68/exIM1XQnZgp3M0+mPIC7OpLdkD3xH4+V2At5IZvP5?= =?us-ascii?Q?i8qHwkMGqallQTesy0lgaCQn1KzNGTUa6e+6dT78J301BshWXpcfeCqsrmpv?= =?us-ascii?Q?DkKl+BInjOl7H7BiahiRnTK/XQAxIqqBfPVOQlqnHFAHfcHOcqkpkAODv1Ea?= =?us-ascii?Q?kJ95TMhJ4JR+FCjzKXskjLoXyefREI3aRdg9Revvs73W+gOrf0kAONvJKiLL?= =?us-ascii?Q?e8uizh/0NCGLdGy8F2yG2XFd8QiV1zwXm6tsWfbqoirL4uBhT5yvGfmBg=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB1926; 5:Q+LSRgfz1yvt3reCClfpMAMvMsMa8DZn64t+beuiYuYk2WIkHwEtQs9lUKX9lwCuRQWu82Ad1NztXsrLR5FyaeUrIGSZrn93oV+YVeJZjnPOq6o+BZo88n2c+AO8nCS+bp1UY0/LWALaREM/xyvK01GtBbtvTIDcbvbj/lgXW58=; 24:RBcqDFwT5r4u8wmu++YLkaXNTWa7oKGco3RqPDa15ZyzjpODm8YlT1+oqAph4eLWbMfsSDz/XZOVn38XpHXdIrmTptaQRCuXdkP+TfXvv8E= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2016 15:06:14.2623 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB1926 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 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_ENABLE features. So move it after clk_core_disable_unprepare to avoid adding forward declared functions later. 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 55e62bac0fb4..e2e8f0c9f20a 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) {