From patchwork Wed Mar 21 03:19:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10298465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 782EA602B3 for ; Wed, 21 Mar 2018 03:22:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6365B297FB for ; Wed, 21 Mar 2018 03:22:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E2C12981F; Wed, 21 Mar 2018 03:22:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD9E829A05 for ; Wed, 21 Mar 2018 03:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752007AbeCUDU5 (ORCPT ); Tue, 20 Mar 2018 23:20:57 -0400 Received: from mail-db5eur01on0082.outbound.protection.outlook.com ([104.47.2.82]:13505 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752015AbeCUDUt (ORCPT ); Tue, 20 Mar 2018 23:20:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=qc8kWekIc96u0Ez+N1izLWSCIzNjNLlfiMfLqBJtNpE=; b=Q3ju9Iit5jkP1OhQl1Y52Huua6NPgjLKADJqhDa4Y6yQzrSp6rqobU0sdrHHMWY81DRy9BYuuuV2I9OrdvHxcbhkfxCEZ9XU6S9ZcNXNS2mrPy648clJa+d+0424GXFT0fQDk+WtnGFKW/53EGiCURnbCodyOzMC4NQ7oeiDpEY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; Received: from b29396-OptiPlex-7040.ap.freescale.net (119.31.174.66) by DBXPR04MB320.eurprd04.prod.outlook.com (2a01:111:e400:9425::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.588.14; Wed, 21 Mar 2018 03:20:41 +0000 From: Dong Aisheng To: linux-clk@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mturquette@baylibre.com, hdegoede@redhat.com, b.zolnierkie@samsung.com, linux@armlinux.org.uk, linux-fbdev@vger.kernel.org, linux-imx@nxp.com, sboyd@kernel.org, Dong Aisheng , Masahiro Yamada , Stephen Boyd Subject: [PATCH V2 4/4] video: simplefb: switch to use clk_bulk API to simplify clock operations Date: Wed, 21 Mar 2018 11:19:51 +0800 Message-Id: <1521602391-30356-5-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521602391-30356-1-git-send-email-aisheng.dong@nxp.com> References: <1521602391-30356-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: KL1PR0302CA0002.apcprd03.prod.outlook.com (2603:1096:802::12) To DBXPR04MB320.eurprd04.prod.outlook.com (2a01:111:e400:9425::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5d6062fe-b9a9-4d12-dc73-08d58edabc6c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DBXPR04MB320; X-Microsoft-Exchange-Diagnostics: 1; DBXPR04MB320; 3:XZE2qEFCQFPuLZKjRWSeRZRM+qFQFHwj+8KRYr11z+83m2fSun6pVLmmcKW31bbOxt6nyOU9cdwHZiWqYyDs8WsvTygcVgl5X1sbX0b5Wg0IQBURwr6P0ivAHv5A1RSER3lhFyQkvvwFQiclRmM0l/ET6vk9zD6Sez6edXizBX2pI2hMfdnuvYOzQQUjWM1u7IPdmEDB2tW//d8M3Ql4GPETcGgn1+PrHJ3SxslUjWJCrNiL96YK8jMrWkbQPVtD; 25:4mRZP7BPjfy4X87hxhRYuURoQjt6gtKpjpupU7iiaj4Z8DjKZ0wn6CNcGvQACcnR12+fD2II8rSeTFTq1LCXPw+mPjXeww6QJLDDYRty8RxW+fgSFvL5wZJDH9S3n3UXViv2k5B3+5kHPhE7UE3G2S9oXiHOfsJuZd64xkFHd+rW6hNmS9q1bk/f1HkHDJvbHa4z6NsbLerILNTmqxpQBKwoqkW3BB9R4oJp4D+sc7dQQOmxn5j7T5SfIhQnzy007rtKurFfe44T8uxJDSV3UXXMj0s6w+qsGe0pLEqanH1V+v2Wzzw8Nt4OvAYSut8N5hmhLsW0R26NaUpZD4eYjw==; 31:v/5efrhrvSsIHck9+gBIUPWShu21cb3hag6CbWSYVzR9jpTzTBaRoVhhA1duk5H3AC1YVltvombjF3ASLJkhHhjIzxpsQo8f4APaKsjRF/JrL67dDsTwl58xxEvWFypAF5Kr+PTDHxBxexrHPGXODPYM3cUlpQN/6LjJMXzf8JbhIx4ZBEAcCfzcmV1pBEHlR+WzxKH4AgO571Y4J5/23vQYPMNnFnkd0nLfHhHWZcA= X-MS-TrafficTypeDiagnostic: DBXPR04MB320: X-Microsoft-Exchange-Diagnostics: 1; DBXPR04MB320; 20:f6DhjFP1938Gs1mYb/ePZ3r/H0Vmdu4i77eEEVFLb6r7DZgTxNLi8e27uAAYxnwgKKYJ59QJEsMNfnm/7YlCYbKt5d43gQGlVzZqTSZcZq0zsEAzXA3QPSpDe6638a0v37ZgLQgg5Z2mVbN2TR31Npty7tQDQ2ohn5MwXXgRPsxETvFfMbBNPaX+ITpfyBCxISx9GsuYNnrkSdQK0fXgpY9fthCHClojjZX2QtmBddyWdZEHbmcfZrALMoo+R3dYBHMYmXKxBm/vbm4sxCSOBufWNEeq7WUwDNkKZmquoTFWWxgeZi4s+NBCgu7j2RrTkel5Ez2Z+gu5UueLh/ROzUadSts+Kd+SgHhYlHQZ8OMW7o5WOBTPyYMNtWSORc7PgOK9j2saBq3PYYZxJIxI2NFc6vo6Lsuf+pionvo9MnE5fL8wqjn3KQvdHMD4aNA0s8k3ez4h4RdWIBqe4kciXu3Rdq1LZmkIRQY7YCpwiGzweps/rAybrsbdQ2naeOml; 4:vvU12EwbOsmmtmCgTtwkbHT73Ags7b7u3j8REukJeHX/2toRgQdlZDY/TjGi7EehbGIqK8XTMqIon9nmaWE6v4/NZcqvKdYY6UFMfMV7CuPQ+Y8Qx0KeJ4M1pj2v98D9tt5kfeXdocha4ng22oB+wQuN52jpIhkt4qU4qSUrvl7/GxQHCKtAITObV5eiH69zcuIuuQLpUcmLnRRH2aDV0fLsVFhkjDpdGVTMlxZjbXyQfvgxkR1uvU6i3fYyAau3EFUPYexsErscDj70HHw4DQyrUXqftkVpnyPIsgLDkB3qoLGNIpFghWzQrH9XfN28o6WfrcpvpBVg4/ekDA61k5J9s/OTcrIspQu1qk6RziyomhVYgO3Sm/U1egrkK3bi X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(185117386973197)(7411616537696); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231221)(944501318)(52105095)(6055026)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:DBXPR04MB320; BCL:0; PCL:0; RULEID:; SRVR:DBXPR04MB320; X-Forefront-PRVS: 0618E4E7E1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39380400002)(396003)(346002)(376002)(39860400002)(199004)(189003)(6512007)(47776003)(53936002)(186003)(66066001)(50226002)(54906003)(105586002)(16526019)(478600001)(68736007)(25786009)(106356001)(4326008)(6666003)(2361001)(6916009)(16586007)(2906002)(97736004)(2351001)(316002)(6486002)(36756003)(8676002)(305945005)(2950100002)(386003)(6506007)(3846002)(7736002)(6116002)(5660300001)(7416002)(81156014)(50466002)(48376002)(81166006)(26005)(8936002)(51416003)(52116002)(76176011)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DBXPR04MB320; H:b29396-OptiPlex-7040.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DBXPR04MB320; 23:XPIRyyvmUmK1thtjts2UqXGI1E6XIGR4sfsZ8mMjQV?= =?us-ascii?Q?gtLNwDImo+BQ9yykEe5jZtieZN9ccAMHqzyjE83v0gNJ6PMRu7FnewJjI0Tq?= =?us-ascii?Q?VLxK57gjbv1fTvrFvAphWKVFbVUFfEkfTf4ipQhxd918qy29DYpunkR7INjJ?= =?us-ascii?Q?OHLoDgoyg4Bm8AJS1gt8fE/sc7EEqyEcY/8uDx8Z541qAYc46iUlYt86S6wP?= =?us-ascii?Q?5ffvva5q5mfFkUD0mhAhjNcp0PejTUop00EwWiOq8XbRyKm841LKo1IIcsT0?= =?us-ascii?Q?Ug4u0cCeZ9EVtRKb5VR46FRY5dcPU0o5HTGbgiwEv5hmkUpanQr36c0dfDW5?= =?us-ascii?Q?eDc3OZiTMKRfWVDykUDD+DZknX3GxIjZWn17lE13SHdgmclKfN3mZ/6Jmds5?= =?us-asc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iagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2018 03:20:41.8371 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5d6062fe-b9a9-4d12-dc73-08d58edabc6c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR04MB320 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switching to use clk_bulk API to simplify clock operations. Cc: Hans de Goede Cc: Bartlomiej Zolnierkiewicz Cc: linux-fbdev@vger.kernel.org Cc: Masahiro Yamada Cc: Stephen Boyd Signed-off-by: Dong Aisheng --- v1->v2: * switch to clk_bulk_get_all from of_clk_bulk_get_all --- drivers/video/fbdev/simplefb.c | 69 ++++++++---------------------------------- 1 file changed, 13 insertions(+), 56 deletions(-) diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c index a3c44ec..3c8124e 100644 --- a/drivers/video/fbdev/simplefb.c +++ b/drivers/video/fbdev/simplefb.c @@ -182,7 +182,7 @@ struct simplefb_par { #if defined CONFIG_OF && defined CONFIG_COMMON_CLK bool clks_enabled; unsigned int clk_count; - struct clk **clks; + struct clk_bulk_data *clks; #endif #if defined CONFIG_OF && defined CONFIG_REGULATOR bool regulators_enabled; @@ -214,37 +214,13 @@ static int simplefb_clocks_get(struct simplefb_par *par, struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct clk *clock; - int i; if (dev_get_platdata(&pdev->dev) || !np) return 0; - par->clk_count = of_clk_get_parent_count(np); - if (!par->clk_count) - return 0; - - par->clks = kcalloc(par->clk_count, sizeof(struct clk *), GFP_KERNEL); - if (!par->clks) - return -ENOMEM; - - for (i = 0; i < par->clk_count; i++) { - clock = of_clk_get(np, i); - if (IS_ERR(clock)) { - if (PTR_ERR(clock) == -EPROBE_DEFER) { - while (--i >= 0) { - if (par->clks[i]) - clk_put(par->clks[i]); - } - kfree(par->clks); - return -EPROBE_DEFER; - } - dev_err(&pdev->dev, "%s: clock %d not found: %ld\n", - __func__, i, PTR_ERR(clock)); - continue; - } - par->clks[i] = clock; - } + par->clk_count = clk_bulk_get_all(&pdev->dev, &par->clks); + if ((par->clk_count < 0) && (par->clk_count == -EPROBE_DEFER)) + return -EPROBE_DEFER; return 0; } @@ -252,45 +228,26 @@ static int simplefb_clocks_get(struct simplefb_par *par, static void simplefb_clocks_enable(struct simplefb_par *par, struct platform_device *pdev) { - int i, ret; + int ret; + + ret = clk_bulk_prepare_enable(par->clk_count, par->clks); + if (ret) + dev_warn(&pdev->dev, "failed to enable clocks\n"); - for (i = 0; i < par->clk_count; i++) { - if (par->clks[i]) { - ret = clk_prepare_enable(par->clks[i]); - if (ret) { - dev_err(&pdev->dev, - "%s: failed to enable clock %d: %d\n", - __func__, i, ret); - clk_put(par->clks[i]); - par->clks[i] = NULL; - } - } - } par->clks_enabled = true; } static void simplefb_clocks_destroy(struct simplefb_par *par) { - int i; - - if (!par->clks) - return; + if (par->clks_enabled) + clk_bulk_disable_unprepare(par->clk_count, par->clks); - for (i = 0; i < par->clk_count; i++) { - if (par->clks[i]) { - if (par->clks_enabled) - clk_disable_unprepare(par->clks[i]); - clk_put(par->clks[i]); - } - } - - kfree(par->clks); + clk_bulk_put_all(par->clk_count, par->clks); } #else static int simplefb_clocks_get(struct simplefb_par *par, struct platform_device *pdev) { return 0; } -static void simplefb_clocks_enable(struct simplefb_par *par, - struct platform_device *pdev) { } +static int simplefb_clocks_enable(struct simplefb_par *par) { } static void simplefb_clocks_destroy(struct simplefb_par *par) { } #endif