Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753303AbdDKMG4 (ORCPT ); Tue, 11 Apr 2017 08:06:56 -0400 Received: from mail-by2nam03on0048.outbound.protection.outlook.com ([104.47.42.48]:56768 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751514AbdDKMGw (ORCPT ); Tue, 11 Apr 2017 08:06:52 -0400 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=fail action=none header.from=nxp.com; From: Dong Aisheng To: CC: , , , , , , , , , , , , , , , Subject: [RFC PATCH 0/3] clk: introduce clk_bulk_get accessories Date: Wed, 12 Apr 2017 12:03:26 +0800 Message-ID: <1491969809-20154-1-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131363860101140058;(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)(336005)(39450400003)(39840400002)(39860400002)(39380400002)(39410400002)(39850400002)(39400400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(9170700003)(38730400002)(7416002)(5660300001)(86362001)(6666003)(104016004)(47776003)(6916009)(97736004)(8936002)(356003)(8676002)(50226002)(85426001)(305945005)(2906002)(189998001)(81166006)(110136004)(33646002)(77096006)(8656002)(54906002)(5003940100001)(36756003)(105606002)(50466002)(53936002)(48376002)(2351001)(106466001)(50986999)(4326008)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0301MB1285;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;A:1;MX:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD021;1:LzlQkqNFlS7/de92ZqcC/+odXdGJuL+ncFB3jJlHHtPODLcuvfQYtn0nX3LyVFkiUio5bBc6+oHVSf4dcVoh4c+dTnERRuxmM6Ws8kqgY8ISqtauOHGTXdirPloruZ1PhLgDihTWBMEJmGCe4t6qndUqk6Md6mCoQNKjX2A7thjwHOnXzUBMFlsEpiSILWD4uqhfjsNoZ6UeiJ2/j42LCJUcs6Pv0LCSartKDCwJEolg/HTKKyW6LgNm3DWFldt4JXniPb2QzMb842I+VvNk5sxMzQZC4TDojq/Dyzvg6vKbgTqwmiGGD3ZtR9TPkuDD4Yc0yq1KfyNd2noQG9W74xCY4/6j0Art4kpqBdByM21qaEgk8aQAwMstBwtG+dAUpa027RguPGoLX1ONFlC4GwzcPaL0K4K0b2ojfZ1ujoh9aoU3kz+HGGJNg/cz10HdRi7CBc1TkWm9TEQPetrtdJWEAO2mShaUgaYOMYZVdfFW7txNhEs9S5+IJDl3DFlXcXR0akwgYv/vjf0wSfIP/9mx6D8W8CcJdT2r6A8zIJNjExREOKH5Lz4Qzv6ZmxYZfD9020BWdW6CzI9JXuzyoNFnU+Fp6s34E+OIqXXDA2179AJthyqWnwDSRrpp6FOShwzGOTHIl938DT89LMouVb5k1dp/4LxB/7iiQPkUXuvrt1qXYI57nWJvKqItQ6e+NbRNPSzEUsE8axgqeK2DBmM42u1BpZlugvKHk/cKnO8= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 18c36ff3-7aeb-4ea2-acf9-08d480d33c1b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030255120)(201703131430075)(201703131517081);SRVR:BY1PR0301MB1285; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1285;3:UGQCrmMfW/0BXT/9u8LkVNxRQEol+2ZSjuzAhSLRe8hCz3thUv3Gh4a+e82tlSvgErKjYW9gEMJNC57bAGmIxQ1/zyJZUb37YMcE5oQERdkelE8lR3Ru028xjWyRR35Vbw9qoovwVwDIkMyld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5got1Rag1JPbYUbk9RuBkSnDqG6fqGPM4J7U8iHgI3jwq9jTS/4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(601004)(2401047)(13017025)(13023025)(13018025)(13024025)(13015025)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(6055026)(6096035)(201703131430075)(201703131448075)(201703131433075)(201703161259075)(20161123556025)(20161123565025)(20161123561025)(20161123563025);SRVR:BY1PR0301MB1285;BCL:0;PCL:0;RULEID:(400006);SRVR:BY1PR0301MB1285; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1285;4:AlXzM/kqUKNBkkEqCdfhGhWljh8wUACcdq3AhGCj39wkQ6rXSyykLYpX7BdX/gVXpaBuP0tOw0rngG0uxzb55p09T8zYas99aDqX5ZXiA0EXgCAonm+lA3aPjTYX9ABCqaNn+hsONYXTt1tXEaWDcE4Kxl/QM1S8DlzpYZzuGW+VYfPQVm3/otJ/KB1a2+7d2j/zrWViO4bTffS0bs0VFdoMg+mURUP3Xa3CG6/3/9pNovsgkoiZK3hK5o/oe5itVsTNDbR7iZQL+DQ4BhLjOp9lCb0OP2pkO3+Ua92SuiIWOoGveFZlGKW2QlObpuYsgHc7rxOvOykSMArdCNVUv59D+f3HXkXHMHv9qOqtlJtB9lNr8+DwWSg1vfU55lG1f0R/qNxF99Ux1ci5HJqnwZfhdq6jgp/bMy51LdTTA3niGEt2+EaIxaYo/+Ar8UDbydg6ZdK8BBESDe4jJeklB0uwqb279GcbRpX2jrD118JlagQEWB8Tb6FM2i8FGOab/e60dwt20kdqrEGIerVf8h5b1vzKtCCDDjKImx20rH3/1AG9UODuKeiK+8SUHY/uAUrjEkhpU39bxTevNnVhHaq+NMhX89NdNwOv800LbwdOIko+94v+hANCpPIfhcgY8u01+QeJVAmD1QTlpLxVgh22s5LXZNclaVyTLAJAEgAKZQSLDbjwAYAy4MUwFSsnrpF3l2sJ9jBniNSpbNlG4xkL7DnsR0/QYsZgpklBPcv+T8y7va1+pMTTB8jaYQejypCp85MbqXKzDng+JD1vCocxRli0VYBZLx7cgUNTllClQPIZcB39j/ZMaZ78chAkrd2wijudScW5NCA6SVoIEA== X-Forefront-PRVS: 0274272F87 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0301MB1285;23:resfCNfoia16525/2n/Ucq2KAaL61izWmIyX0O0?= =?us-ascii?Q?92kv8QRKc1lF3cLnTA2DaDfbt4pjHB/Ad9THpHYCD42q6qazo2YjMvV/r5jT?= =?us-ascii?Q?1SV8YBVD+WAlYiFqeoN6mh+8n5Hz2xlQxfjL+Dm+/yOL2mt0GJpfHf09W6MP?= =?us-ascii?Q?W2WPHarmC27UxE6DuhzWx4Q3DZEpC+enUMKFhnZgr0weuKaIDan2xF5V4ic9?= =?us-ascii?Q?HKR8w68OX8ZQORKRL67KJ6gInFH37Q2TFKEGDEZTlNrZZvqN0JzsrcciZBho?= =?us-ascii?Q?RobA+zSfSR/lmgx4jiPbDrA0i34JBCVxT2437kKFj2hcFggIhnN4vr3K5a/6?= =?us-ascii?Q?1fYXHwEGH3QjkPhgltRxMwr84dY6r3VnbDgKav92LroCmLKbwlGtuwEEGLy6?= =?us-ascii?Q?WtBHHUTIhco2H9IMix7r627Q4Ny08qL5SuOjeyH5uGmXSgPmmB/tm+cS+kw0?= =?us-ascii?Q?kJziQYuWr/5z+/4X69DIDCHDIO5FFqmwdgKylnF6O4iWJfxd2PA+XzeA1elu?= =?us-ascii?Q?SSzRgkZRI96EgJh3ZjuCc9u2DSOG2aVTVcqGQDbCS6dKHkp23fmMAOQ74Tud?= =?us-ascii?Q?D6rcpmKJOsCWABsCKTJs0pNF2HwP840ctnI+stSTBHRu1usiqP4TPxuMUwWU?= =?us-ascii?Q?Wcx4f586UEbSiJst1nheD3PYK/IDbaqdAgkIljRTEyQ6n62HND8oX97Dlr6u?= =?us-ascii?Q?AdT06ymrO8fgPwssyp0H7tBQHsUg9xUPfMb2ZjiNJS0QrkDbEdU0Y2I4agwK?= =?us-ascii?Q?xHeDvJzoorqs3YRDPZuFJpAq8ljg8yiTaPCKhNpdbsYt2IXUlCRV2WSoxTvi?= =?us-ascii?Q?cCARvxhm251l8V1Znkr8TiJ4uGNCRl3I4BYyQFIswsTD/aZifzptEROTJvRb?= =?us-ascii?Q?pWrfucWuXs/2YnUJyqBjcNuSuYs/MonbZVIJsKdGgLH6PmgA9WaRISv4gt/3?= =?us-ascii?Q?qpx+OXq3nMunzoKRhBaoKIh/NDQLaFcmTZNh5sRDO71DGryvrbEi858MMoG0?= =?us-ascii?Q?KMLYRDwllQwbi9biIWKyZYTqy/V4X5Bp9qZER85u44rKmZthJJhvPLc08sLD?= =?us-ascii?Q?fK+gn8//nzXFvhykTVjN+BhHKQn+Fzo/QohaEHFzW3m7Tb0fG1FHI6zfFaDt?= =?us-ascii?Q?L32GTp1ncAQuRclWCOF71U3GSlX+Vyv8aJ9SfYoTT6hHZyxkr/MwCNnsS4cq?= =?us-ascii?Q?5OKTcpNzT+g7SR11BS9REZF81pfXO5fovqijB4KRj1NPl6a5zkgZbk0fcTg?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1285;6:zBsw+t45JlqBe1e92LVJYHetFGJe8us1I1cif0WhOat4y1APz9W4iBWpNIf3UeAdiVjCEcPl+PTenoy9ZVoPsf6ameJ93D8rUlZStLJ64o20/FoBYLcqdesIyY2xDqi5L+H88rB8V8syzP1F2wue6Flnzcf1reDY+EU/sJXxC19iElRxqBvNiwo+SZunyReVfgfdduUn56XAfulFLMN5fYhDY/m3may92OSDNqX9s6K+9QRWD6fPrAPuruGdlyUMhLl7SelpxpRcgKpucW4V8B7XpTytwPhs09uLEsBk8d3Eiz6U2Gn6eLH8rHEewsur4ZIn+rAGCVTm+gmL4Z72x8AtovkYOYri5Cw4y9T+8VUg3l8vjtaynigZtuslBQqkWVCjrkZbrE2s1FkBS27fm+YV7Kz38TppTe+1KUmf1X0amnxriGzuLksanu51rxUPuGBWtwTmBUtRzCxlW/W54g==;5:RqmtXKlo48rxL7u6RDihH2oRpE9MdR/VgTnS92sbjzIN2DWCKT6RgVGPWz9YSfQHz/Ws29KuXDOAIojQUOg+uXbmF9HT37LsIImTdZsZw+7GNcOHDPIwpIiByR8G2kdPUaqrsKcWXz4njIEdwdGMSmDJSuHq0HwgtRbwFv8VroGthnnWeU7B2bTUVwfMV9Ke;24:W0j5Gzzui3KtJN42rVBpQ+2hppxDLVKTsnUmbXfMPJb2HYjrCNBFhuSOFMNc7jUoqdlhA2Nr0wsZNxbOp4ObV5jzRZu6PRoVuIqz/RPLrjo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1285;7:srrHH0RDo5xShnKRxZ9Yz3Fm2dQ1uE72mvQiRKLJzaw43vBAsCi1+XY1zXwH3+fZLIjFnCHVGTaw3LlAhH7bvrHAvj8u/TDrOTryd/ecvAitr5myT/iIM3DK+AGhzFHUVGN2xv0DHoRy3ze5McXmixQX3E9G2g2zWM9Mq4GTycnbpYez38WdWfPMrBmlGE1THcWo5pfZnJ52pJq1EvHc5ANwsMMnkn1TXfEfCOmm0QNOx7UKneHI49SrO2jj5KLJswHqEmwAQgMmsbXq49SFVy2d+u/DldM8jPXqS55hBvVQkJoce/5zgXA3U1aKEYb0VvZrxcL0pwamAt2phM3hbg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2017 12:06:49.9268 (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: BY1PR0301MB1285 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2840 Lines: 85 These helper function allows drivers to get several clk consumers in one operation. If any of the clk cannot be acquired then any clks that were got will be put before returning to the caller. The idea firstly came out when i wanted to clean up and optimize imx6q-cpufreq driver which needs to handle a lot of clocks as it becomes a bit mess. e.g. drivers/cpufreq/imx6q-cpufreq.c You will see we need get 7 clocks during driver probe. (Add there will be more, e.g. pll1, pll1_bypass, pll1_bypass_src, in the future when adding busfreq support). static int imx6q_cpufreq_probe(struct platform_device *pdev) { .... arm_clk = clk_get(cpu_dev, "arm"); pll1_sys_clk = clk_get(cpu_dev, "pll1_sys"); pll1_sw_clk = clk_get(cpu_dev, "pll1_sw"); step_clk = clk_get(cpu_dev, "step"); pll2_pfd2_396m_clk = clk_get(cpu_dev, "pll2_pfd2_396m"); if (IS_ERR(arm_clk) || IS_ERR(pll1_sys_clk) || IS_ERR(pll1_sw_clk) || IS_ERR(step_clk) || IS_ERR(pll2_pfd2_396m_clk)) { dev_err(cpu_dev, "failed to get clocks\n"); ret = -ENOENT; goto put_clk; } if (of_machine_is_compatible("fsl,imx6ul")) { pll2_bus_clk = clk_get(cpu_dev, "pll2_bus"); secondary_sel_clk = clk_get(cpu_dev, "secondary_sel"); if (IS_ERR(pll2_bus_clk) || IS_ERR(secondary_sel_clk)) { dev_err(cpu_dev, "failed to get clocks specific to imx6ul\n"); ret = -ENOENT; goto put_clk; } } .... put_clk: if (!IS_ERR(arm_clk)) clk_put(arm_clk); if (!IS_ERR(pll1_sys_clk)) clk_put(pll1_sys_clk); ........... } Together with the err path handling for each clocks, it does make things a bit ugly. Since we already have regulator_bulk_get accessories, i thought we probably could introduce clk_bulk_get as well to handle such case to ease the driver owners' life. Besides IMX cpufreq driver, there is also some similar cases in kernel which could befinit from this api as well. e.g. drivers/cpufreq/tegra124-cpufreq.c drivers/cpufreq/s3c2412-cpufreq.c sound/soc/samsung/smdk_spdif.c arch/arm/mach-omap1/serial.c ... And actually, if we handle clocks more than 3, then it might be worthy to try, which there is quite many manay in kernel and that probably could save a lot codes. This is a RFC patch intending to bring up the idea to discuss. Comments are welcome and appreciated! Dong Aisheng (3): clk: add clk_bulk_get accessories clk: add managed version of clk_bulk_get cpufreq: imx6q: refine clk operations drivers/clk/clk-devres.c | 36 +++++++++++ drivers/clk/clk.c | 99 +++++++++++++++++++++++++++++ drivers/clk/clkdev.c | 42 +++++++++++++ drivers/cpufreq/imx6q-cpufreq.c | 119 ++++++++++++++++------------------- include/linux/clk.h | 135 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 365 insertions(+), 66 deletions(-) -- 2.7.4