From patchwork Wed Apr 20 09:34:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 8887581 Return-Path: X-Original-To: patchwork-linux-clk@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 73F7BBF29F for ; Wed, 20 Apr 2016 09:42:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B47E2024C for ; Wed, 20 Apr 2016 09:42:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F7BB2025A for ; Wed, 20 Apr 2016 09:42:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933387AbcDTJmQ (ORCPT ); Wed, 20 Apr 2016 05:42:16 -0400 Received: from mail-bl2on0069.outbound.protection.outlook.com ([65.55.169.69]:4436 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932079AbcDTJmM (ORCPT ); Wed, 20 Apr 2016 05:42:12 -0400 Received: from BY2PR03CA039.namprd03.prod.outlook.com (10.141.249.12) by BN1PR0301MB0707.namprd03.prod.outlook.com (10.160.78.139) with Microsoft SMTP Server (TLS) id 15.1.466.19; Wed, 20 Apr 2016 09:42:08 +0000 Received: from BY2FFO11FD052.protection.gbl (2a01:111:f400:7c0c::170) by BY2PR03CA039.outlook.office365.com (2a01:111:e400:2c5d::12) with Microsoft SMTP Server (TLS) id 15.1.466.19 via Frontend Transport; Wed, 20 Apr 2016 09:42:08 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.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 BY2FFO11FD052.mail.protection.outlook.com (10.1.15.189) with Microsoft SMTP Server (TLS) id 15.1.472.8 via Frontend Transport; Wed, 20 Apr 2016 09:42:07 +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 u3K9g0iQ016915; Wed, 20 Apr 2016 02:42:04 -0700 From: Dong Aisheng To: CC: , , , , , , Subject: [RESEND PATCH 1/8] clk: introduce clk_core_enable_lock and clk_core_disable_lock functions Date: Wed, 20 Apr 2016 17:34:33 +0800 Message-ID: <1461144880-8724-2-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461144880-8724-1-git-send-email-aisheng.dong@nxp.com> References: <1461144880-8724-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131056189281936103; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(2950100001)(86362001)(189998001)(11100500001)(104016004)(586003)(1096002)(6806005)(1220700001)(5003940100001)(5008740100001)(110136002)(77096005)(76176999)(92566002)(2906002)(50226001)(50986999)(4326007)(19580395003)(19580405001)(87936001)(85426001)(48376002)(36756003)(81166005)(50466002)(33646002)(106466001)(229853001)(105606002)(2351001)(7059030)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0301MB0707; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD052; 1:ov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cSW+YXLHE2QnhB8Zt1eQ+K4Q2OX/Ey5WTYfvHkyr/wQOAIUdI2uQPCmrl/pLCOIBn8NSVJqtFDqcNInDNlkthd+G4UwIg0UGEDfa5/ApmNYLaEC0usMgU78f7bE+4EZd1C49ZaggGa8NRxG2Jgb+ja9ZWsCCvm9WSxLYb1Ov7IAkv9WaIG2wE= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR0301MB0707; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0707; 25:9LQnJC3s8ulMnqlQWnlIXJifLkQZwA7herpoqWp8abcwnX3cskdV3b8Hr7Rqa5K+Asx49b14vqNJaIOLNU7AMngMHnE50iWgqBvAqntylL4DqwRJhbaTHrprevQmT8t4UY62NCSCzsS03wIX//ayoTO4Lm6FDlyTiVhkyCBDLvy688aJNHthJlZQ2Wcj9WEiTJP/ICvVKP6Z+AI6flqRD/SU2cgQM7pr35KwFTPJMHB7p4/A+2STe8znC8AOXDmmLRe+x0ic5X/+vDdauJDnz4WTXm6nLbLIRaLumUMtjfXgdBJ8kMsQtJK79KkmvVpVTuUT7mAK8ICRwQzRUx6BPqgaXPqMNC+mFqC25rganw3fRRucXBbw9xk1IuEuWIZFEwf6lPp86Cm2zv16koxyjt5GB0wtERumyK0XR6wiaYMBauvbB9UBi+DbS9okhGK8vXN+BBhNfy4TXQ2LJzSQEpuXW2ZwcRRStboXPGk9+s9rJTzd6DOUeN8oK2fU2NZLPZIIijcbWf+hsmqK1nmxHUdjqXudFwZ6YP/9HASL9d6+qo810R7U/MNMgHbpFT4HAE2TOaeCOkAYt6oZBZovI/Q02UnMSG4lm/6Mh0jnyfPC817CDy++iCQY0y+EyiPXFXd5dKZ1KxK61fM9diqYeQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13015025)(5005006)(13018025)(8121501046)(13024025)(13023025)(13017025)(3002001)(10201501046)(6055026); SRVR:BN1PR0301MB0707; BCL:0; PCL:0; RULEID:(400006); SRVR:BN1PR0301MB0707; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0707; 4:vwL3TRuLS71ei+dTsxI5wMpuu2CVSCRA0Ca4aqqfyj2w2w2Ke2Qt46GmQZl5sG+GWjVQr4dH+4W8uUEAvFDQACaPU2j+MjvhiWxu0h0wS+QL9S3TrUi8K/FO9+jTQ3iYHUUugDm02Snz6nie8X4dHQAa4Oi03LdLOaS5JCX9dwt9ooKWNFXBKQKnGfWARBxn9efWeKeAnM4V2utkCtT8hWyhKe/Amq9BXHryTfxBrgupqZps49cZ0LdMOSIZr+f6vJs7Ids+93BI69ckU2Vt8pCTGdMIBYKhqlVRhzvLRjuOYP2YutcLSfrbFU+2eWuDuK9t89bxyacwrpwHlEKvos7wR4n5fRDjyi/R30LhPmfZhKxuWPn3Bbk3tebF2oervvBdSEMLT3FgIRyJ1Pb0cC4xil5uGKNJ2t+Pm4gImdyagmZqYfyZICi2pkudhaOJ5NbXk+N4J9Q7NUn8l9wuu4xqEd/lJyZ9t1VYq0pgd90= X-Forefront-PRVS: 0918748D70 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0301MB0707; 23:zEZQlPUIjzdifl0f58ENe+uYr011Ag8YU72VhDA?= =?us-ascii?Q?34joaHo+X84gt9Be+thgCjyWujiylKhnIKrQ8jVJ9jyHM1V4YtTDDDcSudZq?= =?us-ascii?Q?b9J9ZHrKp1Vt3+o7Q9Sbkd6CQvciPEngpEdAUjtUBUwKsSs3CowOy9EeV6u0?= =?us-ascii?Q?8XvjhVQmELBlmUjJaWEKnX99TDUw4NCMvN7TaQ99+10LtCoATds710Mcgh/J?= =?us-ascii?Q?+jJWusVPFZhbDohZ7QdR0bzHo6OyWOkqM5ZcMi90lUHWW46mFPJHKXBnyo7L?= =?us-ascii?Q?Ctc1bNMFa7i39UAcKsmJ6UXAkk1DGD+VIwhnB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lwRiCe2MjtcZX91Jk5p5RMFyNZPiiO3SnnOwC9b3qqeE7fvdcjJgyI3w9aScHE7PK/+AgtszEMwuUX4AdprIa/kcol1gBIodfse4EVDGdYkTbkWcw==; 24:TJQAnP4HRD7DVVk0DPPFQHzpyfAQRBv1W9ARCkKpUaPhRLTFYlXgMp0YjCa2X8cZptc8KpbpWkQqZj5/vKxUo33vWxots3A84lIlNLav1M8=; 7:m/ocZnn7Cf6jmdnjGv6FHaeqZZReMRArdvS/ZoW4AroRR9r1qDAZVpvrtZXt5ie97xOd9Bv57h9AhnHDSo7o9qVqM7PI1c0Glqop7nzF64GKr3uBBkNzyNyAcabndxr/hLWe/3TGzDg6NGFoExm97cZhVyNVnsYbAWy3v6ce5o5pqX8kSgBryc8B9nOpWbyy9fF2U0jeMhFGB8yNqLkZgYLDTJf+Q5oiEszzTkrjbbE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2016 09:42:07.8660 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0301MB0707 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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_enable 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: Michael Turquette Cc: Stephen Boyd Cc: Shawn Guo 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 9f77cc6..0f9f756 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -591,6 +591,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 @@ -607,9 +614,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); @@ -645,6 +650,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 @@ -659,16 +675,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); @@ -698,6 +708,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 @@ -712,14 +731,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); @@ -758,6 +773,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 @@ -773,19 +800,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)