From patchwork Mon Aug 31 17:05:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bai Ping X-Patchwork-Id: 7099041 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1C9E89F1B9 for ; Mon, 31 Aug 2015 09:02:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2EABB20458 for ; Mon, 31 Aug 2015 09:02:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E111220453 for ; Mon, 31 Aug 2015 09:02:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752325AbbHaJCL (ORCPT ); Mon, 31 Aug 2015 05:02:11 -0400 Received: from mail-bn1bn0105.outbound.protection.outlook.com ([157.56.110.105]:46720 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750922AbbHaJCJ (ORCPT ); Mon, 31 Aug 2015 05:02:09 -0400 Received: from BLUPR03CA012.namprd03.prod.outlook.com (10.255.124.29) by CY1PR0301MB1274.namprd03.prod.outlook.com (10.161.214.22) with Microsoft SMTP Server (TLS) id 15.1.256.15; Mon, 31 Aug 2015 09:02:07 +0000 Received: from BN1AFFO11OLC003.protection.gbl (10.255.124.4) by BLUPR03CA012.outlook.office365.com (10.255.124.29) with Microsoft SMTP Server (TLS) id 15.1.256.15 via Frontend Transport; Mon, 31 Aug 2015 09:02:06 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=freescale.com; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11OLC003.mail.protection.outlook.com (10.58.53.74) with Microsoft SMTP Server (TLS) id 15.1.256.10 via Frontend Transport; Mon, 31 Aug 2015 09:02:06 +0000 Received: from b51503-01.ap.freescale.net (b51503-01.ap.freescale.net [10.193.102.227]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t7V923cl005608; Mon, 31 Aug 2015 02:02:04 -0700 From: Bai Ping To: , CC: , Subject: [PATCH] cpufreq: imx: use the managed interfaces for resources allocation Date: Tue, 1 Sep 2015 01:05:30 +0800 Message-ID: <1441040730-16391-1-git-send-email-b51503@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11OLC003; 1:GPYkDUEUV9tTrGtTdNN5lo4Wtx+tOEonAYuln4Yoe0vNqkidL8nADn6CAXZxT/wyhXukneYAXp1zEr5foc9Ke5wd56hCEBjibvR6akqzHRSJ5xus5PS+SgTQOohAekVl4YOvAcy1cBpIg8K3Yeb8y1zLc9cUcReLa9g0zS8kebB/VfmnK8QwPhFZdrBTcm7ORFyJyqyK+h9Q2trUN7VvlOGxStCqJVYH0XMfkrZQJkj6W43H/ZZSa5X6CJi3JWU/YJDFdxp5TkfHvUIqKFjizYUtV0pHAs+o49tb0d21hTHq7ZpBphZwBC6gCI1AzmeQ97ChUxsQCpxXWHYm18M5ySXvLQKMDSUmWIEfVDpcgpH3YUaoHQNjNtZTzsKClysH+vXMOOnVXKlFH53LAL5DHQO0ipxVk8sTVTFyjAx6xCIXssfB1Ib24MKSJeDMgS7SmjEoz9OXIDf+GBUzfWybog== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(3050300001)(199003)(189002)(106466001)(64706001)(77156002)(104016003)(92566002)(19580395003)(85426001)(4001540100001)(62966003)(229853001)(5001770100001)(68736005)(6806004)(81156007)(19580405001)(105606002)(47776003)(50466002)(50986999)(5001860100001)(189998001)(48376002)(69596002)(5007970100001)(33646002)(5001830100001)(5003940100001)(50226001)(97736004)(5001960100002)(46102003)(36756003)(87936001)(77096005); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB1274; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1274; 2:qn7lzaJsPeeHByBXNqngkjAmzeppPkhR7rFOWzEAOqrfL8eH/turyj27lb0IL4iqtDtw1cQdEylW7Pb75YfgiHzpoeX5vHzH/jGPC89CGZ8g+AS7i1y/zNAjDY92+llpX4J9VHoq6JsC7zXrQfTyVWA37kTCG9I3Os4C88lS1XY=; 3:6g8GK5SDPB9lm3mLaOQtWFpvtytpeXC1lG4QcZW5fuONlD9mRLY0NUXhJ/HyYLThl3728cLFOR7qTi2pVEvE8ZDFE/YCIxAqVjhG1n4Y1tVsu0eIRYOyK89GZDlouPXvH4PTp41Tx8AoTVqr5p7xjw3RM+Hy83nkmOEPcF4/9dxcyy+SAmFkykdgF4QSDOLBzG7bQlwz/2vuDgAYyYZJhq+SniZGMd2+dERINsdcLqY=; 25:ay58w0axhVFHwiDViByD3ZexNZUAQv9zoG/Ut9sSwLXxsj2QUygeLcsJO8yltFPovuiHe8r1o7pQXLzPFPvpuaJ0YCj0AuFD6g10/EYQWB5NP8ytD6K5JzWaBOjWPvsVuNpTbXUBWg7djnwfJHuqBdMHIwpThkSmysKoI5ArjIq3SsasSsOOzE/i8vN5/DHocrEA4uNcErqyggLd4ywxEwSc7t0hNm9GpGQIdSPJUQwFOWQOeiPMK845TrQV4nZEoMvVIVcNHlHYRz9bdgGkQA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1274; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1274; 20:qg7l4ji6vfFEBImLgNIyS88EJ9+SxQY717KHg5fMt702/3fgpnRZjRntNmT5Ej3wCdVTZjgfK+JRMihum7isF2LKotlGS2Jx1FlzMU1kTHKepKBDuw1VsOrJVHPVmQ8MooMU+tVtkI0uFPGBq38vXt4s9rGOzRVW3w1x5jQbTvJ9KWIh+XK03gYDnDi2jlDaIXbV14jxYBa629JZOT4QChSgo+iXWW2O6sXQ06/Y3jMScKon9kyeZT6nimxUxUdFsF+i+7mn/rDv/4Zzrt1/WdmHSGowiclf6eQsC4xIQNaGC7Tvz+GYV9Tr/SKNC4PuksCBW02S4EM7comFJpzQMCjTNVpZms8KCptzFhwTD0Q=; 4:AkbMbLkYORMqg5MyySHF8FU4pRMvf9HbsPzYIh9uqo+LnM+oU7IMns9Pkj9Hpl6ARJZt2QS2C22+sgmoptoejYKCPo3ZoX/nRffjATifBQ3bM3unc8hWBC6Q60m2h/RVf0i1viaaIhrxEVyMUJnhTs/vIX6hBVzXMwG3AjcqmoJ21jK8tSBEujkxEdYDZd5X8+t8kT892TC9mLmsi59Sp3mxPCdxbT7/ReQ4UyTkL/biWLpBWZU+2xoBf9pCgWvPELsrR2pH7CfAUQJ79cK88T0eXUZiEciJUg4PrEDTTXEarwBAatl6oJq9R4q+q73E2Tqg+KRL26E8R/mWK9METw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(8121501046)(3002001); SRVR:CY1PR0301MB1274; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1274; X-Forefront-PRVS: 0685122203 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1274; 23:vXJx9HTqKwXnOMkQV6lZjE7bOLg9zV50d7PyzaL?= =?us-ascii?Q?BZPcd4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ZilYa1871JXz1LU1NBrLsYe?= =?us-ascii?Q?maVG7P3h7HSJs2RGCTJsir48RWUpVm6xA9toTkrHv9FE9fmtOO/37kaMX/JO?= =?us-ascii?Q?hH9Kh6iXQ+f/uWRy2zWfAMxvhaxXzt+xEjE9tJCSm0zoiL0g42HI0Qt6ip3f?= =?us-ascii?Q?WXSrrYT2NWgVeYeoAoRFpNC4nCo5d1SsZOr+SM8IkARWKaV46n/zRkSHyaum?= =?us-ascii?Q?JeRK/8ps5/CU=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1274; 5:NyicKhhhpt7Y4wcyj3u2sOI/6Ekon/1+XzvojGV4JSiniMp9kxvT/GgAAHZp9+HfZ+2VlxFJXfTo3jG6Aj+B5ttPHKLLOaqixAUU6HtnfR5xrAelp3BzZDEgMdwkztSccXoiEaVBiFy9KzLtx/YFbg==; 24:Dt9Ovvj/zxP1Vl0jj8VZi/IUIGSzgi4+uCIMQ84vqgBUA4Zwuzm9vYSWL5O9FTvNV4uEwUjh1aRmz1dpLVS7Q43gzW5JC0c/XPCMKVpiXMY=; 20:SwAUk4aMRQ+9WBakOPgiJwGwbrUcG6ebUTY9oijU+On+3sp+/nXBMT3BP9Da+U8xSEc5YkRxDTc9onXBPRlo0A== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2015 09:02:06.6148 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1274 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replace the clk_get() and regulator_get() with the managed interfaces then the error path can be simplified. Signed-off-by: Bai Ping --- drivers/cpufreq/imx6q-cpufreq.c | 52 +++++++++++------------------------------ 1 file changed, 13 insertions(+), 39 deletions(-) diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 380a90d..1439f93 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -174,25 +174,25 @@ 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"); + arm_clk = devm_clk_get(cpu_dev, "arm"); + pll1_sys_clk = devm_clk_get(cpu_dev, "pll1_sys"); + pll1_sw_clk = devm_clk_get(cpu_dev, "pll1_sw"); + step_clk = devm_clk_get(cpu_dev, "step"); + pll2_pfd2_396m_clk = devm_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; + goto put_node; } - arm_reg = regulator_get(cpu_dev, "arm"); - pu_reg = regulator_get_optional(cpu_dev, "pu"); - soc_reg = regulator_get(cpu_dev, "soc"); + arm_reg = devm_regulator_get(cpu_dev, "arm"); + pu_reg = devm_regulator_get_optional(cpu_dev, "pu"); + soc_reg = devm_regulator_get(cpu_dev, "soc"); if (IS_ERR(arm_reg) || IS_ERR(soc_reg)) { dev_err(cpu_dev, "failed to get regulators\n"); ret = -ENOENT; - goto put_reg; + goto put_node; } /* @@ -205,7 +205,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) ret = of_init_opp_table(cpu_dev); if (ret < 0) { dev_err(cpu_dev, "failed to init OPP table: %d\n", ret); - goto put_reg; + goto put_node; } /* Because we have added the OPPs here, we must free them */ @@ -222,7 +222,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table); if (ret) { dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret); - goto put_reg; + goto out_free_opp; } /* Make imx6_soc_volt array's size same as arm opp number */ @@ -313,24 +313,7 @@ free_freq_table: out_free_opp: if (free_opp) of_free_opp_table(cpu_dev); -put_reg: - if (!IS_ERR(arm_reg)) - regulator_put(arm_reg); - if (!IS_ERR(pu_reg)) - 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); +put_node: of_node_put(np); return ret; } @@ -341,15 +324,6 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev) dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); if (free_opp) of_free_opp_table(cpu_dev); - regulator_put(arm_reg); - 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); return 0; }