From patchwork Tue Jan 23 12:50:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10180841 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 9968A602B7 for ; Tue, 23 Jan 2018 17:25:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78B8A28210 for ; Tue, 23 Jan 2018 17:25:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B10D284F4; Tue, 23 Jan 2018 17:25:35 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 BDD0B28210 for ; Tue, 23 Jan 2018 17:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751864AbeAWRZG (ORCPT ); Tue, 23 Jan 2018 12:25:06 -0500 Received: from mail-co1nam03on0047.outbound.protection.outlook.com ([104.47.40.47]:35808 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751824AbeAWRZB (ORCPT ); Tue, 23 Jan 2018 12:25:01 -0500 Received: from MWHPR03CA0049.namprd03.prod.outlook.com (10.174.173.166) by BN3PR03MB1414.namprd03.prod.outlook.com (10.163.34.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Tue, 23 Jan 2018 17:24:58 +0000 Received: from BY2FFO11FD046.protection.gbl (2a01:111:f400:7c0c::153) by MWHPR03CA0049.outlook.office365.com (2603:10b6:301:3b::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.444.14 via Frontend Transport; Tue, 23 Jan 2018 17:24:57 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=fail 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 BY2FFO11FD046.mail.protection.outlook.com (10.1.15.170) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.428.12 via Frontend Transport; Tue, 23 Jan 2018 17:24:56 +0000 Received: from b29396-OptiPlex-7040.ap.freescale.net (b29396-OptiPlex-7040.ap.freescale.net [10.192.242.1]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w0NCoq1A021755; Tue, 23 Jan 2018 05:51:01 -0700 From: Dong Aisheng To: CC: , , , , , , , , , Dong Aisheng Subject: [RFC PATCH 2/2] video: simplefb: switch to use clk_bulk API to simplify clock operations Date: Tue, 23 Jan 2018 20:50:41 +0800 Message-ID: <1516711841-25234-3-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516711841-25234-1-git-send-email-aisheng.dong@nxp.com> References: <1516711841-25234-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131612018979385094; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(39380400002)(396003)(39860400002)(346002)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(105606002)(53936002)(51416003)(54906003)(47776003)(85426001)(336011)(8936002)(86362001)(8676002)(81156014)(50226002)(50466002)(48376002)(81166006)(77096007)(68736007)(498600001)(2906002)(6666003)(36756003)(2950100002)(5660300001)(2351001)(6916009)(106466001)(97736004)(305945005)(26005)(16586007)(76176011)(450100002)(316002)(4326008)(356003)(104016004)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB1414; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD046; 1:7sqUSRYXp5lZYuDoTrpZmmwsdu0zhEA7rvK7LvqQ6nt7knZoh58ay9XxlEDq4AAbY9NDdDcC6IeTcAJJEHm/ReZci7wdw2Z7EXsR/lFfYPNIVKc7QL28MJiGMdQPwYx0 MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7c621603-9113-431a-c29d-08d5628639d1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603307); SRVR:BN3PR03MB1414; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB1414; 3:ywT3oLzi0J4B9rhfSMln/dA+Qc7/HfUHV+OmOIcKRnhoySZbvGWwyfGHMkMUWMKHzjZYGZPGKf0cmuALtxQiEh4a9l6k7Qd0HY8DWkACOlJEv7BuGTtfBO7Y80IN5nJ+zC8JEWdxCAs707R5JSyibEco8hQZnp7j/NPRQ1PQ3muSwWmMEaw/DIKJk8Aa559mxzxZoJ8vrc3aRDWaWkMikIuhoBekOu/NTOQ3SOmZ3BSJ4Sh5D9k88K//KRuWvKMP3mF+vmB9ASdDwKvyCbUuXli1BIqvmyDIISI9PAEMfXNYz5QVH9LJqRRHQ2L5BtcwZ7cyB/eWD+lyMcOTuX/sS+60WvGJ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-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(185117386973197)(7411616537696); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(3231023)(2400081)(944501161)(6055026)(6096035)(20161123563025)(20161123561025)(20161123565025)(20161123556025)(201703131430075)(201703131448075)(201703131433075)(201703151042153)(20161123559100)(201708071742011); SRVR:BN3PR03MB1414; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:BN3PR03MB1414; X-Forefront-PRVS: 05610E64EE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR03MB1414; 23:YIRUo+KBXV5QGPb1iZVsaj53YakZjQpGGWGNVH65Z?= =?us-ascii?Q?ga89E8TdOvoa3TDMBukpfoTeSg7niIjNfciZjUkpvzO3Mti39GZ4kUSdjUUe?= =?us-ascii?Q?N9QzIsQPfVIM/j8BNsd2AvA+QvRQ8LG9M3jfcMw7DMkAOI+RTKx7SLuiSeqE?= =?us-ascii?Q?e4uXe1ieozMQ23mqfrHv+AAyVbnfSTc5+A2Mf3NmBF2BwLKJSW6pTtpeGPzs?= =?us-ascii?Q?XxMzhdDaZi1TIoLqAEe7WvX8lkmhT+PI1sEUHAGRrbaXPAZRNz9OtHBgU0oa?= =?us-ascii?Q?hVAaJvDiiZUvSZJiKmyTnG9If3Px4P9CbtT4WX5m3mCNmA7aQQxeZbUAt9F8?= =?us-ascii?Q?oFZqOcp1K7jFmNb69pdw+r6Oj0+AEFIh0hy+Ox5Rgd7Np3X0LkvhHZ+YBcH4?= =?us-ascii?Q?kzJoZwOjLD+8d5T67vO/fiRtCx9NJnZ5tyg81T4n2pSIx69+yR9toZQimjyi?= =?us-ascii?Q?3tQTXJnvAmySIVSbtJFChXpbpeIyaG/vDeeng/IWD5zF7vOWBlOF30GQyqcl?= =?us-ascii?Q?AtcruhVf1M58CAuApaKjCJwgSi/EBkma2fQQpJS7otjU+WA8B5vBaZPiasT1?= =?us-ascii?Q?qHSkUarnY9j8K74wi1rJRXnFfRpo1TxEGVr2yhga7fafheekyT0yxZWsXflv?= =?us-ascii?Q?JQPDQfHWSE6xciQM25uKCjO9aINvu+J/XKuVHWQQm5xgoF/4L8eGkpw8dImf?= =?us-ascii?Q?6D5TFgoR6PJRspAkvpUJMklgFevXzc8ppwYbcOYa/xwCRTXR4ytmPU6oBnqY?= =?us-ascii?Q?JJBGlZw39e+X280iqXLbYg+CJc89qcG7o/2brx/J52SeTK07zW4Xr4uyuTKw?= =?us-ascii?Q?KdzHyYUxg0zZD8EoJmiSvbP+dKjG1ZOUV39v5iNIHoNMjqd/oklDX2t2hm6W?= =?us-ascii?Q?W8BxCKgdGTgVW+PXeBYLSk7YUrHXhAl+gmR42l5K08WKgwW0Vzm+GGp7QkGU?= =?us-ascii?Q?DIyYzkTiigUPIrXescjoDtY2O9DF72CJqVeweZm9Bvp1o/XBjHjvOH/n7CKL?= =?us-ascii?Q?zDrXyPwZ1oRT+iePE3toQxDAl2i639uWAayH7RLhLN2CB/1VEvQ7EmwZaFyD?= =?us-ascii?Q?70OeuDueYfxw0JEIxCUuZYUjRyf5Ek7wZRCvs0o6fvkhLmBbVfQERV9y4ET4?= =?us-ascii?Q?QEjUNCpLzk=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB1414; 6:R3fCQSY7I60djBSgrrHR/JsX2LqIP2p0oavrF0MPeS63TOCVkmKzkrra2DiVmrjnqo33p/c8rFl2yucpcf73ofZ3cpLtJldkSRGaRZrkqFbjtVJUEU44S6KG/ngfFRO+yQ9iho7oTFXrevaoFTIOT7ipO4sdHbbmpo9OjVauF59CZjhTBQfK6iLJbJC8R4ClWFDOqFRHg05PctwCmh60ognzd2zIlw8iiGwkwicdjkMwXFTt/ZoMNXrGs99VvwComv73M6IowoV/yCLHufTSwsXzdbiJJ7or9iyuSKWJtRdwINUTQf5Xji+h8YvOU9K62PPwAU4EXpxiHxwW/caDxmeMkm4CF/spCkygPAyKHnQ=; 5:YT2lAtsO9EZXnJ71umeyyA5UufKRv3MwubK8GTVcF29UwrirRJmaxRyiGOqWxdl0a1I7fqwe5JNZrl5Ych0P6kOJi5f02USoNlUHdeMBB+aAfBaWd2+5NJFodkbOcGNtllxCzhhiUDx8Tq6RgLxVDsdRF+asZb1JG0aX3pTk+og=; 24:6XYsq8mrDRhjCV/I/L0SiDRSO0n3SY9VlBQUW58lorUyZSMbclApW1aYaDpAIFb6OoCk5taGHNQtJVHoXjYb3HI2UfA/P2q53XObBGOUohs=; 7:zgb4rleNFOzdJPxHtFXV4ObLQaybLfa7sNl9isgAZ+oJ5ICnT/PzlqGonhmiPpKNjWplRdlF/qIXjy/0uB748LIlkpn2PpIq+GhWCoYbGBOcPr83YgYSbF36HdQxhd4ia/uFJjxYg3sld/0zdYbJ7MPYAzGnL8F0WZVqTsBJShrng01bjsYHPbipLeWmxBAdUgDGYxHDZzLMVQ4iLWfXcDzKby+kvV9yqLKl7qu1dArKIY/14vGiuMybHKScn8Df SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2018 17:24:56.8933 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c621603-9113-431a-c29d-08d5628639d1 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: BN3PR03MB1414 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 --- drivers/video/fbdev/simplefb.c | 70 ++++++++---------------------------------- 1 file changed, 13 insertions(+), 57 deletions(-) diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c index a3c44ec..3ce2e5b 100644 --- a/drivers/video/fbdev/simplefb.c +++ b/drivers/video/fbdev/simplefb.c @@ -181,8 +181,7 @@ struct simplefb_par { u32 palette[PSEUDO_PALETTE_SIZE]; #if defined CONFIG_OF && defined CONFIG_COMMON_CLK bool clks_enabled; - unsigned int clk_count; - struct clk **clks; + struct clk_bulk *clk_bulk; #endif #if defined CONFIG_OF && defined CONFIG_REGULATOR bool regulators_enabled; @@ -214,37 +213,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_bulk = of_clk_bulk_get_all(np); + if (IS_ERR(par->clk_bulk) && PTR_ERR(par->clk_bulk) == -EPROBE_DEFER) + return -EPROBE_DEFER; return 0; } @@ -252,45 +227,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_enable_all(par->clk_bulk); + 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_all(par->clk_bulk); - 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); + of_clk_bulk_put_all(par->clk_bulk); } #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