From patchwork Wed Aug 29 14:41:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10580429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 988A71805 for ; Wed, 29 Aug 2018 14:45:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8749929C77 for ; Wed, 29 Aug 2018 14:45:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B40A2B3F4; Wed, 29 Aug 2018 14:45:20 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 52C4C2A750 for ; Wed, 29 Aug 2018 14:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727547AbeH2Smf (ORCPT ); Wed, 29 Aug 2018 14:42:35 -0400 Received: from mail-eopbgr40070.outbound.protection.outlook.com ([40.107.4.70]:38085 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727204AbeH2Sme (ORCPT ); Wed, 29 Aug 2018 14:42:34 -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:X-MS-Exchange-SenderADCheck; bh=Q8iTMETEn7KSoArPSgEEclCn4FhbGLFQMHj5o60S6bA=; b=mKPoyFnYxQq9xufLcvy5YlVSkw1a1/3jRkF8CnM4ASfJzGbGJqDgf4YrmtYdaPxo8MFh6DwFyJu4KBYiwKh8vxzErhhaH6PjfdTpibpeWsSqXQhJFUWt0qTQ3OYl5W2LucnTRniazodq9J1I/4CMVQ1jjctspvSHZ5XWfSFTJz0= 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 DB7PR04MB4219.eurprd04.prod.outlook.com (2603:10a6:5:27::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Wed, 29 Aug 2018 14:45:05 +0000 From: Dong Aisheng To: linux-arm-kernel@lists.infradead.org Cc: dongas86@gmail.com, kernel@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, linux-imx@nxp.com, Dong Aisheng , Hans de Goede , Bartlomiej Zolnierkiewicz , linux-fbdev@vger.kernel.org, Masahiro Yamada , Stephen Boyd Subject: [PATCH V5 4/4] video: simplefb: switch to use clk_bulk API to simplify clock operations Date: Wed, 29 Aug 2018 22:41:09 +0800 Message-Id: <1535553669-30250-5-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535553669-30250-1-git-send-email-aisheng.dong@nxp.com> References: <1535553669-30250-1-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR04CA0010.apcprd04.prod.outlook.com (2603:1096:203:36::22) To DB7PR04MB4219.eurprd04.prod.outlook.com (2603:10a6:5:27::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d5659f4-5eb6-4bed-c559-08d60dbe0516 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:DB7PR04MB4219; X-Microsoft-Exchange-Diagnostics: 1;DB7PR04MB4219;3:knevGdvWdaQcs/4ZvrbESRNrE+zBiW6ltl4+74TTqkcqgQEbZyOxy3V5Sd6McPX3Pj5dBvyp+KPl1KrYEziXfdxWpCk0P0pBEYNWnTeTzFbc6+OzoABBXheD5tY1RjK8anGFQaJejX/RrWQxziKE4AlgIN+fPSH6SY0cjvhgXYATEURYGWURFdcLwIiDaXlyDCZ6GuG0bZJbwXouUVJLtUPLTrI8xdBi6ZkeiPDSb1rIgfikZ60anyQ7m5tfd7SO;25:SKJseWNS4xHS24BvJjo70eVxiOcelDcrNo29PNx0x3ALXRKw4kzF982TqT7BnWnuKKTX3C9gbMI7HugBEStMizCu8vTxvrcOy2qXgFsh7r3L3cAAUAIUcRORchoXK3yJ+sOLgw5FSNJaRbzCWLBoxQkcjS2TjMD7WxzPgzDKF+IV3UPuBNaH9AV7xeSmXSH2nFQOuq8pcym5brt6L63ByOi7hFdzpCdcTH45kqJd2TyBFHQ4bFcd+zo0pVHrvF+v7vsfipO0giQPXzUznSmj6s4jxN2c1U+o47P7sOmYoH/7hp+pW6GzUCTKyRa3UwGoc28Rvsp6xvxVW8J/++tmLQ==;31:iMY5HMXpBeFEKqcoqifAo83mWWmDv45czr0QSVHIhvPUNk6Um8Rrng3+YYlrmJMQS//ydINzBXLA+IQTnAizYDYfNcenxmik+kdGITejv4HfYwJaikPnuwfQKSJN0SA6mDk5IWkB1DEFAIWXukudIEoVuiaOP1hhVsN87YAeOvWDpDIihXQhmiVa80G5YAfUSu20iL63tlJ1JW7i52z0UQ4a6lheFX8e98RLBm3N+Cs= X-MS-TrafficTypeDiagnostic: DB7PR04MB4219: X-Microsoft-Exchange-Diagnostics: 1;DB7PR04MB4219;20:7amXQlBJByuc0P/JvQCHZfbgBy6XRk5albGU/+b8Smf5JYzi86wFSzpKowU8YzdbHsb5AlYIGfjTvGKrRqEm/FojU5a+YALHtoxKaxc/LwYNrf0W7yJ86j6sCoLrx+8y30IV2zg9/Go9UKINYnZ2Ord6s8t+DvmJAZ0u3cjYlFVlLXzRLUpMv30PgcKTWulS0qM0dGakvPgQxQ/srhvctzuILqVYEEZVbsay1fkG/KEXi679IMwz1SRw7ct7LvIviGaId7gy0WLTKuX3Y1gYBkcS/gjdP8CliBarGBO8oUY3Ck2G2Hx7FAetkkFLPq2Uv0TOLtfKN9itJt6I1l+pv1h/KVSxi8IWoPfauljUlj2xWoVwEqVeLvxgYnsCRSw+uD3GLSF7suI6yVvbrDiS/gKvv5/nOemB3jeogDOWV4gqGDWVri0xr+lFfaBtJJ3xrv0jJ//Pxb+64KcKCKmsaM7RodEbma18PCGc++53qOOJoUV/iYiu3s4+Td8c+W5h;4:DpRJejb9E+jWuOsbGGgHh2Pw0VN+eQyAExToaLDpv7pY+HfogK0NsvLulN2h18uA0XJgQ3bHQ+MnmJ91P9vKq3XSdk+A+HHdaL/PaUKX59RiNko8oCbrQMdxx6UuRJwkkku0G8XifUXUIvjPK+NJVggHZbqGrd6lwrvADZAb15Mw3N/qZZ/jfvMwpPhsDq4ERw3ay1jiNcoCwYTCeh04Pdw0Zs3Joi4ZuaaGsx86EQienEa1KPsN65nyD6/MsYva4S8p9KpXZKbUIsQc/YV8dLNQ203y1zErnAKN+QwxMXLy+kobM6MMApZvfwJWZpALQfIdfjJ3Pq+pblJPScSxht+OcvJuRDj+HhQy6pq8PaqVpXTr2Lw6QWdYVkvpC3RuTFBszendDy13CG6g2NX0ZnrAAJtPbqwxbOKzp1 TgSYs= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(185117386973197)(7411616537696)(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(93006095)(93001095)(10201501046)(3002001)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201708071742011)(7699016);SRVR:DB7PR04MB4219;BCL:0;PCL:0;RULEID:;SRVR:DB7PR04MB4219; X-Forefront-PRVS: 077929D941 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(376002)(346002)(39860400002)(136003)(366004)(396003)(189003)(199004)(478600001)(76176011)(51416003)(52116002)(6512007)(53936002)(8676002)(81166006)(50466002)(48376002)(81156014)(97736004)(16586007)(316002)(11346002)(8936002)(446003)(476003)(50226002)(6916009)(486006)(2906002)(2361001)(14444005)(86362001)(956004)(2616005)(54906003)(68736007)(6486002)(2351001)(39060400002)(66066001)(47776003)(5660300001)(3846002)(6116002)(25786009)(186003)(7736002)(16526019)(26005)(4326008)(36756003)(6506007)(386003)(105586002)(106356001)(305945005);DIR:OUT;SFP:1101;SCL:1;SRVR:DB7PR04MB4219;H:b29396-OptiPlex-7040.ap.freescale.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;DB7PR04MB4219;23:c+UPlCxDVbdFJ7PoDHSC4VmpKIrGUf3T5LDX5cBVZwjo5KchCRJbTkCji2igZAE0+HMH0casoHOOmdkjz4otmWAW2pdiat6YlFHuec11NAk1P+J+LJfNbuJee5OeITlFkLoxI5uft0AStlg9nwQp2w2C4pDieoilv1ilNtmGncqZMprFCxe+Nyee//QS1p6mrs9GfkqsQIhyv0eZYRC50sboW6ad0JpDbEvMEZ0aQuRA5JULljHGMv05W+UImpdyd2A9KlyRCIvEQLwbQlzjIPsvkE43AxZKGuI8kzhAkGPviZo9OyuaDhA26urkMMu/xH4yefUmVoWmnqapg1Q4okR1ZSk2QU3bNdQwV4Pu5JS6V2lLH4NJvihA7E8fq0xnuVWChse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EWpc6e5hmbnUDMrXG/5lZUI2TS2 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2018 14:45:05.8477 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d5659f4-5eb6-4bed-c559-08d60dbe0516 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4219 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 Tested-by: Thor Thayer Signed-off-by: Dong Aisheng --- v4->v5: * fix wrong setting of par->clks_enabled v3->v4: * no changes v2->v3: * fix a build warning on x86 platform due to a wrong of the prototype of simplefb_clocks_enable v1->v2: * switch to clk_bulk_get_all from of_clk_bulk_get_all --- drivers/video/fbdev/simplefb.c | 68 +++++++++--------------------------------- 1 file changed, 14 insertions(+), 54 deletions(-) diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c index 9a9d748..8d1fbd6 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,39 +228,23 @@ 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; - 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; - } - } + ret = clk_bulk_prepare_enable(par->clk_count, par->clks); + if (ret) { + par->clks_enabled = false; + dev_warn(&pdev->dev, "failed to enable clocks\n"); + } else { + par->clks_enabled = true; } - par->clks_enabled = true; } static void simplefb_clocks_destroy(struct simplefb_par *par) { - int i; - - if (!par->clks) - return; - - 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]); - } - } + if (par->clks_enabled) + clk_bulk_disable_unprepare(par->clk_count, par->clks); - kfree(par->clks); + clk_bulk_put_all(par->clk_count, par->clks); } #else static int simplefb_clocks_get(struct simplefb_par *par,