From patchwork Mon Nov 16 21:24:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 7630921 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E218BBF90C for ; Mon, 16 Nov 2015 21:25:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 074572053D for ; Mon, 16 Nov 2015 21:25:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08062203EB for ; Mon, 16 Nov 2015 21:25:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752562AbbKPVZN (ORCPT ); Mon, 16 Nov 2015 16:25:13 -0500 Received: from mout.web.de ([212.227.15.4]:57194 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752487AbbKPVZI (ORCPT ); Mon, 16 Nov 2015 16:25:08 -0500 Received: from [192.168.1.3] ([77.181.163.50]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0LdmgV-1agKjk3CIl-00izol; Mon, 16 Nov 2015 22:24:39 +0100 Subject: [PATCH 2/3] ste_dma40: Delete another unnecessary check in d40_probe() To: Dan Williams , Linus Walleij , Vinod Koul , linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <564A4899.8040109@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <564A4996.2000406@users.sourceforge.net> Date: Mon, 16 Nov 2015 22:24:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <564A4899.8040109@users.sourceforge.net> X-Provags-ID: V03:K0:pTh4rc7JURnPuiZXlJxue6upq/KOawfplmHZn5SyMmdTxdABCJo wtGpmVe693/lETVDkh/6uWAA8RI/Bz06sWxYksMLpWsxe1vQOc1TsHWdUzfWxwHaPHIBscv sptp+IwYmo/aYB9Oafa1W4D2cr/NYdMRIeXMDeGZqyDukg8PELTMzskAwThx2S2+x551NA7 RR0c6Ewj2dElwLybhEDuQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:S6v14RNT2mE=:BDbpcVGlYCDYrCSrE+o7/t S0f4YuCe9Z/M+XS9eV9AkWIuAnMA0M5yPCOv2iLu7fuc9Ffe4YGn52Grm1a5NTAq9nyits3Ah LSf9INCB2RZDUa2HvKg/5zTWEf3PVFVB4al2mNjb6PGF4Kzi+HGnHxYZoXo0YJ8n5C3q3XsfG yd0dDE0K2WHE4Gpyif3nJ+AnKAfCClydom9gKwTpNvoqy8md6blVOKMkRKKQR26/jqXAcZCxl gjeGkI3rmwahFZQbJNa5mVk7ixuKGOZ+qQwua26noCykhh1ftMGAPyexuS5bHpHzsNnpQJp2C EP+QUirFwscDr8I/obGIa4C3kr8LUDXHOgPCnUIv2WAFGkGv1AnubTdajlZKjidGPqO+mavhm UnPn2JmlpTFGnMWp0sAX+67O80wHWbedoTGxBIfgZ68gnvTCVbQMnY//0tNxI326MJJO6gjGs 6ITHsKCYHwjVKCTDO0Zk5SV6lbt4HP956bGQDVC+kFtJjNy9PMPcpjdkWQOBUkwcqCxCoX+Y7 N/hpOJRXkdFo7acZPKmc5NiBwJACygXGt25n1q37hcHADwWtsoM1j5LsyXE07NL55Yn4xA9pO 2OCeYFaPwiiSH5IkawXDFom2BQ7q/rxsSEkuUFPo8xWMITdsS9B9upq8h7152SHgaSM8Ftjuc UW2ssM9TLY9+Zfr+k+So+xHhBSjMqAZcAmI1uhrQwn4k1ESsuHso6HKd+6vbFxFaPVAs186AQ pBj2qUE85Hu10PuVKuMVapWQ4Q3ivFA7Uw5IvxphI4QLe65H2KgKRe9A5wYxiiV2NlxVgK8Un 6rM3Xuh Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Markus Elfring Date: Mon, 16 Nov 2015 21:56:07 +0100 A single jump label was used by the d40_probe() function in several cases for error handling which was a bit inefficient here. * This implementation detail could be improved by the introduction of another jump label. * Remove an extra check for the variable "base". * Omit its explicit initialisation at the beginning then. Signed-off-by: Markus Elfring Acked-by: Linus Walleij --- drivers/dma/ste_dma40.c | 82 ++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 9132ae0..8ebfde1 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -3543,7 +3543,7 @@ static int __init d40_probe(struct platform_device *pdev) struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev); struct device_node *np = pdev->dev.of_node; int ret = -ENOENT; - struct d40_base *base = NULL; + struct d40_base *base; struct resource *res = NULL; int num_reserved_chans; u32 val; @@ -3552,17 +3552,17 @@ static int __init d40_probe(struct platform_device *pdev) if (np) { if (d40_of_probe(pdev, np)) { ret = -ENOMEM; - goto failure; + goto report_failure; } } else { d40_err(&pdev->dev, "No pdata or Device Tree provided\n"); - goto failure; + goto report_failure; } } base = d40_hw_detect_init(pdev); if (!base) - goto failure; + goto report_failure; num_reserved_chans = d40_phy_res_init(base); @@ -3693,50 +3693,48 @@ static int __init d40_probe(struct platform_device *pdev) return 0; failure: - if (base) { - kmem_cache_destroy(base->desc_slab); - if (base->virtbase) - iounmap(base->virtbase); + kmem_cache_destroy(base->desc_slab); + if (base->virtbase) + iounmap(base->virtbase); - if (base->lcla_pool.base && base->plat_data->use_esram_lcla) { - iounmap(base->lcla_pool.base); - base->lcla_pool.base = NULL; - } + if (base->lcla_pool.base && base->plat_data->use_esram_lcla) { + iounmap(base->lcla_pool.base); + base->lcla_pool.base = NULL; + } - if (base->lcla_pool.dma_addr) - dma_unmap_single(base->dev, base->lcla_pool.dma_addr, - SZ_1K * base->num_phy_chans, - DMA_TO_DEVICE); - - if (!base->lcla_pool.base_unaligned && base->lcla_pool.base) - free_pages((unsigned long)base->lcla_pool.base, - base->lcla_pool.pages); - - kfree(base->lcla_pool.base_unaligned); - - if (base->phy_lcpa) - release_mem_region(base->phy_lcpa, - base->lcpa_size); - if (base->phy_start) - release_mem_region(base->phy_start, - base->phy_size); - if (base->clk) { - clk_disable_unprepare(base->clk); - clk_put(base->clk); - } + if (base->lcla_pool.dma_addr) + dma_unmap_single(base->dev, base->lcla_pool.dma_addr, + SZ_1K * base->num_phy_chans, + DMA_TO_DEVICE); - if (base->lcpa_regulator) { - regulator_disable(base->lcpa_regulator); - regulator_put(base->lcpa_regulator); - } + if (!base->lcla_pool.base_unaligned && base->lcla_pool.base) + free_pages((unsigned long)base->lcla_pool.base, + base->lcla_pool.pages); - kfree(base->lcla_pool.alloc_map); - kfree(base->lookup_log_chans); - kfree(base->lookup_phy_chans); - kfree(base->phy_res); - kfree(base); + kfree(base->lcla_pool.base_unaligned); + + if (base->phy_lcpa) + release_mem_region(base->phy_lcpa, + base->lcpa_size); + if (base->phy_start) + release_mem_region(base->phy_start, + base->phy_size); + if (base->clk) { + clk_disable_unprepare(base->clk); + clk_put(base->clk); + } + + if (base->lcpa_regulator) { + regulator_disable(base->lcpa_regulator); + regulator_put(base->lcpa_regulator); } + kfree(base->lcla_pool.alloc_map); + kfree(base->lookup_log_chans); + kfree(base->lookup_phy_chans); + kfree(base->phy_res); + kfree(base); +report_failure: d40_err(&pdev->dev, "probe failed\n"); return ret; }