From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933227AbbENOjN (ORCPT ); Thu, 14 May 2015 10:39:13 -0400 Received: from mail-bn1bn0104.outbound.protection.outlook.com ([157.56.110.104]:28984 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932662AbbENOiH (ORCPT ); Thu, 14 May 2015 10:38:07 -0400 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 2/5] clk: introduce clk_core_enable_lock and clk_core_disable_lock functions Date: Thu, 14 May 2015 21:29:00 +0800 Message-ID: <1431610143-21853-3-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;BL2FFO11OLC002;1:JDQC9LkpgQro2m4vzrE7r5o4OG5iPudYoN3oJK8/PtX0+/AdSuIqJ7kU1m2tEKnqWxOH0If+SvIQy+CPZwc/ewiaIL7sDDq436uPgIYsW97XuxMpCJFXTBqsTtoF9WphMEw7mrEZHPDynqzlUpC/YptZ16ZDW4NWpmeKkES3o/F9jpOlJ3hy9iM9BxhexxDX2bDzDXsz7yS7ExMWVR62Xvq6CRTvHNXJ5gq6i5OZKl/Mshaqb30WJRMn9my9liDv2WHqGe2sT1tMr+WnOKB5r6oWQr+Ow2iWPQw9xSqZQw5EwQ+6zwKk5BPnN6fuiEsih0tOiayAXkjJtQg5SWd2kg== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(339900001)(199003)(189002)(189998001)(104016003)(107886002)(110136002)(19580395003)(5001960100002)(19580405001)(48376002)(50466002)(33646002)(77096005)(105606002)(50226001)(6806004)(87936001)(2950100001)(106466001)(36756003)(76176999)(85426001)(46102003)(50986999)(92566002)(62966003)(77156002)(86362001)(47776003)(229853001)(2351001)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR0301MB1205;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1205;2:dKyoq0IO/l6TZbZZ5F4mvYSovcQElrGtXO/e9MVZ+UTjnmIop5/yYzBo29QxUsQe;2:Fp5sCap+2KcN8eUvhwxJaERCnBzOnnu/4CzpF/lcX6lYJgc1bcX33i+F3i8Xe1Gob4ZRXCpRKuVHWX+mckkFxXLIJdNzP6UvOZYTGNWcLBL4GOGN++jr5TRt2k7weZwW7jMpkY51arJii4jKAa7UGQOhCznIOp2oAR0p8ws6jV13J7MGxlZZiZIR4sUdpjHqQn4w4ju+Q1ivv/vkmPtSsMCV/kun1hpAeZW3p26kcpo=;6:1wrIES9aObbe5zkoOCbexoGlTz/PwD23Lm/0j1YpCG6oofKwuWwv9NCO9caue5OqwBuV/xwJxiJnVaJVPoOs01s9uXJn1C8jwxBmsuEQXbGHJSo9waMWiYyLBg9F8Y9qYx0ePB0Y4R4STY592vDzsaF1wMQpw0pe/VcGUXFZqXABaj5yRWS2FJOCAgSTdSeDnYU8mAUI++2UmuwbTuRXyVFvy8nzhj+2QuEJy3uuMVpVnyycutFw1wM3C8n2joWl6UlbdFt1XDk+nUPzzNVFZmVzDZBmyc1iFOUaeldLbOmrqWRei0Mgk5ireuKD1xZmrIvMXRYvPY0rlZmgWTPBRQ==;3:vN34WC+7LT3Li1rpQrr2Z6p+aJ7ITAWlW/n0bmtes9WERzQh9oift4z+stmk6BEILtoFvTxeZdpbod97RfdeyniDfSglTs9wDyysfajD0BLP0j4vQCh5l/fUIE6C2X1166qVbPwVHvMT5yv+wAmA/5xWZ11JrwuBQShwBEUFKJ4uZod4fCYTFrmoqzSJg1/LFq5venLrudFA8G0bqBE784umylJnHj3cGt/uosBwqXjNvFS/m7DOEyb8gXdBrxsvM4pD/xHv0GokYmPMf/+Kjbz+RbHFuVs0vgqXMHgXI6o= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB1205; 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:BY1PR0301MB1205;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB1205; X-Forefront-PRVS: 0576145E86 X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1205;9:T5eQWAHaQ8P4FAjcJp4tLJcD82B+gdVUzm5oPT6kVkYUYz1Z7N/4i2K+bGt6QrRbhnXDeNFtxw8ijfKCgL+dCmerlOGxNqexk33k0nBDeZ92nB82J9BNQZsfYP33pObB3EYaWd6oC3i7CszpYN3Tvt60EZwxPsdbL2FGE1N03BKnnSX9ZQgG7kyC1ZbskmiVaaIpUTZZmKher4G9Sj//tSLueI2NSmM07+UTPP4a5YuHYdpsmjfAzw5e0hfV75eLL0jzaDndKnjj+cnuL6z3LJaFnrGLngn74PET/maxnnan+ZsB9hckxCEin4eLVUJsrU+5oy4S1rfY9swk1hSQr1rdIbQdY9FixyovArq9SwdXN9WaLfBKHmzsj2G8JLyWG5axhsqiJ14DSulenDwKpNaoTHkP3G19dOn6oY4GTRYPW+wNzduAeLbpUj/+t1ZofWl/M75L3fmzSU3AIpZYl3UPj8sb7eXh1Wqu5W8vV+KrfsYA2734mNEDBLV9z7+Qe5HmXOUCCRp3m7Xf+AqYtRPCjlZ+WlZWZ6VFj4fArhAfssoLfMKpiaJ4n5dSieNSRCxUM3J9JfhOyPOasz7JiH7Jia7gVaFDfmjMlQ/gqAXDiM3SUisb4lvMapL9jJ8Ts9y07v9LCfMyGkKsfOpZ4M4vNbCqqOifWxabtltHbE/UZDzEN7dUes7kZM79XU97FNZ+dcylhRBkCzjXGd/8tswtU7hhbPabJbFuz0iCvAEvj75pDFfZjUqPN8sECCg+iGR8ZKZFMp666t0F99fV3ovZif9EyT5BN/aF65609vmzBBvBzRfclad5CPiSkUZcqgqrf1vZVLavMjOike02XgvUK0Woh1dR3RpariEBJElReN6OEWrhwGM/OSanGDwkcFI1d1MRJgml+cRMoJcRpQ== X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1205;3:QmkJ3mpnW7kSzZfLDGxrJUwizxJzDe4LofxXUhP3FttWlcVXUEeJQrZucJ1yVzwHCtR6emvW6xsCT72tL8NB/LueZlHGog9WKgaY7+65gJovJ/b03W5FrkPBPn1dsr3c1lba53p6AvpLrcQi+frKOg==;10:td7klLeTlUprtMSSWgQxaAms2J+gil+6AOn1FWIAXcyVhTJW9OFPMc/ALhL1JoRY225poK6t5MH/bRPOdy9mqHTyHePzf5wl2/ohvqa81Os=;6:OFR/z3Zm+PVjIqDrxb3fSfg1IgjfAkSfo8LtcNEe/NTNffOXn/STDY9Gnz3jef/D X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2015 14:38:01.3686 (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: BY1PR0301MB1205 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 0e813ea..2f44c8c 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -565,6 +565,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 @@ -581,9 +588,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); @@ -619,6 +624,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 @@ -633,16 +649,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); @@ -669,6 +679,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 @@ -683,14 +702,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); @@ -729,6 +744,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 @@ -744,19 +771,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 unsigned long clk_core_round_rate_nolock(struct clk_core *core, unsigned long rate, -- 1.9.1