Skip to contentSkip to conversation

PCI: versatile: don't check resource with devm_ioremap_resource

PATCH In review Jisheng Zhang 2 participants 2 messages Apr 3, 2015 – Apr 9, 2015 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: versatile: don't check resource with devm_ioremap_resource

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.

---
 drivers/pci/host/pci-versatile.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pci/host/pci-versatile.c +6 -6
index 464bf49..ba5eab1 100644
@@ -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)
Signature · 1 line
2.1.4
maintainer
#1 lore raw
Quoted 7 lines · Jisheng Zhang

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.

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 <[email protected]>
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]
drivers/pci/host/pci-versatile.c +6 -6
index 1ec694a52379..b1caaea740fe 100644
@@ -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)