linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: bhelgaas@google.com (Bjorn Helgaas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] PCI: versatile: don't check resource with devm_ioremap_resource
Date: Thu, 9 Apr 2015 14:32:32 -0500	[thread overview]
Message-ID: <20150409193232.GK30967@google.com> (raw)
In-Reply-To: <1428067025-543-1-git-send-email-jszhang@marvell.com>

On Fri, Apr 03, 2015 at 09:17:05PM +0800, Jisheng Zhang wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need
> to duplicate this in the driver. And we should check whether
> devm_ioremap_resource() succeeds or not.
> 
> This patch fixes all of these two trival issues.
> 
> Signed-off-by: Jisheng Zhang <jszhang@marvell.com>

This looks correct to me, so I applied it to pci/host-versatile for v4.1
(unless Rob chimes in).

commit 873581698d391ff070fc1eb8fb298c85e873c07c
Author: Jisheng Zhang <jszhang@marvell.com>
Date:   Fri Apr 3 21:17:05 2015 +0800

    PCI: versatile: Check for devm_ioremap_resource() failures
    
    Check for failure of devm_ioremap_resource().
    
    devm_ioremap_resource() validates the resource it receives, so if we check
    for devm_ioremap_resource() failure, we need not check for failure of the
    preceding platform_get_resource().
    
    [bhelgaas: changelog]
    Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

diff --git a/drivers/pci/host/pci-versatile.c b/drivers/pci/host/pci-versatile.c
index 1ec694a52379..b1caaea740fe 100644
--- a/drivers/pci/host/pci-versatile.c
+++ b/drivers/pci/host/pci-versatile.c
@@ -138,19 +138,19 @@ static int versatile_pci_probe(struct platform_device *pdev)
 	LIST_HEAD(pci_res);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENODEV;
 	versatile_pci_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(versatile_pci_base))
+		return PTR_ERR(versatile_pci_base);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	if (!res)
-		return -ENODEV;
 	versatile_cfg_base[0] = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(versatile_cfg_base[0]))
+		return PTR_ERR(versatile_cfg_base[0]);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
-	if (!res)
-		return -ENODEV;
 	versatile_cfg_base[1] = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(versatile_cfg_base[1]))
+		return PTR_ERR(versatile_cfg_base[1]);
 
 	ret = versatile_pci_parse_request_of_pci_ranges(&pdev->dev, &pci_res);
 	if (ret)

      reply	other threads:[~2015-04-09 19:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-03 13:17 [PATCH] PCI: versatile: don't check resource with devm_ioremap_resource Jisheng Zhang
2015-04-09 19:32 ` Bjorn Helgaas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150409193232.GK30967@google.com \
    --to=bhelgaas@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).