From patchwork Thu Aug 31 11:43:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9931947 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 A139B6022E for ; Thu, 31 Aug 2017 11:44:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94914205A4 for ; Thu, 31 Aug 2017 11:44:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8926E27CAF; Thu, 31 Aug 2017 11:44:30 +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 ED7DE205A4 for ; Thu, 31 Aug 2017 11:44:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751450AbdHaLoT (ORCPT ); Thu, 31 Aug 2017 07:44:19 -0400 Received: from mail-co1nam03on0059.outbound.protection.outlook.com ([104.47.40.59]:13167 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751074AbdHaLoO (ORCPT ); Thu, 31 Aug 2017 07:44:14 -0400 Received: from BN6PR03CA0010.namprd03.prod.outlook.com (10.168.230.148) by BN3PR03MB2260.namprd03.prod.outlook.com (10.166.74.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Thu, 31 Aug 2017 11:44:13 +0000 Received: from BN1AFFO11FD017.protection.gbl (2a01:111:f400:7c10::142) by BN6PR03CA0010.outlook.office365.com (2603:10b6:404:23::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10 via Frontend Transport; Thu, 31 Aug 2017 11:44:12 +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=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 BN1AFFO11FD017.mail.protection.outlook.com (10.58.52.77) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1385.11 via Frontend Transport; Thu, 31 Aug 2017 11:44:03 +0000 Received: from b29396-OptiPlex-7040.ap.freescale.net (b29396-OptiPlex-7040.ap.freescale.net [10.192.242.182]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v7VBhwvn032310; Thu, 31 Aug 2017 04:43:59 -0700 From: Dong Aisheng To: CC: , , , , , , Dong Aisheng , Viresh Kumar , Anson Huang , Leonard Crestez Subject: [PATCH RESEND 1/1] cpufreq: imx6q: switch to Use clk_bulk_get to refine clk operations Date: Thu, 31 Aug 2017 19:43:57 +0800 Message-ID: <1504179837-18842-1-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131486534525832731; (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)(39380400002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(4326008)(50986999)(50466002)(48376002)(53936002)(47776003)(86362001)(5660300001)(110136004)(966005)(36756003)(105606002)(356003)(575784001)(2906002)(77096006)(305945005)(6306002)(54906002)(33646002)(106466001)(2351001)(97736004)(8676002)(8936002)(85426001)(498600001)(5003940100001)(189998001)(6916009)(81156014)(81166006)(68736007)(626005)(104016004)(8656003)(50226002)(7416002)(32563001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB2260; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD017; 1:IGtR4eHjlIgL73dbqRn7hzcaf85h4MqMhksfmyFX5LYEZUqFj4R/0msFxr+RuL50jRfvqkMzoUzkvBCPvAQncSgARiPrXxPAUk5gbyGz1m+pPyfgip+5tk9CDdslEGZS MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d2782eed-9109-4a24-6cba-08d4f065999d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BN3PR03MB2260; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2260; 3:VL0sxP0YfUzBTIBWIYEkOKecBLfCdlrbn4IuOY5g0X/2yX1sgauNP1If+PH+vnUuSFUx4nlLB/Fbvx0KWQk+akisTYI0F1gm+QpLYJYUxj2PQb6AtByFRpuN3iQ4IA2Vn99XdIY+Jfm3XtDM1U6SuqaTdTfEKafxiz4P1pmPr6hiWyCyvJwwczWYwDqY3TqCqtdZXQK90cgdufG2svsZAYq6z2T49AKy/Pe8wQ2CnHhNjc/5/rEvUoxPz+q6VEqVAbwoXGc2TuYrp6cxPHPQ7Oq/cx0OSomRv88SKbajgHSFI/FuYvoCWmas3G4dcq0atdihIIP76u8qiEV/BFEnUx5FUuwWv+N/DR/ysId/47I=; 25:rOr6olcRmTL2CU5JNUssEF5u6PeWTNhh4XMZM59pGr/EQJhEPuOrbxnAh4boWPo4yTe8JJWCwrNSFuq13zqnyLDXUrEo6C/OgnedOj3vPnZr/dGsDfZXRsJyuL0z2gHT48C3nvGsMoD2YIL/q8N4a8AoY86Sq0gfGP+yblOari6ay2Y3TC/nTf1atEogb1mES951zHz2hONTlx8qzWC+8J9I8MNvevcJTxEGJTT6Nl2t84V1BnzL5aRLTB0FC9aiA4BPgYu3x3LeCIGnkz+ASRttshzAmzt2q9ER8M+x/KwHQXuOnao8jMenoalK0+tyjFJEHhISp29gHBEdzjgc9g== X-MS-TrafficTypeDiagnostic: BN3PR03MB2260: X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2260; 31:E5V2LmzkjaNZXFzGDjTp5ZNSwQf5iyj+5aZT0H03bY8R8m8+S17uCMJkyqnssXOOquXj1wAkYiKNEc71sNQ1mDgINh4GBuR6XVRh6PeU4nByVXi4UiXNIzneKGoMPYUqwFP88UkvILM3FvoORKg2yTMytiY1HRTBGZRlv1i9tEatc+B7pp8eJCO8qVO0yKsQKquR50wB85QSM7aDRp8pFZwiaELG1f8EJMYCdM5ntUc=; 4:Ig7iC8aTGWkXykALU5YazCkaCLrgAE2GsAsEn4+CQ/WADFR8LoIodoRrv9qWELIwLrpYcGZ/AZknvTBm/trUbLnfkiUPJYddeg1LhRrYmzSZwmC2IpqR0bfkyCCjtQkibVg5ZaZNMnTurvAw0IGOFR5b0KwXijkdsC6eRFAOjGSavcfNVt1/OItPs8PD7ltbXLeN6NbAA6KvI4La3WMEBYqjqaIg4S1Q39gT8eRvbzJH9ysyVM7/+S49LKyiAgV+bUdcRA1r6HZpMvKUnZD9MDu1/LsxqELuykI9qGinu2Q= X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(601004)(2401047)(5005006)(13016025)(13018025)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6096035)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123563025)(20161123565025)(20161123556025)(20161123559100)(20161123561025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN3PR03MB2260; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN3PR03MB2260; X-Forefront-PRVS: 04163EF38A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR03MB2260; 23:eWRZFJTRoyaM2//DHzxJSfyc5AKWjrmNikXB4QWlw?= =?us-ascii?Q?o51gE+xLyJvWhprpBM1KP22Rhv83qM78Dt/2sGey37vMDxjHojNCm7aKG+pD?= =?us-ascii?Q?U7In32QHhN5dtengwuVuLtIDJ6hlhvQBWkc9a/YkA5TeivA18+yfXL3FIZlC?= =?us-ascii?Q?PHdX6tZylGbvVYyxGvnpjyT/HoPVrFFlgjpH8/uIqML/9GyEtc3VjcKSyjNh?= =?us-ascii?Q?R3Ijf4kK7+XzTSs645XsoM5TtbB+xFnFlmLS3t4QbEZGs4Yl1gTLFuAgmdvR?= =?us-ascii?Q?ltzrmusXLtjLileklMX6CJ8qob/XZ7A73khp/5X+NmUjzLbMhXPXquUDzBAS?= =?us-ascii?Q?J5BTcU7jpSMFTvUziQRODecQ9L4CikENVFE9NNr41M3J/uUl0SyI/caZpTSZ?= =?us-ascii?Q?AY7iv6+jwBZ5bUy/TZI3fOwrp8F2yX6N2if+HouiYTe8+GYfqjVQKLz7NFWv?= =?us-ascii?Q?6QD6jIWqrXdyWvDuIMWsjKG/FZI77t7x+JhZwwuz6yC25gPslvC10TzW0y2v?= =?us-ascii?Q?t7ELZSRGCx1AL5qkeLRsde6DxqHfoaEkA3nWy7lEam9YQ2qDLzlKJ2Zwqvyb?= =?us-ascii?Q?eP4dBBCACKwecnoNuoBQWNZFBwRCfxPyCG+Q4ATLx+epZwAbC/v29qI2reZm?= =?us-ascii?Q?AnNAjw7Z4ISrN+K8y3h9Z+xRQPoMPUrbjrKvKbYXB91pDAK3YQ3LGLjHeMFJ?= =?us-ascii?Q?c0mpANekutiOAkiqoABBqdH4R/l3uNTbypoZTuccPMoAIXEQr7qKGHgjH9i1?= =?us-ascii?Q?J2EXAamCjgDEC4Qu+e/ilPsHzzK30GN7yOsNn32KzAcuhWu1SL3Ou091n9QJ?= =?us-ascii?Q?s0owa9Hgd2mCmwnC2CYZgLUc/VlJON8PnubTZpprLVOx8xA5t2TjzDIzo/BY?= =?us-ascii?Q?XOJwRijtKNUCw1MMTScuetGlB7+EKztftSMhYpYNWWc0fpD/AyQu9J7s7eqn?= =?us-ascii?Q?6bqIzH1wztr2nzVM11bIrhKQSffQ8es+4/njdFCzau4Sflf3l+4y2Rk0dj+r?= =?us-ascii?Q?DKNYlXfMA5yl0WemJrI34NUMY8doE9a47eDiWUMijGG4SkPDoE1W+pYBO0Yq?= =?us-ascii?Q?wKb735zbHSZLYEYKOcNBsjoB/aUhmVBtT/qXKCF+JRp2X7MA5uuK+U07seJ1?= =?us-ascii?Q?kcK765k88zxL7mo6naZDCYSBK1c30ZcFokZzS9jwQ0D314E3XcaY9dZpSTr8?= =?us-ascii?Q?Hlp5oFaICZQWTw=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2260; 6:wGJxpMh9h7d47uxF3Z7ECgMMHFby7ohskuUxieu+5ynAjk8M6xSNiXlvEZ3zqyut+8bFQI2dcN3RdzSqMnWKf/qXEAF1BRPwfTSunYzj4fOmX4OfXIfNeJG/Y3+0UkdNvajU6xMYMgo9W7+fxdNV2rmWkrObQ1ngDH4PJQPlPr9OwIli9T2isFL+eelgGtiY2Te5wZnfuxPrFYzf7mjnMGDPI09WYn70+V3N8nbbdGdC53ad+NXp5SIX9wVf4wdpeViUgMQV3PfsYiueTseOOQOz1No/+dYSs5o5SXSNgjriJCGHfSy0O14W0cccHb2TdtDuJSyzJjjnuRtc9sqn3g==; 5:lc6EX6NU0j6UIizrTuPV3vcklYqrjcv5ViD9tfCDITljQgDzqj12U0y2AHz115wnXUdPaVM1HRiLjJlc2zy3zbWWVsJMLdQ7Ggr1iIXkdme5+M+1ubpzTcKo6/QUOE/hoB7/tyqc9LyeOa8l26D8tA==; 24:65pl8yYGlyUB9bp+By84epiuFkw6n9sZ7cYli/IAEtTx99GNZ6X04RvCrMOvwZngeRVgf5HYif+EhMZlVlXw06pV25c3mww+/AIMVNOSujs=; 7:tlYoAvBg7y76VNFEt74dZUoVwkkMbbvtpKS2P1ndi0gtTv2Oo4jQbvb4t8VsUfQFiLuyeYLQmydSOjW/HEOtYb0FmgjYlQ7hmfNdvH7cwoc60ieQlAM7E4JwCSwsX5FK3KoQ5MxQnk6nUvDPOvbxPMcc0PLJCHmTvoyhXEOW+99R2KNhqY/zAB6A2mo3Vqw4bO29yfsI3AE13bCezORBXYn8K0twhE7A4pxYo9BY/mM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2017 11:44:03.4884 (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: BN3PR03MB2260 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use clk_bulk_get to ease the driver clocks handling. Cc: "Rafael J. Wysocki" Cc: Viresh Kumar Cc: Shawn Guo Cc: Anson Huang Cc: Leonard Crestez Signed-off-by: Dong Aisheng --- The original one is here which depends on clk_bulk APIs. https://patchwork.kernel.org/patch/9737337/ Now the clk_bulk APIs are already in kernel, so resend the patch. (Patch title changed a bit to be more specific.) --- drivers/cpufreq/imx6q-cpufreq.c | 125 ++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 69 deletions(-) diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 14466a9..c5c0af3 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -24,15 +24,29 @@ static struct regulator *arm_reg; static struct regulator *pu_reg; static struct regulator *soc_reg; -static struct clk *arm_clk; -static struct clk *pll1_sys_clk; -static struct clk *pll1_sw_clk; -static struct clk *step_clk; -static struct clk *pll2_pfd2_396m_clk; - -/* clk used by i.MX6UL */ -static struct clk *pll2_bus_clk; -static struct clk *secondary_sel_clk; +enum IMX6_CPUFREQ_CLKS { + ARM, + PLL1_SYS, + STEP, + PLL1_SW, + PLL2_PFD2_396M, + /* MX6UL requires two more clks */ + PLL2_BUS, + SECONDARY_SEL, +}; +#define IMX6Q_CPUFREQ_CLK_NUM 5 +#define IMX6UL_CPUFREQ_CLK_NUM 7 + +static int num_clks; +static struct clk_bulk_data clks[] = { + { .id = "arm" }, + { .id = "pll1_sys" }, + { .id = "step" }, + { .id = "pll1_sw" }, + { .id = "pll2_pfd2_396m" }, + { .id = "pll2_bus" }, + { .id = "secondary_sel" }, +}; static struct device *cpu_dev; static bool free_opp; @@ -52,7 +66,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) new_freq = freq_table[index].frequency; freq_hz = new_freq * 1000; - old_freq = clk_get_rate(arm_clk) / 1000; + old_freq = clk_get_rate(clks[ARM].clk) / 1000; opp = dev_pm_opp_find_freq_ceil(cpu_dev, &freq_hz); if (IS_ERR(opp)) { @@ -111,29 +125,31 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) * voltage of 528MHz, so lower the CPU frequency to one * half before changing CPU frequency. */ - clk_set_rate(arm_clk, (old_freq >> 1) * 1000); - clk_set_parent(pll1_sw_clk, pll1_sys_clk); - if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk)) - clk_set_parent(secondary_sel_clk, pll2_bus_clk); + clk_set_rate(clks[ARM].clk, (old_freq >> 1) * 1000); + clk_set_parent(clks[PLL1_SW].clk, clks[PLL1_SYS].clk); + if (freq_hz > clk_get_rate(clks[PLL2_PFD2_396M].clk)) + clk_set_parent(clks[SECONDARY_SEL].clk, + clks[PLL2_BUS].clk); else - clk_set_parent(secondary_sel_clk, pll2_pfd2_396m_clk); - clk_set_parent(step_clk, secondary_sel_clk); - clk_set_parent(pll1_sw_clk, step_clk); + clk_set_parent(clks[SECONDARY_SEL].clk, + clks[PLL2_PFD2_396M].clk); + clk_set_parent(clks[STEP].clk, clks[SECONDARY_SEL].clk); + clk_set_parent(clks[PLL1_SW].clk, clks[STEP].clk); } else { - clk_set_parent(step_clk, pll2_pfd2_396m_clk); - clk_set_parent(pll1_sw_clk, step_clk); - if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk)) { - clk_set_rate(pll1_sys_clk, new_freq * 1000); - clk_set_parent(pll1_sw_clk, pll1_sys_clk); + clk_set_parent(clks[STEP].clk, clks[PLL2_PFD2_396M].clk); + clk_set_parent(clks[PLL1_SW].clk, clks[STEP].clk); + if (freq_hz > clk_get_rate(clks[PLL2_PFD2_396M].clk)) { + clk_set_rate(clks[PLL1_SYS].clk, new_freq * 1000); + clk_set_parent(clks[PLL1_SW].clk, clks[PLL1_SYS].clk); } else { /* pll1_sys needs to be enabled for divider rate change to work. */ pll1_sys_temp_enabled = true; - clk_prepare_enable(pll1_sys_clk); + clk_prepare_enable(clks[PLL1_SYS].clk); } } /* Ensure the arm clock divider is what we expect */ - ret = clk_set_rate(arm_clk, new_freq * 1000); + ret = clk_set_rate(clks[ARM].clk, new_freq * 1000); if (ret) { dev_err(cpu_dev, "failed to set clock rate: %d\n", ret); regulator_set_voltage_tol(arm_reg, volt_old, 0); @@ -142,7 +158,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) /* PLL1 is only needed until after ARM-PODF is set. */ if (pll1_sys_temp_enabled) - clk_disable_unprepare(pll1_sys_clk); + clk_disable_unprepare(clks[PLL1_SYS].clk); /* scaling down? scale voltage after frequency */ if (new_freq < old_freq) { @@ -173,7 +189,7 @@ static int imx6q_cpufreq_init(struct cpufreq_policy *policy) { int ret; - policy->clk = arm_clk; + policy->clk = clks[ARM].clk; ret = cpufreq_generic_init(policy, freq_table, transition_latency); policy->suspend_freq = policy->max; @@ -213,28 +229,15 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) return -ENOENT; } - 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") || - of_machine_is_compatible("fsl,imx6ull")) { - 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; - } - } + of_machine_is_compatible("fsl,imx6ull")) + num_clks = IMX6UL_CPUFREQ_CLK_NUM; + else + num_clks = IMX6Q_CPUFREQ_CLK_NUM; + + ret = clk_bulk_get(cpu_dev, num_clks, clks); + if (ret) + goto put_node; arm_reg = regulator_get(cpu_dev, "arm"); pu_reg = regulator_get_optional(cpu_dev, "pu"); @@ -378,22 +381,11 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) regulator_put(pu_reg); if (!IS_ERR(soc_reg)) regulator_put(soc_reg); -put_clk: - if (!IS_ERR(arm_clk)) - clk_put(arm_clk); - if (!IS_ERR(pll1_sys_clk)) - clk_put(pll1_sys_clk); - if (!IS_ERR(pll1_sw_clk)) - clk_put(pll1_sw_clk); - if (!IS_ERR(step_clk)) - clk_put(step_clk); - if (!IS_ERR(pll2_pfd2_396m_clk)) - clk_put(pll2_pfd2_396m_clk); - if (!IS_ERR(pll2_bus_clk)) - clk_put(pll2_bus_clk); - if (!IS_ERR(secondary_sel_clk)) - clk_put(secondary_sel_clk); + + clk_bulk_put(num_clks, clks); +put_node: of_node_put(np); + return ret; } @@ -407,13 +399,8 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev) if (!IS_ERR(pu_reg)) regulator_put(pu_reg); regulator_put(soc_reg); - clk_put(arm_clk); - clk_put(pll1_sys_clk); - clk_put(pll1_sw_clk); - clk_put(step_clk); - clk_put(pll2_pfd2_396m_clk); - clk_put(pll2_bus_clk); - clk_put(secondary_sel_clk); + + clk_bulk_put(num_clks, clks); return 0; }