From patchwork Thu May 14 13:29:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Aisheng X-Patchwork-Id: 6406241 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 45DBD9F1C1 for ; Thu, 14 May 2015 14:42:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 45A9220437 for ; Thu, 14 May 2015 14:42:21 +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 3F5DA20412 for ; Thu, 14 May 2015 14:42:20 +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 1YsuIE-0003sS-Ci; Thu, 14 May 2015 14:39:22 +0000 Received: from mail-bl2on0134.outbound.protection.outlook.com ([65.55.169.134] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YsuHM-0003OW-W0 for linux-arm-kernel@lists.infradead.org; Thu, 14 May 2015 14:38:31 +0000 Received: from BN3PR0301CA0007.namprd03.prod.outlook.com (10.160.180.145) by BY1PR0301MB1205.namprd03.prod.outlook.com (10.161.203.154) with Microsoft SMTP Server (TLS) id 15.1.160.19; Thu, 14 May 2015 14:38:02 +0000 Received: from BL2FFO11OLC002.protection.gbl (2a01:111:f400:7c09::107) by BN3PR0301CA0007.outlook.office365.com (2a01:111:e400:4000::17) with Microsoft SMTP Server (TLS) id 15.1.160.19 via Frontend Transport; Thu, 14 May 2015 14:38:01 +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 BL2FFO11OLC002.mail.protection.outlook.com (10.173.161.186) with Microsoft SMTP Server (TLS) id 15.1.160.8 via Frontend Transport; Thu, 14 May 2015 14:38:01 +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 t4EEboxI007474; Thu, 14 May 2015 07:37:57 -0700 From: Dong Aisheng To: 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150514_073829_459598_E193534E X-CRM114-Status: GOOD ( 12.08 ) 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=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 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,