From patchwork Tue Jul 28 13:19:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Aisheng X-Patchwork-Id: 6886501 Return-Path: X-Original-To: patchwork-linux-arm@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 5B11BC05AC for ; Tue, 28 Jul 2015 14:32:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 51F932065D for ; Tue, 28 Jul 2015 14:32:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BDB72049E for ; Tue, 28 Jul 2015 14:32:43 +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 1ZK5u7-0005LG-9l; Tue, 28 Jul 2015 14:30:51 +0000 Received: from mail-bl2on0105.outbound.protection.outlook.com ([65.55.169.105] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZK5tU-0003WY-9f for linux-arm-kernel@lists.infradead.org; Tue, 28 Jul 2015 14:30:16 +0000 Received: from CH1PR03CA001.namprd03.prod.outlook.com (10.255.156.146) by BLUPR03MB1361.namprd03.prod.outlook.com (10.163.80.27) with Microsoft SMTP Server (TLS) id 15.1.225.19; Tue, 28 Jul 2015 14:29:50 +0000 Received: from BL2FFO11FD037.protection.gbl (10.255.156.132) by CH1PR03CA001.outlook.office365.com (10.255.156.146) with Microsoft SMTP Server (TLS) id 15.1.207.19 via Frontend Transport; Tue, 28 Jul 2015 14:29:50 +0000 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; Received-SPF: Fail (protection.outlook.com: domain of freescale.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 BL2FFO11FD037.mail.protection.outlook.com (10.173.161.133) with Microsoft SMTP Server (TLS) id 15.1.231.11 via Frontend Transport; Tue, 28 Jul 2015 14:29:49 +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 t6SETZDI010845; Tue, 28 Jul 2015 07:29:46 -0700 From: Dong Aisheng To: Subject: [PATCH V3 2/5] clk: introduce clk_core_enable_lock and clk_core_disable_lock functions Date: Tue, 28 Jul 2015 21:19:42 +0800 Message-ID: <1438089585-30103-3-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; BL2FFO11FD037; 1:V3WovEhchv7HJSV/RcXsvCoPG/ggJRLhI9Z88oU1SbKSKf+sgrV3DFoWCPz9h860xrQD/SqnfuSSMfCct+tmuAPXNYxoPtfuBdJWkS687MCi+ohbIvNfo9CeczkrsJ/zISA+7cASyAnIRdBPppWv5ygziQiIBWDN0V8RWaXJ4y7dzU+GTuiMs2DfnaxEqQ3D9f4cydcT2eCv+SiW69cC80FZ2SXe3LQrSBG9o+akxRuXM6rq2qbbkATxq83QlKmcmaTf6H7iZYDa6jp9YGUhJReNr8M22Cio6pG/DQZUXcK47BpVxl3/XXWiXVmgrVnAfexcFg6AmG3EpGNUrtSX9Q== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(77096005)(106466001)(33646002)(104016003)(2950100001)(46102003)(105606002)(86362001)(110136002)(76176999)(5001960100002)(48376002)(50986999)(36756003)(50226001)(229853001)(87936001)(107886002)(2351001)(19580395003)(47776003)(92566002)(77156002)(19580405001)(6806004)(62966003)(85426001)(189998001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB1361; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1361; 2:whGnjYEJi4pOyq8k5rd0Y9tXeUvHC63noanBkNxqEWoYRyOsldsXsARmzGNtjx/Fynq/KDK+8Sn+A0Gyac6E72b6ZVQ2SGOeqARGdZw6cPLyEWP1/gp1N9wZSKbWj5jxE94JpdipYsVcZZO9MxYg4dHraaP7ga5pW0Lc9Skew6Q=; 3:AnUa2dyFH0DZJR+e4jOhLNDVi9br8OGUTCiDCCvatXY8DdKLZkkIHNi2mZO/0OpksVLCgodiqBWHGL7cRu6tXmiB7lX+sAWT5txThwGlXrVLKwwB0PN+ebtWHPvJ9kTsZNd0dQzoA3m1KOZ+Mt1vHpOAc7tDLEY7wC5WM8R+XwYc/o/B6p2wzQiKk/jY4cZB8fMtDA5tToAYqZrvQ5T66Vib7uaSeZRaoYKcFC6h5Kc=; 25:G0MEFTUCLWSS52Hh76S2eu3U24VFsvvBuC7eFrg5CAuUqTXd6g68PgwEgNlZy7ZXW+GiR2j5fkEKyw+2HFq7AA/gveOq559rxB3ByUzCJbkAIMhV0tcl2VXOrlKKb9NEK57xFNyFyZ29g3qLtPjSvs6tQEdABe4/WcwHme0FzJtQiqnKkfUN/PeGVPTFuTVZYiiQjv/LPP3sNFyifJo+zqLLMqEWkjkwEfwyz/rlO4GL+Ay0np4A8f9k2FqSkojd X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1361; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1361; 20:HFYxMZd71DCD1OZSRu6A0z5+7wR6+78GEzF2CDAfvtPtrenH4TTDFXiNX+cz0yfR/Ni3WPAPoxiKfKvu8/7GMXlfshJcfayZcM91HBvox/5aRhH4hfaywcuBOcizFsl7fW3P7oqrojGIeRAY65euu6ft/uwKg6rSyVTtMi9Jr9M6f8zWHD2uagHuUfNzegu6blUUBtkG3tdkLFtgised5g63xOxGsFAteQ8dSn5x6+BeXjJhNPcEvxv5exZh52XyCGHRplGVleHQ70/4hSOhsbTSj1wxS09ivz49CJkaQsGk6YJ50z+t0OBjb50ikb25wyxUlsz6r5IyTwWqVxmOv/92H/p9NqwiUOoCgCUza6A=; 4:PXZu8R2v/2pWNT6C07y2Q+lacmGXo6X/dhvA9NZprFwNYQfk8vjyRkmv1Hw+d35bv2X7QXOTZWWpBvTvcz441eKKlkSBfH8+9c6/NHkMSZ1NG6chNDr2FTp8tPQSVgdPaFjpCeicYDJCJyc0WqLeumyQ5H89G89P3vFnro/iwz1bwiBKlrQxpQbj0CMDIAH8VtyWd2Trpafgv42ajIc+5G2FzBh8cmvyvtt1O7M1FOkytDkSMFFSmgZyZNk36ujDp8UdbmdFuoler1AwPHqSD6pK8opJO+5R6HYgBFDRULA= BLUPR03MB1361: 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:BLUPR03MB1361; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB1361; X-Forefront-PRVS: 06515DA04B X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB1361; 23:P6+MhkVoxoZTvgRH3e1XlwUasomYcNY7dVI6u8xZjho4oAyc4HFYf2dz3tLpAhmNHG5V5umXdZWY1903aKheMk/d/yu6II64s4eHh8uEJKAtEMyQ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38Gim5y/wh0qw1w7uts3GeCpEgpcvE0=; 20:7e7s5AZYM16kO1axt34BOGvKtvE5iGDeEel1s7ou2LckgB37p31nX4/FT6MWcUE3uzh69fKOz5HaVjJSDx9gqA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2015 14:29:49.5967 (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: BLUPR03MB1361 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150728_073012_895782_BAA5A80A X-CRM114-Status: GOOD ( 21.53 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ranjani.Vaidyanathan@freescale.com, b20596@freescale.com, mturquette@linaro.org, shawnguo@kernel.org, sboyd@codeaurora.org, linux-kernel@vger.kernel.org, r64343@freescale.com, b20788@freescale.com, b29396@freescale.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 This can be useful when clock core wants to enable/disable clocks. Then we don't have to convert the struct clk_core to struct clk to call clk_enable/clk_disable which is a bit un-align with exist using. And after introduce clk_core_{enable|disable}_lock, we can refine clk_eanble and clk_disable a bit. As well as clk_core_{enable|disable}_lock, we also added clk_core_{prepare|unprepare}_lock and clk_core_prepare_enable/ clk_core_unprepare_disable for clock core to easily use. Cc: Mike Turquette Cc: Stephen Boyd Signed-off-by: Dong Aisheng --- drivers/clk/clk.c | 85 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 4c7f7b2..c2310d5 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -583,6 +583,13 @@ static void clk_core_unprepare(struct clk_core *core) clk_core_unprepare(core->parent); } +static void clk_core_unprepare_lock(struct clk_core *core) +{ + clk_prepare_lock(); + clk_core_unprepare(core); + clk_prepare_unlock(); +} + /** * clk_unprepare - undo preparation of a clock source * @clk: the clk being unprepared @@ -599,9 +606,7 @@ void clk_unprepare(struct clk *clk) if (IS_ERR_OR_NULL(clk)) return; - clk_prepare_lock(); - clk_core_unprepare(clk->core); - clk_prepare_unlock(); + clk_core_unprepare_lock(clk->core); } EXPORT_SYMBOL_GPL(clk_unprepare); @@ -637,6 +642,17 @@ static int clk_core_prepare(struct clk_core *core) return 0; } +static int clk_core_prepare_lock(struct clk_core *core) +{ + int ret; + + clk_prepare_lock(); + ret = clk_core_prepare(core); + clk_prepare_unlock(); + + return ret; +} + /** * clk_prepare - prepare a clock source * @clk: the clk being prepared @@ -651,16 +667,10 @@ static int clk_core_prepare(struct clk_core *core) */ int clk_prepare(struct clk *clk) { - int ret; - if (!clk) return 0; - clk_prepare_lock(); - ret = clk_core_prepare(clk->core); - clk_prepare_unlock(); - - return ret; + return clk_core_prepare_lock(clk->core); } EXPORT_SYMBOL_GPL(clk_prepare); @@ -687,6 +697,15 @@ static void clk_core_disable(struct clk_core *core) clk_core_disable(core->parent); } +static void clk_core_disable_lock(struct clk_core *core) +{ + unsigned long flags; + + flags = clk_enable_lock(); + clk_core_disable(core); + clk_enable_unlock(flags); +} + /** * clk_disable - gate a clock * @clk: the clk being gated @@ -701,14 +720,10 @@ static void clk_core_disable(struct clk_core *core) */ void clk_disable(struct clk *clk) { - unsigned long flags; - if (IS_ERR_OR_NULL(clk)) return; - flags = clk_enable_lock(); - clk_core_disable(clk->core); - clk_enable_unlock(flags); + clk_core_disable_lock(clk->core); } EXPORT_SYMBOL_GPL(clk_disable); @@ -747,6 +762,18 @@ static int clk_core_enable(struct clk_core *core) return 0; } +static int clk_core_enable_lock(struct clk_core *core) +{ + unsigned long flags; + int ret; + + flags = clk_enable_lock(); + ret = clk_core_enable(core); + clk_enable_unlock(flags); + + return ret; +} + /** * clk_enable - ungate a clock * @clk: the clk being ungated @@ -762,19 +789,33 @@ static int clk_core_enable(struct clk_core *core) */ int clk_enable(struct clk *clk) { - unsigned long flags; - int ret; - if (!clk) return 0; - flags = clk_enable_lock(); - ret = clk_core_enable(clk->core); - clk_enable_unlock(flags); + return clk_core_enable_lock(clk->core); +} +EXPORT_SYMBOL_GPL(clk_enable); + +static int clk_core_prepare_enable(struct clk_core *core) +{ + int ret; + + ret = clk_core_prepare_lock(core); + if (ret) + return ret; + + ret = clk_core_enable_lock(core); + if (ret) + clk_core_unprepare_lock(core); return ret; } -EXPORT_SYMBOL_GPL(clk_enable); + +static void clk_core_disable_unprepare(struct clk_core *core) +{ + clk_core_disable_lock(core); + clk_core_unprepare_lock(core); +} static int clk_core_round_rate_nolock(struct clk_core *core, struct clk_rate_request *req)