Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933118AbbENOix (ORCPT ); Thu, 14 May 2015 10:38:53 -0400 Received: from mail-bn1bon0118.outbound.protection.outlook.com ([157.56.111.118]:38289 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751221AbbENOiI (ORCPT ); Thu, 14 May 2015 10:38:08 -0400 X-Greylist: delayed 104621 seconds by postgrey-1.27 at vger.kernel.org; Thu, 14 May 2015 10:38:07 EDT Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; From: Dong Aisheng To: CC: , , , , , , , , , Subject: [PATCH v2 3/5] clk: move clk_disable_unused after clk_core_disable_unprepare function Date: Thu, 14 May 2015 21:29:01 +0800 Message-ID: <1431610143-21853-4-git-send-email-aisheng.dong@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431610143-21853-1-git-send-email-aisheng.dong@freescale.com> References: <1431610143-21853-1-git-send-email-aisheng.dong@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD050;1:IbAhEX62t4erqFO5Nch9aTUfND8gvSG+tB5HnMPFnppLXrBFEhS/0ZBZWRZl5cJYJ/NEt6nEqIsfXguoIE/4RxDCHxkS7CjQNeDInHDXpKpNzgbOb1voGf8OnPWQgEeLrEcEd/+BXRfsIDp0EUESQVFR8z45Bpe01y/GUlpo+9ovtQtub+amMd1BKHMFW4PBtQfd/bOxm4IeEatyEuTZL0BEdjKboX6pUFgl9IUxRWBBQ0MbJhjnq5Kvg7iZ+iA5XnuHV27bAAe5S/onwbIvV+qDLzDrlaHbTF1agsVPiqy3IuS5GIg24oFAkGslgUt+DBAjrZvfXTDWO22ekSI+/g== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(979002)(6009001)(339900001)(199003)(189002)(189998001)(104016003)(107886002)(110136002)(19580395003)(5001960100002)(19580405001)(48376002)(50466002)(33646002)(77096005)(105606002)(50226001)(81156007)(6806004)(87936001)(2950100001)(106466001)(36756003)(76176999)(85426001)(46102003)(50986999)(92566002)(62966003)(77156002)(86362001)(47776003)(229853001)(2351001)(4001430100001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR03MB1368;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;A:1;MX:1;PTR:InfoDomainNonexistent;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB1368;2:yQU6ZFqOFfPn46tiz5pc9OOV9S2nFStdUt0n0tSjqiSd8V85tr00JXl4O5DLY6UL;2:LL4X8ZxqISjJmY2ShiWhKYks11ZBLqG0RYK50/8+OzIDXDvrgwIRU5lLq4or7d+ozvIoJKFFyUKDkPpYVsPM0VSBlYhHTJaKwR5cUQAErcr7gwH6gQhvcQTijJyLzGPkIDIEZRoRc0wDnQAp+PDrVsarF7pNAIZQmQeeOUhXxU84sZl8i+lThrV9nzjhw2nO1wf10ynWuRW/56wmZgVRxRLzNBhr0A0ApWhIZgclANM=;6:CGeyhjkISesU7qtlHNcQfXnhEkQSSpfed7B3BVzA3My0kurbNHjoObp1Pn+vBwQwnDHF/Cg5pV4sfnw2IFvaJogUYHOisTdxmxOwZgHgpyndnDQqJgfVNj9urD/IP68lUuDDyKbk1UprW0adW8KPTMUDeYwpTq1O1bSywkKoiVDfpKT3O32ltRW62P82R7IOSeKCrLL+jLRJbneG2B0TJ/dmAFDcTotZlCWvKKE1C43dk/OvybTeYmrJc3xx1kmc23eeL3OV/R4R02sGmaqqYVJP70IHGy2oahMjHg7q/4nKIl0eBQsYIM6LBFMnGVtCEsS0a5+spoLj8AtduFvhQQ==;3:c02K3DQVU0GWpRydNXKVRBZ6hbOk0ohL77wgl5nWVs4h3CzfUZbqi7085wOJY8fP+oBBKxXMOcUVVrAfer8+Xp1kbnjQNmdeb8RWGF9EYzaGui/nI+4K43Z6hdpRbBKxACXQaerDxaNVkJgEdGUD+FGVjNv6iiV8cH5B9kBEWojsNx4i6Wei1jxgPOD5u/9mUknGvlLY2ZOjWfd1NRHyumSDwm9Z0AEDVopOY6dPjnahhzIY0y55+NlADvPpyDVlGCk/PyrODTYzVR35qBUi9RHagjFuMlxPN1ySlyx5ec4= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1368; 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:BN3PR03MB1368;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1368; X-Forefront-PRVS: 0576145E86 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR03MB1368;9:ChRr+nzu39whcGlxRxoLIgGr2k8bI2aLziob/2o/er?= =?us-ascii?Q?oBBVjnleDhLeDeM65FSBdW0wee0UI67gbgzDxMZz3gPF+Vw68LHFTzkQX4iU?= =?us-ascii?Q?5+oH5tcMNVV2/iHr4EQonR6xWmDY+G6IWEdRv1OFLxugboMdGn95aikVbUMn?= =?us-ascii?Q?Ai+LYq/bhXIbMPxAV7d/UDc8hDpmTkzrcUIYEuMXcmeyT31qupPVYJdxXhpp?= =?us-ascii?Q?BcFBELav515oCjYfz9w5MEUhZ8JRjo+r4JrCYVfWLONHgqt6vu8Lv6/JvrbZ?= =?us-ascii?Q?gAuJdb2NANcFushA4M5hYh9KkcwsNmvAlvc3boIYJPgGYM2R5g7VQjM74m6z?= =?us-ascii?Q?tkd/NBtT4YppRtnqDuWRgEebflACGQdEH2Kn1oouq9x+2hKkmNLhs6+oo+NG?= =?us-ascii?Q?/fL6DyXgimWZIzNUy/rf4APLZAeB95jKS/LYaoVSNO9AX0pWk5GX0HLhs+Xv?= =?us-ascii?Q?zxfijDmORe1xzlQ5N0870PpNQOlG6RyQNXfzlhcGrsIFEKXTASpqI3JcwL0c?= =?us-ascii?Q?Iq7M5VxkiMZ13k3Ii3KUKWs5hMtCtOGYrza1CdawpODAzUuxsZhL00ExCsEG?= =?us-ascii?Q?y5EeI+0PCGofjBiUykz6T5heBAUGSDYl3ovaXQejhwQ3uZnyFngI+c99Q7hX?= =?us-ascii?Q?nzOk9+8T0GpaAL61nnEabTEKzcasmvMFZW9yFsfXH7lQDFriho6afYkPHHX1?= =?us-ascii?Q?Pu9st/F3AqTEvMn0mEEg3aJml3H6gEmpKyG+ufOGSbKLRwzi3WnYxMNvHF9y?= =?us-ascii?Q?6oV++eUJsehuq+Ty0nRRbXIgeh1D04ZgesoLilHadBY11b/M57LG81YQUDC+?= =?us-ascii?Q?aPDH0Oa5puStMYvqBRGBqT7F3kkl9LSerafzFNO1U2MI5HoG4bXis6gU49/7?= =?us-ascii?Q?K0C7bjPVZafBh+MsZMSTFFrsrksKF5+bJ6IkyiMImWDMCsK3WTbTu7rUZIns?= =?us-ascii?Q?nUL0wePDO9gDXiF95bt+6URy9lagM0i/WUhe6fCuiPdQcUw3VxHntGMRyT0u?= =?us-ascii?Q?yg7CWy0620DOZ/adjT8NLC0j16WkXspLiGTGBmdEZrEA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB1368;3:HMzgBvZbs1lJb602A7wPs6D65PWpJV4XQKnpSk0rZ2upZpX671CICYJuZcZ3uuY/Yh7lZ4iKKMUIaRdHJhnG8lRsAvkZnkubKI8dBgxwLGspmlonU7kPQ7O6PIr5psmdGghyj0OnjjA5KFYWYZadLQ==;10:v4BEojN47at30TTnwfVdKN+73jdUg67D3kPOBIaxtvtDhs5E6hlr2zczQyak6Z953v3iBi73yEyRFi265ju1aVeImuCv6mXU5KV9vNKynrQ=;6:OTNuiDej9LsHHBoafUv9LJ604Ri+UYmTmMfpl0pFSnMxPnNzzaY0Xz0A7WuMUp9E X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2015 14:38:04.8869 (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.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1368 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6004 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 2f44c8c..597d6d2 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -162,104 +162,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) @@ -799,6 +701,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 unsigned long clk_core_round_rate_nolock(struct clk_core *core, unsigned long rate, unsigned long min_rate, -- 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/