Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755626AbbG1Oba (ORCPT ); Tue, 28 Jul 2015 10:31:30 -0400 Received: from mail-bn1bon0117.outbound.protection.outlook.com ([157.56.111.117]:49077 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755340AbbG1O34 (ORCPT ); Tue, 28 Jul 2015 10:29:56 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; From: Dong Aisheng To: CC: , , , , , , , , , Subject: [PATCH V3 3/5] clk: move clk_disable_unused after clk_core_disable_unprepare function Date: Tue, 28 Jul 2015 21:19:43 +0800 Message-ID: <1438089585-30103-4-git-send-email-aisheng.dong@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438089585-30103-1-git-send-email-aisheng.dong@freescale.com> References: <1438089585-30103-1-git-send-email-aisheng.dong@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD040;1:vs28f0+uLoP+RbmkVWiFAAC3CYXXgpOG6FJ4LQX/n9vJQJZEat3SWNEIbfpdKD7Z5VozRE6cattG2IBY2UtzLVyITiN/Eb9+q1dkK06ymNJYo+gRLkJGC5XxM0iqiHT19Xw6qdyTt0AGyRNWjs/5Tm6ozS6OfKwK7LGvzlhX7CC1PYc7x25XWnFjsvb4Lt58BF5j/L9YE/P9Snaf+CQIrUl5WJIUN3MSbUCOF37F9ylZqg4HIaNW4k1shPlhxoRHoRwMiZB86nNfSW1xyiUZZRI2CDz9yOvM4uEzAjorcrSlBFHQK6rpBbTT4NZF5Ct6DkVD3X4Ld2XGVBoPmQeyqA== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(86362001)(5001920100001)(87936001)(106466001)(50986999)(76176999)(85426001)(19580405001)(6806004)(105606002)(77156002)(46102003)(19580395003)(36756003)(62966003)(92566002)(229853001)(5001960100002)(2351001)(107886002)(47776003)(50226001)(104016003)(2950100001)(48376002)(110136002)(189998001)(33646002)(77096005)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0301MB1209;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1209;2:/FkLDOAsYUeKuM4lNQjBndtg+lY6hZRPhr4STXUrnk/nMEmQaHMTLLIWI3PnA5IS;3:AT5Pmzt8aIX6+qPjmFXDzVAoobxVHmnP6Xi9TJ0AQ/AiLLNZl/X5X7mbQL0FBazWie6G5l9Sp2DEvkBCfIrEDR+V6D8uSyfeMUWgV/4yhg3YndfeCH7Q/IbOuHGjlJg4h3tP/bk5PONyOEEhrZYd3/B+I6G4zFID6YIYrf3T9fsC0AR1d8R+OMcr/nj4mpdnxXG/rBR0QBEsXJivqrcHqKxIa0uy/rRzQIzQLqRrtto=;25:8m3gS2Z+S1B9/quXbMc2+Pb6DlMkavIfNl8EincHgKN9UY8VZPKMRcuuzz/RD9N5c1JdPmohawveoZ52/1kVMo6EnIu1ruS5j9GNkz0Ni/tM1ZCVpdJRd50ubWa0+e42tBHEr2Jpj6dSsCWy4oOoESYJS7PiYtf5iF+xH10Ruugz34gNDlSx4RgZ4vetvoTaE4ECPNqMDSrm1b+dE+dZGnEjUZ2UCIj6B0kln/K8pmP+t4lzB1mTzrqX3tCHJ+BYRPSwa/oPK94t5iNYwBqkKQ==;20:1vfwOgZcKshfayPiSwBzdOJ/P1HL2lT4ClYfDLfDiHQgLpefiSsl2qfPgdcdOaFVKOrfeGrQY/704XxhkeSPWCqqG2IHjg/GDVY22OznVafQ4qA0E/cUJiW+Rq+3OOBXgfeOzgFiixI6Xd5VUwqFtSopmuPK4xoxkJxTDUhlHAHUKmAwcdSGbNFjljiC8GmmZT8YJMG8FVQRpFLYk18fpEEKkgSBP53/plkgJVS0oB3hu5gvycS9pHX4UaRoUIJJsRpOSjZZVP5P/vLo9Jqin30XywiV37Rh8KXLbTziQfwtQWhxcmzxUa5MHy0RbKR7y0LG7Jg1kJ78HJ+CqpV7I+6l65WAOJB0f9e0c/lqhfs= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1209; CY1PR0301MB1209: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:CY1PR0301MB1209;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1209; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1209;4:pqD6oWU+hjouml5rAmQBGmFYHJzR0+HfzgeJEu6Moo5gKAkJ7lwFWbwcSl+aCDlKDwZ8MGZM6fSnF56u+yGWJcOtYJlApaivCkXVYyutYl/+yRC2WITWP856mSyv/GxaeGlasH8EeQkPp6VQlTXtMxG7dKhS17E1v41W1MRGO2eGw0Pq/s8N75iAAnodJsYFxrlBY55exreMfStXV6qENmafscefSwk6BPglmAqVfmS43jdZFmxm2NOtQNRJypDKoSN5Vg89vwm2oKDC4Lne3yTaiS5WphW0WAsRuXNMr8c= X-Forefront-PRVS: 06515DA04B X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1209;23:Ktu5I5G6kETbhu3jLA22qzz/9YAJgTTPOwx3HuF6QGTBid0vMIKovGMMqQSxuvLsa7f2qA7mAYf4pdar9lIXoNbVJMRuFfg9mALQkEZsjK1k1Y1VkdBKzp8VI3RDmyNZOD8Mx5Ub3DjwcytTDTlcH7776PJ9rvL+fWHN4Nw1fuxuywBUpRp0SVd/aRr7qdwygW0BCZiACpbVthBYZecdNQqkhJ7GKUY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IBrEmFwmP8J9JIg5ybYZxN1iXoA4n4h7ZijzW7VYyx9qKg2LNdDmke2kQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2015 14:29:53.2852 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1209 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5980 Lines: 235 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: Mike Turquette Cc: Stephen Boyd 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 c2310d5..ac158c4 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -171,104 +171,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(struct clk *clk) @@ -817,6 +719,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) { -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/