From patchwork Thu May 14 13:29:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Aisheng X-Patchwork-Id: 6406251 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C26899F1C1 for ; Thu, 14 May 2015 14:42:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D796520457 for ; Thu, 14 May 2015 14:42:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D86DA20437 for ; Thu, 14 May 2015 14:42:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YsuIV-000405-W0; Thu, 14 May 2015 14:39:39 +0000 Received: from mail-bn1bon0138.outbound.protection.outlook.com ([157.56.111.138] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YsuHN-0003Oj-18 for linux-arm-kernel@lists.infradead.org; Thu, 14 May 2015 14:38:31 +0000 Received: from BY2PR03CA012.namprd03.prod.outlook.com (10.255.93.29) by BN3PR03MB1368.namprd03.prod.outlook.com (10.163.34.154) with Microsoft SMTP Server (TLS) id 15.1.166.22; Thu, 14 May 2015 14:38:05 +0000 Received: from BY2FFO11FD050.protection.gbl (10.255.93.4) by BY2PR03CA012.outlook.office365.com (10.255.93.29) with Microsoft SMTP Server (TLS) id 15.1.160.19 via Frontend Transport; Thu, 14 May 2015 14:38:05 +0000 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; Received-SPF: Fail (protection.outlook.com: domain of freescale.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 BY2FFO11FD050.mail.protection.outlook.com (10.1.15.187) with Microsoft SMTP Server (TLS) id 15.1.160.8 via Frontend Transport; Thu, 14 May 2015 14:38:04 +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 t4EEboxJ007474; Thu, 14 May 2015 07:38:00 -0700 From: Dong Aisheng To: 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150514_073829_388819_DE2941BB X-CRM114-Status: GOOD ( 10.94 ) X-Spam-Score: -0.0 (/) Cc: Ranjani.Vaidyanathan@freescale.com, b20596@freescale.com, mturquette@linaro.org, sboyd@codeaurora.org, linux-kernel@vger.kernel.org, r64343@freescale.com, b20788@freescale.com, shawn.guo@linaro.org, b29396@freescale.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_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: 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,