Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp321285ybi; Tue, 18 Jun 2019 23:36:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUxW65wIIf3n6P4UZQ4Bcd5z9cW5VdmE5qYbFCDchzFF9Az1vxE9eHiNY1KVxR0FuGvlXX X-Received: by 2002:a17:90a:5887:: with SMTP id j7mr9344389pji.136.1560926213471; Tue, 18 Jun 2019 23:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560926213; cv=none; d=google.com; s=arc-20160816; b=J1X5+oXaamxTrcCjhjMHnYNeDhJR9PW0rN5zM5Ai7sc+AsTekiNYZm1WHTRLCJrPxC rNlLUF1lr9JPosiO/EtBHClVGDiOBbZ2Hj+gp+LxEiOufiBccAMi2buwdc2s63tVHyrF O0Eyd06Qi6lMA2FMo/qOSM4CvG4RbujcS1oDgxC8iKZcb12G7PQCKszvh8wqbaPQJHhg cfq4ZAYDKY++rU3lBxI+IjNN5aHEYOsCs7IdiqmYgUQ4ir39Dk8JA29PKYezi18gCQnV lfxyx3dP9oRRmk4S3MVJN1S92kq8hSUzE8gH/3Ty/mrNsTj092SuOIV7CallP+Ksj8RV O/Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Tw9Y/vwN/nARE1RA9Z2C9HCqwYacrU1B+FDIn0dtVZQ=; b=tY7azHDaCY8FyiUPMzfgj3ekdF8sqe3+4imsSrnoEHfxF5dixwREhnJcOeobFxGhdo 5WeJCZut/JWJE9yPwW86+0QvV7TRsQb5a4EGfTCdNCKtARIdhleXIDOSfjnHbbQiC4ad 6c0h5ngB4MoAkKJO4ZKDRr0SG44SOPFMndZwWphCtCRIA1dJgywbwXZH0Rb/XhxLd3Jc te1EV1JbMtp/xjiK1tbjLN9scmsloJLNie4EsIYgHl8MH1PvSNkMJnsVjBAgtbekP2cX AlVChTqwL9F2BTm1WM+S13J4A+NdN2BYZw+09CF1DATP+qRxZeiqTPEhs7TiErlG4+fm QWsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nikanor-nu.20150623.gappssmtp.com header.s=20150623 header.b=1auTgZY3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16si15494329pfn.162.2019.06.18.23.36.38; Tue, 18 Jun 2019 23:36:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nikanor-nu.20150623.gappssmtp.com header.s=20150623 header.b=1auTgZY3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731029AbfFSGgQ (ORCPT + 99 others); Wed, 19 Jun 2019 02:36:16 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:44154 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730791AbfFSGgP (ORCPT ); Wed, 19 Jun 2019 02:36:15 -0400 Received: by mail-lf1-f68.google.com with SMTP id r15so11163028lfm.11 for ; Tue, 18 Jun 2019 23:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikanor-nu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Tw9Y/vwN/nARE1RA9Z2C9HCqwYacrU1B+FDIn0dtVZQ=; b=1auTgZY3XXASfEB5dbWR7cin7TUrizNMayAe8EJtU+g2xVhoj90JKlrRoa7NhUs96r cIZ/6gso0BtyhVAysHmSYMPB53TJC9qwJmi2HuUwAlhqGILlA7rWM+u+ORxfRfEDUzUM ztcLvl6IiYfLhcWUpgDogw0rmQqBRURhPoNLV7/bfnWNBWkpHZ3t/N1WmRC3ZUBYajib 96vS8sUYOsSzRsNui60qrgQMlRkkcu5fLtYt9vvU3b/pXUqS0P1DRDEOuIVwtkr3pvSc AXU4YluwYPU6RJ1/Vyd5SVa4fJIHhTMzdl1pOPPu7EfPSxyeuOzQ7VYGRNnIMOWLfHHe Jhvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Tw9Y/vwN/nARE1RA9Z2C9HCqwYacrU1B+FDIn0dtVZQ=; b=CP0hM7ORw70XQs0ntBres9oHK7NqY1XcCvNmWa54Ak6nzQRw96b7lGelhJnUzL+qtt dx1ty6oM+qAMpww6Ywc2s6pbSI0MZYjC0xj4bW65dWpWDHaPqBWoMoZYHWq3pyVF99Bm 2Twd2CA2Nq8mhtqUPmGDXRa1fFPvrLwlWUx2b7whsqQ+mDRmEAgZ84DBF6y8J3DJ9Ykk RrP3H+7YwmheiL8Ko7/384fQr2Lmu/1fmAxALuMYlTxOQ9HRsAcfOMf8uk/Wy6Xbbos6 MI+B9xxTSfF4+YgGlMHgmWBBGP1pyA8+uefwkZsPV67i1b+NR8bnQlgfPl75HeI2pzbD cjww== X-Gm-Message-State: APjAAAU20wDaJlS64OFOae35SMDGKAdTaLojxFKUcEqW7jp3opQT+pCs MHcKISS+bZbpvEvJWY4XyzCwrw== X-Received: by 2002:ac2:5189:: with SMTP id u9mr60649520lfi.189.1560926173626; Tue, 18 Jun 2019 23:36:13 -0700 (PDT) Received: from dev.nikanor.nu (78-72-133-4-no161.tbcn.telia.com. [78.72.133.4]) by smtp.gmail.com with ESMTPSA id k82sm2933092ljb.84.2019.06.18.23.36.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 23:36:13 -0700 (PDT) From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= To: gregkh@linuxfoundation.org Cc: dan.carpenter@oracle.com, jeremy@azazel.net, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Subject: [PATCH] staging: kpc2000: simplify error handling in kp2000_pcie_probe Date: Wed, 19 Jun 2019 08:36:07 +0200 Message-Id: <20190619063607.20722-1-simon@nikanor.nu> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can get rid of a few iounmaps in the middle of the function by re-ordering the error handling labels and adding two new labels. Signed-off-by: Simon Sandström --- This change has not been tested besides by compiling. It might be good took take an extra look to make sure that I got everything right. Also, this change was proposed by Dan Carpenter. Should I add anything in the commit message to show this? - Simon drivers/staging/kpc2000/kpc2000/core.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 610ea549d240..cb05cca687e1 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -351,12 +351,11 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, err = pci_request_region(pcard->pdev, REG_BAR, KP_DRIVER_NAME_KP2000); if (err) { - iounmap(pcard->regs_bar_base); dev_err(&pcard->pdev->dev, "probe: failed to acquire PCI region (%d)\n", err); err = -ENODEV; - goto err_disable_device; + goto err_unmap_regs; } pcard->regs_base_resource.start = reg_bar_phys_addr; @@ -374,7 +373,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, dev_err(&pcard->pdev->dev, "probe: DMA_BAR could not remap memory to virtual space\n"); err = -ENODEV; - goto err_unmap_regs; + goto err_release_regs; } dev_dbg(&pcard->pdev->dev, "probe: DMA_BAR virt hardware address start [%p]\n", @@ -384,11 +383,10 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, err = pci_request_region(pcard->pdev, DMA_BAR, "kp2000_pcie"); if (err) { - iounmap(pcard->dma_bar_base); dev_err(&pcard->pdev->dev, "probe: failed to acquire PCI region (%d)\n", err); err = -ENODEV; - goto err_unmap_regs; + goto err_unmap_dma; } pcard->dma_base_resource.start = dma_bar_phys_addr; @@ -400,7 +398,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, pcard->sysinfo_regs_base = pcard->regs_bar_base; err = read_system_regs(pcard); if (err) - goto err_unmap_dma; + goto err_release_dma; // Disable all "user" interrupts because they're not used yet. writeq(0xFFFFFFFFFFFFFFFF, @@ -438,14 +436,14 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, if (err) { dev_err(&pcard->pdev->dev, "CANNOT use DMA mask %0llx\n", DMA_BIT_MASK(64)); - goto err_unmap_dma; + goto err_release_dma; } dev_dbg(&pcard->pdev->dev, "Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard))); err = pci_enable_msi(pcard->pdev); if (err < 0) - goto err_unmap_dma; + goto err_release_dma; rv = request_irq(pcard->pdev->irq, kp2000_irq_handler, IRQF_SHARED, pcard->name, pcard); @@ -478,14 +476,14 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, free_irq(pcard->pdev->irq, pcard); err_disable_msi: pci_disable_msi(pcard->pdev); +err_release_dma: + pci_release_region(pdev, DMA_BAR); err_unmap_dma: iounmap(pcard->dma_bar_base); - pci_release_region(pdev, DMA_BAR); - pcard->dma_bar_base = NULL; +err_release_regs: + pci_release_region(pdev, REG_BAR); err_unmap_regs: iounmap(pcard->regs_bar_base); - pci_release_region(pdev, REG_BAR); - pcard->regs_bar_base = NULL; err_disable_device: pci_disable_device(pcard->pdev); err_remove_ida: -- 2.20.1