Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932266AbbG1OaA (ORCPT ); Tue, 28 Jul 2015 10:30:00 -0400 Received: from mail-by2on0102.outbound.protection.outlook.com ([207.46.100.102]:23123 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755387AbbG1O35 (ORCPT ); Tue, 28 Jul 2015 10:29:57 -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 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 Content-Type: text/plain 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/yu6II64s4eHh8uEJKAtEMyQfKndBvFXJkrYefSuUuyLW7eFUmQ6zcMCQcaFJZKyhV5kj3Q9kxUSdfZJRCauv3TfgM8+m/ahN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B37p31nX4/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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4343 Lines: 183 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) -- 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/