Skip to contentSkip to conversation

simplify use of devm_ioremap_resource

PATCH Applied Julia Lawall 19 participants 56 messages Aug 14, 2013 – Jun 6, 2015

Subsystems (42)
DRM drivers Media (V4L/DVB) SCSI USB +38 more subsystems
lore
Share & tools
lore
#0 lore raw

cover simplify use of devm_ioremap_resource

devm_ioremap_resource often uses the result of a call to platform_get_resource as its last argument. devm_ioremap_resource does appropriate error handling on this argument, so error handling can be removed from the call site. To make the connection between the call to platform_get_resource and the call to devm_ioremap_resource more clear, the former is also moved down to be adjacent to the latter.

In many cases, this patch changes the specific error value that is returned on failure of platform_get_resource.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

(
res = platform_get_resource(pdev, IORESOURCE_MEM, n);
- if (res == NULL) { ... \(goto l;\|return ret;\) } e = devm_ioremap_resource(e1, res);
|
- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
)
// </smpl>

#1 lore raw

PATCH 1/29 pinctrl: nomadik: simplify use of devm_ioremap_resource

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/pinctrl/pinctrl-nomadik.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/pinctrl/pinctrl-nomadik.c +1 -4
index 89280bc..be126fc 100644
@@ -1055,10 +1055,6 @@ static int nmk_gpio_probe(struct platform_device *dev)
 		pdata->num_gpio   = NMK_GPIO_PER_CHIP;
 	}
 
-	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENOENT;
-
 	irq = platform_get_irq(dev, 0);
 	if (irq < 0)
 		return irq;
@@ -1067,6 +1063,7 @@ static int nmk_gpio_probe(struct platform_device *dev)
 	if (secondary_irq >= 0 && !pdata->get_secondary_status)
 		return -EINVAL;
 
+	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	base = devm_ioremap_resource(&dev->dev, res);
 	if (IS_ERR(base))
 		return PTR_ERR(base);
#2 lore raw

Re: [PATCH 1/29] pinctrl: nomadik: simplify use of devm_ioremap_resource

Quoted 26 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

Quoted 1 line

Patch applied.

Yours,
Linus Walleij

#3 lore raw

PATCH 2/29 video: mxsfb: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/video/mxsfb.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/video/mxsfb.c +1 -6
index c2d3514..d250ed0 100644
@@ -855,12 +855,6 @@ static int mxsfb_probe(struct platform_device *pdev)
 	if (of_id)
 		pdev->id_entry = of_id->data;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "Cannot get memory IO resource\n");
-		return -ENODEV;
-	}
-
 	fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev);
 	if (!fb_info) {
 		dev_err(&pdev->dev, "Failed to allocate fbdev\n");
@@ -869,6 +863,7 @@ static int mxsfb_probe(struct platform_device *pdev)
 
 	host = to_imxfb_host(fb_info);
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	host->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(host->base)) {
 		ret = PTR_ERR(host->base);
#4 lore raw

Re: [PATCH 2/29] video: mxsfb: simplify use of devm_ioremap_resource

Quoted 51 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/video/mxsfb.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/video/mxsfb.c +0 -6
index c2d3514..d250ed0 100644
@@ -855,12 +855,6 @@ static int mxsfb_probe(struct platform_device *pdev)
 	if (of_id)
 		pdev->id_entry = of_id->data;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "Cannot get memory IO resource\n");
-		return -ENODEV;
-	}
-
 	fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev);
 	if (!fb_info) {
 		dev_err(&pdev->dev, "Failed to allocate fbdev\n");

drivers/video/mxsfb.c static int mxsfb_probe(struct platform_device *pdev) · line 869

Quoted 7 lines
drivers/video/mxsfb.c +1 -0
@@ -869,6 +863,7 @@ static int mxsfb_probe(struct platform_device *pdev)
 
 	host = to_imxfb_host(fb_info);
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	host->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(host->base)) {
 		ret = PTR_ERR(host->base);

Thanks, queued for 3.12.

Tomi

#5 lore raw

PATCH 3/29 drivers/gpio: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/gpio/gpio-mvebu.c       |    7 +------
 drivers/gpio/gpio-spear-spics.c |    7 +------
 2 files changed, 2 insertions(+), 12 deletions(-)
drivers/gpio/gpio-mvebu.c +1 -6
index 80ad35e..3c3321f 100644
@@ -566,12 +566,6 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 	else
 		soc_variant = MVEBU_GPIO_SOC_VARIANT_ORION;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "Cannot get memory resource\n");
-		return -ENODEV;
-	}
-
 	mvchip = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_gpio_chip), GFP_KERNEL);
 	if (!mvchip) {
 		dev_err(&pdev->dev, "Cannot allocate memory\n");
@@ -611,6 +605,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 	mvchip->chip.dbg_show = mvebu_gpio_dbg_show;
 
 	spin_lock_init(&mvchip->lock);
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	mvchip->membase = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(mvchip->membase))
 		return PTR_ERR(mvchip->membase);
drivers/gpio/gpio-spear-spics.c +1 -6
index 7a4bf7c..e9a0415 100644
@@ -128,18 +128,13 @@ static int spics_gpio_probe(struct platform_device *pdev)
 	struct resource *res;
 	int ret;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "invalid IORESOURCE_MEM\n");
-		return -EBUSY;
-	}
-
 	spics = devm_kzalloc(&pdev->dev, sizeof(*spics), GFP_KERNEL);
 	if (!spics) {
 		dev_err(&pdev->dev, "memory allocation fail\n");
 		return -ENOMEM;
 	}
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	spics->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(spics->base))
 		return PTR_ERR(spics->base);
Acked-by on v1 3/29
#6 lore raw

Re: [PATCH 3/29] drivers/gpio: simplify use of devm_ioremap_resource

Quoted 26 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

Quoted 6 lines

---

 drivers/gpio/gpio-spear-spics.c |    7 +------
 2 files changed, 2 insertions(+), 12 deletions(-)

For SPEAr:

Quoted 30 lines
drivers/gpio/gpio-spear-spics.c +1 -7
index 7a4bf7c..e9a0415 100644
@@ -128,18 +128,13 @@ static int spics_gpio_probe(struct platform_device *pdev)
        struct resource *res;
        int ret;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res) {
-               dev_err(&pdev->dev, "invalid IORESOURCE_MEM\n");
-               return -EBUSY;
-       }
-
        spics = devm_kzalloc(&pdev->dev, sizeof(*spics), GFP_KERNEL);
        if (!spics) {
                dev_err(&pdev->dev, "memory allocation fail\n");
                return -ENOMEM;
        }
 
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        spics->base = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(spics->base))
                return PTR_ERR(spics->base);
 
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#7 lore raw

Re: [PATCH 3/29] drivers/gpio: simplify use of devm_ioremap_resource

In reply to Julia Lawall
Quoted 7 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

Patch applied with Viresh's ACK.

Yours,
Linus Walleij

#8 lore raw

PATCH 4/29 mtd: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/mtd/devices/elm.c    |    5 -----
 drivers/mtd/nand/txx9ndfmc.c |    4 +---
 2 files changed, 1 insertion(+), 8 deletions(-)
drivers/mtd/devices/elm.c +0 -5
index 4f683d2..d1dd6a3 100644
@@ -368,11 +368,6 @@ static int elm_probe(struct platform_device *pdev)
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "no memory resource defined\n");
-		return -ENODEV;
-	}
-
 	info->elm_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(info->elm_base))
 		return PTR_ERR(info->elm_base);
drivers/mtd/nand/txx9ndfmc.c +1 -3
index 440b570..235714a 100644
@@ -281,12 +281,10 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)
 	unsigned long gbusclk = plat->gbus_clock;
 	struct resource *res;
 
-	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENODEV;
 	drvdata = devm_kzalloc(&dev->dev, sizeof(*drvdata), GFP_KERNEL);
 	if (!drvdata)
 		return -ENOMEM;
+	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	drvdata->base = devm_ioremap_resource(&dev->dev, res);
 	if (IS_ERR(drvdata->base))
 		return PTR_ERR(drvdata->base);
#9 lore raw

Re: [PATCH 4/29] mtd: simplify use of devm_ioremap_resource

Quoted 7 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

Pushed to l2-mtd.git, thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#10 lore raw

PATCH 5/29 spi/spi-{bcm63xx.c,bfin-v3.c}: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/spi/spi-bcm63xx.c |    8 +-------
 drivers/spi/spi-bfin-v3.c |    8 +-------
 2 files changed, 2 insertions(+), 14 deletions(-)
drivers/spi/spi-bcm63xx.c +1 -7
index 4ac028d..2b5c692 100644
@@ -342,13 +342,6 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	struct bcm63xx_spi *bs;
 	int ret;
 
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r) {
-		dev_err(dev, "no iomem\n");
-		ret = -ENXIO;
-		goto out;
-	}
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "no irq\n");
@@ -375,6 +368,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, master);
 	bs->pdev = pdev;
 
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	bs->regs = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(bs->regs)) {
 		ret = PTR_ERR(bs->regs);
drivers/spi/spi-bfin-v3.c +1 -7
index 603d7e9..d5bab00 100644
@@ -792,13 +792,6 @@ static int bfin_spi_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	/* get register base and tx/rx dma */
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem) {
-		dev_err(dev, "can not get register base\n");
-		return -ENXIO;
-	}
-
 	res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
 	if (!res) {
 		dev_err(dev, "can not get tx dma resource\n");
@@ -838,6 +831,7 @@ static int bfin_spi_probe(struct platform_device *pdev)
 	drv_data->pin_req = info->pin_req;
 	drv_data->sclk = sclk;
 
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	drv_data->regs = devm_ioremap_resource(dev, mem);
 	if (IS_ERR(drv_data->regs)) {
 		ret = PTR_ERR(drv_data->regs);
maintainer Applied
#11 lore raw

Re: [PATCH 5/29] spi/spi-{bcm63xx.c,bfin-v3.c}: simplify use of devm_ioremap_resource

Quoted 4 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Applied, thanks.

#12 lore raw

PATCH 6/29 tegra: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/iommu/tegra-smmu.c  |    2 --
 drivers/memory/tegra20-mc.c |    2 --
 drivers/memory/tegra30-mc.c |    2 --
 3 files changed, 6 deletions(-)
drivers/iommu/tegra-smmu.c +0 -2
index f6f120e..e066560 100644
@@ -1177,8 +1177,6 @@ static int tegra_smmu_probe(struct platform_device *pdev)
 		struct resource *res;
 
 		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
-		if (!res)
-			return -ENODEV;
 		smmu->regs[i] = devm_ioremap_resource(&pdev->dev, res);
 		if (IS_ERR(smmu->regs[i]))
 			return PTR_ERR(smmu->regs[i]);
drivers/memory/tegra20-mc.c +0 -2
index 0548eea..7cd82b8 100644
@@ -218,8 +218,6 @@ static int tegra20_mc_probe(struct platform_device *pdev)
 		struct resource *res;
 
 		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
-		if (!res)
-			return -ENODEV;
 		mc->regs[i] = devm_ioremap_resource(&pdev->dev, res);
 		if (IS_ERR(mc->regs[i]))
 			return PTR_ERR(mc->regs[i]);
drivers/memory/tegra30-mc.c +0 -2
index 58d2979..ef79345 100644
@@ -340,8 +340,6 @@ static int tegra30_mc_probe(struct platform_device *pdev)
 		struct resource *res;
 
 		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
-		if (!res)
-			return -ENODEV;
 		mc->regs[i] = devm_ioremap_resource(&pdev->dev, res);
 		if (IS_ERR(mc->regs[i]))
 			return PTR_ERR(mc->regs[i]);
#13 lore raw

Re: [PATCH 6/29] tegra: simplify use of devm_ioremap_resource

Quoted 4 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

I believe that drivers/iommu changes are usually applied by Joerg Roedel <[email protected]> and drivers/memory changes by Greg Kroah-Hartman <[email protected]>, although admittedly neither of those is particularly called out by the MAINTAINERS file...

I guess these are simple enough that I can take them through the Tegra tree though, since it doesn't look like there will be any conflicts doing so for 3.12.

#14 lore raw

Re: [PATCH 6/29] tegra: simplify use of devm_ioremap_resource

In reply to Julia Lawall
Quoted 4 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

I have applied this to Tegra's for-3.12/cleanup branch.

#15 lore raw

PATCH 7/29 dma: mmp: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/dma/mmp_pdma.c |    3 ---
 drivers/dma/mmp_tdma.c |    3 ---
 2 files changed, 6 deletions(-)
drivers/dma/mmp_pdma.c +0 -3
index 9a32f2d..afa5a2e 100644
@@ -786,9 +786,6 @@ static int mmp_pdma_probe(struct platform_device *op)
 	spin_lock_init(&pdev->phy_lock);
 
 	iores = platform_get_resource(op, IORESOURCE_MEM, 0);
-	if (!iores)
-		return -EINVAL;
-
 	pdev->base = devm_ioremap_resource(pdev->dev, iores);
 	if (IS_ERR(pdev->base))
 		return PTR_ERR(pdev->base);
drivers/dma/mmp_tdma.c +0 -3
index a9345d0..38cb517 100644
@@ -550,9 +550,6 @@ static int mmp_tdma_probe(struct platform_device *pdev)
 	}
 
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!iores)
-		return -EINVAL;
-
 	tdev->base = devm_ioremap_resource(&pdev->dev, iores);
 	if (IS_ERR(tdev->base))
 		return PTR_ERR(tdev->base);
Applied
#16 lore raw

Re: [PATCH 7/29] dma: mmp: simplify use of devm_ioremap_resource

Quoted 23 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

Quoted 1 line

Applied, thanks

~Vinod

#17 lore raw

PATCH 8/29 drivers/cpuidle/cpuidle-kirkwood.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/cpuidle/cpuidle-kirkwood.c |    3 ---
 1 file changed, 3 deletions(-)
drivers/cpuidle/cpuidle-kirkwood.c +0 -3
index 521b0a7..2237135 100644
@@ -60,9 +60,6 @@ static int kirkwood_cpuidle_probe(struct platform_device *pdev)
 	struct resource *res;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res = NULL)
-		return -EINVAL;
-
 	ddr_operation_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(ddr_operation_base))
 		return PTR_ERR(ddr_operation_base);
#18 lore raw

Re: [PATCH 8/29] drivers/cpuidle/cpuidle-kirkwood.c: simplify use of devm_ioremap_resource

Quoted 23 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

Quoted 1 line

Queued up for 3.12.

Thanks,
Rafael

Quoted 19 lines
---
 drivers/cpuidle/cpuidle-kirkwood.c |    3 ---
 1 file changed, 3 deletions(-)
drivers/cpuidle/cpuidle-kirkwood.c +0 -3
index 521b0a7..2237135 100644
@@ -60,9 +60,6 @@ static int kirkwood_cpuidle_probe(struct platform_device *pdev)
 	struct resource *res;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL)
-		return -EINVAL;
-
 	ddr_operation_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(ddr_operation_base))
 		return PTR_ERR(ddr_operation_base);
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#19 lore raw

PATCH 9/29 drivers/char/hw_random/tx4939-rng.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/char/hw_random/tx4939-rng.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/char/hw_random/tx4939-rng.c +1 -3
index 00593c8..09c5fbe 100644
@@ -110,12 +110,10 @@ static int __init tx4939_rng_probe(struct platform_device *dev)
 	struct resource *r;
 	int i;
 
-	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	if (!r)
-		return -EBUSY;
 	rngdev = devm_kzalloc(&dev->dev, sizeof(*rngdev), GFP_KERNEL);
 	if (!rngdev)
 		return -ENOMEM;
+	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	rngdev->base = devm_ioremap_resource(&dev->dev, r);
 	if (IS_ERR(rngdev->base))
 		return PTR_ERR(rngdev->base);
#20 lore raw

Re: [PATCH 9/29] drivers/char/hw_random/tx4939-rng.c: simplify use of devm_ioremap_resource

Quoted 26 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

Quoted 1 line

Patch applied. Thanks!

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#21 lore raw

PATCH 10/29 drivers/watchdog/nuc900_wdt.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/watchdog/nuc900_wdt.c |    5 -----
 1 file changed, 5 deletions(-)
drivers/watchdog/nuc900_wdt.c +0 -5
index e2b6d2c..b15b6ef 100644
@@ -256,11 +256,6 @@ static int nuc900wdt_probe(struct platform_device *pdev)
 	spin_lock_init(&nuc900_wdt->wdt_lock);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res = NULL) {
-		dev_err(&pdev->dev, "no memory resource specified\n");
-		return -ENOENT;
-	}
-
 	nuc900_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(nuc900_wdt->wdt_base))
 		return PTR_ERR(nuc900_wdt->wdt_base);
maintainer Reviewed-by on v1 10/29
#22 lore raw

Re: [PATCH 10/29] drivers/watchdog/nuc900_wdt.c: simplify use of devm_ioremap_resource

Quoted 21 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
   ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) }
   ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
   e = devm_ioremap_resource(e1, res);
Quoted 4 lines

// </smpl>

Acked-by
#23 lore raw

Re: [PATCH 10/29] drivers/watchdog/nuc900_wdt.c: simplify use of devm_ioremap_resource

2013/8/15 Guenter Roeck <[email protected]>:

Quoted 25 lines · Julia Lawall
Quoted 24 lines

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
   ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) }
   ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
   e = devm_ioremap_resource(e1, res);

// </smpl>

Quoted 3 lines
Quoted 2 lines

Thanks for your patch.

Quoted 2 lines
Signature · 2 lines
Wan ZongShun.
www.mcuos.com
#24 lore raw

PATCH 11/29 marvell-ccic/mmp-driver.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/media/platform/marvell-ccic/mmp-driver.c |    8 --------
 1 file changed, 8 deletions(-)
drivers/media/platform/marvell-ccic/mmp-driver.c +0 -8
index f06daa4..b5a19af 100644
@@ -396,10 +396,6 @@ static int mmpcam_probe(struct platform_device *pdev)
 	 * Get our I/O memory.
 	 */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res = NULL) {
-		dev_err(&pdev->dev, "no iomem resource!\n");
-		return -ENODEV;
-	}
 	mcam->regs = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(mcam->regs))
 		return PTR_ERR(mcam->regs);
@@ -409,10 +405,6 @@ static int mmpcam_probe(struct platform_device *pdev)
 	 * should really be managed outside of this driver?
 	 */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	if (res = NULL) {
-		dev_err(&pdev->dev, "no power resource!\n");
-		return -ENODEV;
-	}
 	cam->power_regs = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(cam->power_regs))
 		return PTR_ERR(cam->power_regs);
#25 lore raw

PATCH 12/29 sound/soc/samsung/ac97.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 sound/soc/samsung/ac97.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
sound/soc/samsung/ac97.c +1 -6
index 2dd623f..c732df9 100644
@@ -404,18 +404,13 @@ static int s3c_ac97_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem_res) {
-		dev_err(&pdev->dev, "Unable to get register resource\n");
-		return -ENXIO;
-	}
-
 	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!irq_res) {
 		dev_err(&pdev->dev, "AC97 IRQ not provided!\n");
 		return -ENXIO;
 	}
 
+	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	s3c_ac97.regs = devm_ioremap_resource(&pdev->dev, mem_res);
 	if (IS_ERR(s3c_ac97.regs))
 		return PTR_ERR(s3c_ac97.regs);
maintainer Applied
#26 lore raw

Re: [PATCH 12/29] sound/soc/samsung/ac97.c: simplify use of devm_ioremap_resource

Quoted 4 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Applied, thanks.

#27 lore raw

PATCH 13/29 drivers/input/keyboard/tegra-kbc.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/input/keyboard/tegra-kbc.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/input/keyboard/tegra-kbc.c +1 -6
index b46142f..9cd20e6 100644
@@ -638,12 +638,6 @@ static int tegra_kbc_probe(struct platform_device *pdev)
 	if (!tegra_kbc_check_pin_cfg(kbc, &num_rows))
 		return -EINVAL;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "failed to get I/O memory\n");
-		return -ENXIO;
-	}
-
 	kbc->irq = platform_get_irq(pdev, 0);
 	if (kbc->irq < 0) {
 		dev_err(&pdev->dev, "failed to get keyboard IRQ\n");
@@ -658,6 +652,7 @@ static int tegra_kbc_probe(struct platform_device *pdev)
 
 	setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc);
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	kbc->mmio = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(kbc->mmio))
 		return PTR_ERR(kbc->mmio);
#28 lore raw

PATCH 14/29 drivers/scsi/ufs/ufshcd-pltfrm.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A debugging statement in the error-handling code is removed as well, as it doesn't seem to give any more information than devm_ioremap_resource already gives.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/scsi/ufs/ufshcd-pltfrm.c |    7 -------
 1 file changed, 7 deletions(-)
drivers/scsi/ufs/ufshcd-pltfrm.c +0 -7
index c42db40..ea699b9 100644
@@ -102,15 +102,8 @@ static int ufshcd_pltfrm_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 
 	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem_res) {
-		dev_err(dev, "Memory resource not available\n");
-		err = -ENODEV;
-		goto out;
-	}
-
 	mmio_base = devm_ioremap_resource(dev, mem_res);
 	if (IS_ERR(mmio_base)) {
-		dev_err(dev, "memory map failed\n");
 		err = PTR_ERR(mmio_base);
 		goto out;
 	}
#29 lore raw

Re: [PATCH 14/29] drivers/scsi/ufs/ufshcd-pltfrm.c: simplify use of devm_ioremap_resource

Quoted 45 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A debugging statement in the error-handling code is removed as well, as it doesn't seem to give any more information than devm_ioremap_resource already gives.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/scsi/ufs/ufshcd-pltfrm.c |    7 -------
 1 file changed, 7 deletions(-)
drivers/scsi/ufs/ufshcd-pltfrm.c +0 -2
index c42db40..ea699b9 100644
@@ -102,15 +102,8 @@ static int ufshcd_pltfrm_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
 
        mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!mem_res) {
-               dev_err(dev, "Memory resource not available\n");

drivers/scsi/ufs/ufshcd-pltfrm.c static int ufshcd_pltfrm_probe(struct platform_device *pdev) · line 109

Quoted 10 lines
drivers/scsi/ufs/ufshcd-pltfrm.c +0 -5
-               err = -ENODEV;
-               goto out;
-       }
-
        mmio_base = devm_ioremap_resource(dev, mem_res);
        if (IS_ERR(mmio_base)) {
-               dev_err(dev, "memory map failed\n");
                err = PTR_ERR(mmio_base);
                goto out;
        }

Redundant error message and error handling have been removed in the patches submitted by 'Wei Yongjun' and 'Wolfram Sang'.

1. http://www.spinics.net/lists/linux-scsi/msg67557.html
2. http://www.spinics.net/lists/linux-scsi/msg67558.html

thanks anyway... :-)

Signature · 1 line
~Santosh
#30 lore raw

PATCH 15/29 ASoC: tegra20-ac97: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 sound/soc/tegra/tegra20_ac97.c |    6 ------
 1 file changed, 6 deletions(-)
sound/soc/tegra/tegra20_ac97.c +0 -6
index 00106b5..ae27bcd 100644
@@ -334,12 +334,6 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
 	}
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem) {
-		dev_err(&pdev->dev, "No memory resource\n");
-		ret = -ENODEV;
-		goto err_clk_put;
-	}
-
 	regs = devm_ioremap_resource(&pdev->dev, mem);
 	if (IS_ERR(regs)) {
 		ret = PTR_ERR(regs);
#31 lore raw

PATCH 16/29 amba: tegra-ahb: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/amba/tegra-ahb.c |    2 --
 1 file changed, 2 deletions(-)
drivers/amba/tegra-ahb.c +0 -2
index 1f44e56..558a239 100644
@@ -256,8 +256,6 @@ static int tegra_ahb_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENODEV;
 	ahb->regs = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(ahb->regs))
 		return PTR_ERR(ahb->regs);
#32 lore raw

PATCH 17/29 drivers/rtc: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/rtc/rtc-ds1216.c |    4 +---
 drivers/rtc/rtc-ds1286.c |    4 +---
 drivers/rtc/rtc-spear.c  |    7 +------
 3 files changed, 3 insertions(+), 12 deletions(-)
drivers/rtc/rtc-ds1216.c +1 -3
index 9c04fd2..c948bd3 100644
@@ -144,15 +144,13 @@ static int __init ds1216_rtc_probe(struct platform_device *pdev)
 	struct ds1216_priv *priv;
 	u8 dummy[8];
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENODEV;
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
 	platform_set_drvdata(pdev, priv);
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	priv->ioaddr = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(priv->ioaddr))
 		return PTR_ERR(priv->ioaddr);
drivers/rtc/rtc-ds1286.c +1 -3
index 50e109b..14c4b24 100644
@@ -332,13 +332,11 @@ static int ds1286_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct ds1286_priv *priv;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENODEV;
 	priv = devm_kzalloc(&pdev->dev, sizeof(struct ds1286_priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	priv->rtcregs = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(priv->rtcregs))
 		return PTR_ERR(priv->rtcregs);
drivers/rtc/rtc-spear.c +1 -6
index c492cf0..6470641 100644
@@ -358,12 +358,6 @@ static int spear_rtc_probe(struct platform_device *pdev)
 	int status = 0;
 	int irq;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "no resource defined\n");
-		return -EBUSY;
-	}
-
 	config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
 	if (!config) {
 		dev_err(&pdev->dev, "out of memory\n");
@@ -385,6 +379,7 @@ static int spear_rtc_probe(struct platform_device *pdev)
 		return status;
 	}
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	config->ioaddr = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(config->ioaddr))
 		return PTR_ERR(config->ioaddr);
Acked-by on v1 17/29
#33 lore raw

Re: [PATCH 17/29] drivers/rtc: simplify use of devm_ioremap_resource

Quoted 26 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

Quoted 6 lines

---

 drivers/rtc/rtc-spear.c  |    7 +------
 3 files changed, 3 insertions(+), 12 deletions(-)

For SPEAr:

Quoted 25 lines
drivers/rtc/rtc-spear.c +1 -6
index c492cf0..6470641 100644
@@ -358,12 +358,6 @@ static int spear_rtc_probe(struct platform_device *pdev)
        int status = 0;
        int irq;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res) {
-               dev_err(&pdev->dev, "no resource defined\n");
-               return -EBUSY;
-       }
-
        config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
        if (!config) {
                dev_err(&pdev->dev, "out of memory\n");
@@ -385,6 +379,7 @@ static int spear_rtc_probe(struct platform_device *pdev)
                return status;
        }
 
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        config->ioaddr = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(config->ioaddr))
                return PTR_ERR(config->ioaddr);
#34 lore raw

Re: [17/29] drivers/rtc: simplify use of devm_ioremap_resource

In reply to Julia Lawall
Quoted 26 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

Quoted 1 line

Rebased and applied, thanks.

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#35 lore raw

PATCH 18/29 tty: ar933x_uart: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/tty/serial/ar933x_uart.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/tty/serial/ar933x_uart.c +1 -6
index 3f5517f..a712a3f 100644
@@ -640,12 +640,6 @@ static int ar933x_uart_probe(struct platform_device *pdev)
 	if (id > CONFIG_SERIAL_AR933X_NR_UARTS)
 		return -EINVAL;
 
-	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem_res) {
-		dev_err(&pdev->dev, "no MEM resource\n");
-		return -EINVAL;
-	}
-
 	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!irq_res) {
 		dev_err(&pdev->dev, "no IRQ resource\n");
@@ -659,6 +653,7 @@ static int ar933x_uart_probe(struct platform_device *pdev)
 
 	port = &up->port;
 
+	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	port->membase = devm_ioremap_resource(&pdev->dev, mem_res);
 	if (IS_ERR(port->membase))
 		return PTR_ERR(port->membase);
#36 lore raw

PATCH 19/29 watchdog: ts72xx_wdt: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/watchdog/ts72xx_wdt.c |   10 ----------
 1 file changed, 10 deletions(-)
drivers/watchdog/ts72xx_wdt.c +0 -10
index 4da59b4..42913f1 100644
@@ -403,21 +403,11 @@ static int ts72xx_wdt_probe(struct platform_device *pdev)
 	}
 
 	r1 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r1) {
-		dev_err(&pdev->dev, "failed to get memory resource\n");
-		return -ENODEV;
-	}
-
 	wdt->control_reg = devm_ioremap_resource(&pdev->dev, r1);
 	if (IS_ERR(wdt->control_reg))
 		return PTR_ERR(wdt->control_reg);
 
 	r2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	if (!r2) {
-		dev_err(&pdev->dev, "failed to get memory resource\n");
-		return -ENODEV;
-	}
-
 	wdt->feed_reg = devm_ioremap_resource(&pdev->dev, r2);
 	if (IS_ERR(wdt->feed_reg))
 		return PTR_ERR(wdt->feed_reg);
maintainer Reviewed-by on v1 19/29
#37 lore raw

Re: [PATCH 19/29] watchdog: ts72xx_wdt: simplify use of devm_ioremap_resource

Quoted 21 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
   ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) }
   ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
   e = devm_ioremap_resource(e1, res);
Quoted 4 lines

// </smpl>

#38 lore raw

PATCH 20/29 watchdog: s3c2410_wdt: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/watchdog/s3c2410_wdt.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/watchdog/s3c2410_wdt.c +1 -6
index 6a22cf5..9fbc993 100644
@@ -325,12 +325,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
 	dev = &pdev->dev;
 	wdt_dev = &pdev->dev;
 
-	wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (wdt_mem = NULL) {
-		dev_err(dev, "no memory resource specified\n");
-		return -ENOENT;
-	}
-
 	wdt_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (wdt_irq = NULL) {
 		dev_err(dev, "no irq resource specified\n");
@@ -339,6 +333,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
 	}
 
 	/* get the memory region for the watchdog timer */
+	wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	wdt_base = devm_ioremap_resource(dev, wdt_mem);
 	if (IS_ERR(wdt_base)) {
 		ret = PTR_ERR(wdt_base);
maintainer Reviewed-by on v1 20/29
#39 lore raw

Re: [PATCH 20/29] watchdog: s3c2410_wdt: simplify use of devm_ioremap_resource

Quoted 24 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
   ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) }
   ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
   e = devm_ioremap_resource(e1, res);
Quoted 4 lines

// </smpl>

#40 lore raw

PATCH 21/29 pwm: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/pwm/pwm-lpc32xx.c     |    3 ---
 drivers/pwm/pwm-renesas-tpu.c |    5 -----
 drivers/pwm/pwm-spear.c       |    7 +------
 3 files changed, 1 insertion(+), 14 deletions(-)
drivers/pwm/pwm-lpc32xx.c +0 -3
index efb6c7b..efac99e 100644
@@ -124,9 +124,6 @@ static int lpc32xx_pwm_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -EINVAL;
-
 	lpc32xx->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(lpc32xx->base))
 		return PTR_ERR(lpc32xx->base);
drivers/pwm/pwm-renesas-tpu.c +0 -5
index 2600892..444d589 100644
@@ -404,11 +404,6 @@ static int tpu_probe(struct platform_device *pdev)
 
 	/* Map memory, get clock and pin control. */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "failed to get I/O memory\n");
-		return -ENXIO;
-	}
-
 	tpu->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(tpu->base))
 		return PTR_ERR(tpu->base);
drivers/pwm/pwm-spear.c +1 -6
index a54d214..8ad26b8 100644
@@ -178,18 +178,13 @@ static int spear_pwm_probe(struct platform_device *pdev)
 	int ret;
 	u32 val;
 
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r) {
-		dev_err(&pdev->dev, "no memory resources defined\n");
-		return -ENODEV;
-	}
-
 	pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
 	if (!pc) {
 		dev_err(&pdev->dev, "failed to allocate memory\n");
 		return -ENOMEM;
 	}
 
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	pc->mmio_base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(pc->mmio_base))
 		return PTR_ERR(pc->mmio_base);
Acked-by on v1 21/29
#41 lore raw

Re: [PATCH 21/29] pwm: simplify use of devm_ioremap_resource

Quoted 26 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

Quoted 5 lines

---

 drivers/pwm/pwm-spear.c       |    7 +------

For SPEAr:

Quoted 30 lines
drivers/pwm/pwm-spear.c +1 -7
index a54d214..8ad26b8 100644
@@ -178,18 +178,13 @@ static int spear_pwm_probe(struct platform_device *pdev)
        int ret;
        u32 val;
 
-       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!r) {
-               dev_err(&pdev->dev, "no memory resources defined\n");
-               return -ENODEV;
-       }
-
        pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
        if (!pc) {
                dev_err(&pdev->dev, "failed to allocate memory\n");
                return -ENOMEM;
        }
 
+       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        pc->mmio_base = devm_ioremap_resource(&pdev->dev, r);
        if (IS_ERR(pc->mmio_base))
                return PTR_ERR(pc->mmio_base);
 
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#42 lore raw

Re: [PATCH 21/29] pwm: simplify use of devm_ioremap_resource

In reply to Julia Lawall
Quoted 26 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

Quoted 7 lines
---
 drivers/pwm/pwm-lpc32xx.c     |    3 ---
 drivers/pwm/pwm-renesas-tpu.c |    5 -----
 drivers/pwm/pwm-spear.c       |    7 +------
 3 files changed, 1 insertion(+), 14 deletions(-)

Applied, thanks.

Thierry

#43 lore raw

PATCH 22/29 host1x/{dev.c,drm/hdmi.c}: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/gpu/host1x/dev.c      |    7 +------
 drivers/gpu/host1x/drm/hdmi.c |    3 ---
 2 files changed, 1 insertion(+), 9 deletions(-)
drivers/gpu/host1x/dev.c +1 -6
index 28e28a2..e615edd 100644
@@ -98,12 +98,6 @@ static int host1x_probe(struct platform_device *pdev)
 	if (!id)
 		return -EINVAL;
 
-	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!regs) {
-		dev_err(&pdev->dev, "failed to get registers\n");
-		return -ENXIO;
-	}
-
 	syncpt_irq = platform_get_irq(pdev, 0);
 	if (syncpt_irq < 0) {
 		dev_err(&pdev->dev, "failed to get IRQ\n");
@@ -120,6 +114,7 @@ static int host1x_probe(struct platform_device *pdev)
 	/* set common host1x device data */
 	platform_set_drvdata(pdev, host);
 
+	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	host->regs = devm_ioremap_resource(&pdev->dev, regs);
 	if (IS_ERR(host->regs))
 		return PTR_ERR(host->regs);
drivers/gpu/host1x/drm/hdmi.c +0 -3
index 01097da..9ffece6 100644
@@ -1248,9 +1248,6 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
 		return err;
 
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!regs)
-		return -ENXIO;
-
 	hdmi->regs = devm_ioremap_resource(&pdev->dev, regs);
 	if (IS_ERR(hdmi->regs))
 		return PTR_ERR(hdmi->regs);
#44 lore raw

PATCH 23/29 drivers/i2c/busses/i2c-ocores.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/i2c/busses/i2c-ocores.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/i2c/busses/i2c-ocores.c +1 -4
index 0e1f824..e686e2c 100644
@@ -353,10 +353,6 @@ static int ocores_i2c_probe(struct platform_device *pdev)
 	int ret;
 	int i;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENODEV;
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
@@ -365,6 +361,7 @@ static int ocores_i2c_probe(struct platform_device *pdev)
 	if (!i2c)
 		return -ENOMEM;
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	i2c->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(i2c->base))
 		return PTR_ERR(i2c->base);
Applied
#45 lore raw

Re: [PATCH 23/29] drivers/i2c/busses/i2c-ocores.c: simplify use of devm_ioremap_resource

Quoted 26 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

Quoted 1 line

Applied to for-next, thanks!

#46 lore raw

PATCH 24/29 drivers/remoteproc/da8xx_remoteproc.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/remoteproc/da8xx_remoteproc.c |   14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/remoteproc/da8xx_remoteproc.c +1 -13
index 129f7b9..bb41ee0 100644
@@ -201,23 +201,11 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
 	}
 
 	bootreg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!bootreg_res) {
-		dev_err(dev,
-			"platform_get_resource(IORESOURCE_MEM, 0): NULL\n");
-		return -EADDRNOTAVAIL;
-	}
-
-	chipsig_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	if (!chipsig_res) {
-		dev_err(dev,
-			"platform_get_resource(IORESOURCE_MEM, 1): NULL\n");
-		return -EADDRNOTAVAIL;
-	}
-
 	bootreg = devm_ioremap_resource(dev, bootreg_res);
 	if (IS_ERR(bootreg))
 		return PTR_ERR(bootreg);
 
+	chipsig_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 	chipsig = devm_ioremap_resource(dev, chipsig_res);
 	if (IS_ERR(chipsig))
 		return PTR_ERR(chipsig);
#47 lore raw

Re: [PATCH 24/29] drivers/remoteproc/da8xx_remoteproc.c: simplify use of devm_ioremap_resource

Quoted 8 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

...

Quoted 2 lines

Applied and pushed to remoteproc-next, thanks!

#48 lore raw

PATCH 25/29 drivers/spi/spi-sirf.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/spi/spi-sirf.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/spi/spi-sirf.c +1 -6
index 62c92c3..546fae2 100644
@@ -588,12 +588,6 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, master);
 	sspi = spi_master_get_devdata(master);
 
-	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem_res) {
-		dev_err(&pdev->dev, "Unable to get IO resource\n");
-		ret = -ENODEV;
-		goto free_master;
-	}
 	master->num_chipselect = num_cs;
 
 	for (i = 0; i < master->num_chipselect; i++) {
@@ -620,6 +614,7 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
 		}
 	}
 
+	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	sspi->base = devm_ioremap_resource(&pdev->dev, mem_res);
 	if (IS_ERR(sspi->base)) {
 		ret = PTR_ERR(sspi->base);
Acked-by on v1 25/29
#49 lore raw

RE: [PATCH 25/29] drivers/spi/spi-sirf.c: simplify use of devm_ioremap_resource

PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBKdWxpYSBM YXdhbGwgW21haWx0bzpKdWxpYS5MYXdhbGxAbGlwNi5mcl0NCj4gU2VudDog V2VkbmVzZGF5LCBBdWd1c3QgMTQsIDIwMTMgNToxMSBQTQ0KPiBUbzogQmFy cnkgU29uZw0KPiBDYzoga2VybmVsLWphbml0b3JzQHZnZXIua2VybmVsLm9y ZzsgTWFyayBCcm93bjsNCj4gbGludXgtYXJtLWtlcm5lbEBsaXN0cy5pbmZy YWRlYWQub3JnOyBsaW51eC1zcGlAdmdlci5rZXJuZWwub3JnOw0KPiBsaW51 eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnDQo+IFN1YmplY3Q6IFtQQVRDSCAy NS8yOV0gZHJpdmVycy9zcGkvc3BpLXNpcmYuYzogc2ltcGxpZnkgdXNlIG9m DQo+IGRldm1faW9yZW1hcF9yZXNvdXJjZQ0KPiANCj4gRnJvbTogSnVsaWEg TGF3YWxsIDxKdWxpYS5MYXdhbGxAbGlwNi5mcj4NCj4gDQo+IFJlbW92ZSB1 bm5lZWRlZCBlcnJvciBoYW5kbGluZyBvbiB0aGUgcmVzdWx0IG9mIGEgY2Fs bCB0bw0KPiBwbGF0Zm9ybV9nZXRfcmVzb3VyY2Ugd2hlbiB0aGUgdmFsdWUg aXMgcGFzc2VkIHRvIGRldm1faW9yZW1hcF9yZXNvdXJjZS4NCj4gDQo+IE1v dmUgdGhlIGNhbGwgdG8gcGxhdGZvcm1fZ2V0X3Jlc291cmNlIGFkamFjZW50 IHRvIHRoZSBjYWxsIHRvDQo+IGRldm1faW9yZW1hcF9yZXNvdXJjZSB0byBt YWtlIHRoZSBjb25uZWN0aW9uIGJldHdlZW4gdGhlbSBtb3JlIGNsZWFyLg0K PiANCj4gQSBzaW1wbGlmaWVkIHZlcnNpb24gb2YgdGhlIHNlbWFudGljIHBh dGNoIHRoYXQgbWFrZXMgdGhpcyBjaGFuZ2UgaXMgYXMNCj4gZm9sbG93czog KGh0dHA6Ly9jb2NjaW5lbGxlLmxpcDYuZnIvKQ0KPiANCj4gLy8gPHNtcGw+ DQo+IEBADQo+IGV4cHJlc3Npb24gcGRldixyZXMsbixlLGUxOw0KPiBleHBy ZXNzaW9uIHJldCAhPSAwOw0KPiBpZGVudGlmaWVyIGw7DQo+IEBADQo+IA0K PiAtIHJlcyA9IHBsYXRmb3JtX2dldF9yZXNvdXJjZShwZGV2LCBJT1JFU09V UkNFX01FTSwgbik7DQo+ICAgLi4uIHdoZW4gIT0gcmVzDQo+IC0gaWYgKHJl cyA9PSBOVUxMKSB7IC4uLiBcKGdvdG8gbDtcfHJldHVybiByZXQ7XCkgfQ0K PiAgIC4uLiB3aGVuICE9IHJlcw0KPiArIHJlcyA9IHBsYXRmb3JtX2dldF9y ZXNvdXJjZShwZGV2LCBJT1JFU09VUkNFX01FTSwgbik7DQo+ICAgZSA9IGRl dm1faW9yZW1hcF9yZXNvdXJjZShlMSwgcmVzKTsNCj4gLy8gPC9zbXBsPg0K PiANCj4gU2lnbmVkLW9mZi1ieTogSnVsaWEgTGF3YWxsIDxKdWxpYS5MYXdh bGxAbGlwNi5mcj4NCg0KQWNrZWQtYnk6IEJhcnJ5IFNvbmcgPEJhb2h1YS5T b25nQGNzci5jb20+DQoNCj4gDQo+IC0tLQ0KPiAgZHJpdmVycy9zcGkvc3Bp LXNpcmYuYyB8ICAgIDcgKy0tLS0tLQ0KPiAgMSBmaWxlIGNoYW5nZWQsIDEg aW5zZXJ0aW9uKCspLCA2IGRlbGV0aW9ucygtKQ0KIA0KCgpNZW1iZXIgb2Yg dGhlIENTUiBwbGMgZ3JvdXAgb2YgY29tcGFuaWVzLiBDU1IgcGxjIHJlZ2lz dGVyZWQgaW4gRW5nbGFuZCBhbmQgV2FsZXMsIHJlZ2lzdGVyZWQgbnVtYmVy IDQxODczNDYsIHJlZ2lzdGVyZWQgb2ZmaWNlIENodXJjaGlsbCBIb3VzZSwg Q2FtYnJpZGdlIEJ1c2luZXNzIFBhcmssIENvd2xleSBSb2FkLCBDYW1icmlk Z2UsIENCNCAwV1osIFVuaXRlZCBLaW5nZG9tCk1vcmUgaW5mb3JtYXRpb24g Y2FuIGJlIGZvdW5kIGF0IHd3dy5jc3IuY29tLiBGb2xsb3cgQ1NSIG9uIFR3 aXR0ZXIgYXQgaHR0cDovL3R3aXR0ZXIuY29tL0NTUl9QTEMgYW5kIHJlYWQg b3VyIGJsb2cgYXQgd3d3LmNzci5jb20vYmxvZwo

maintainer Applied
#50 lore raw

Re: [PATCH 25/29] drivers/spi/spi-sirf.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall
Quoted 4 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Applied, thanks.

#51 lore raw

PATCH 26/29 drivers/media/platform/coda.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/media/platform/coda.c |    5 -----
 1 file changed, 5 deletions(-)
drivers/media/platform/coda.c +0 -5
index 66db0df..1a2192f 100644
@@ -3122,11 +3122,6 @@ static int coda_probe(struct platform_device *pdev)
 
 	/* Get  memory for physical registers */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res = NULL) {
-		dev_err(&pdev->dev, "failed to get memory region resource\n");
-		return -ENOENT;
-	}
-
 	dev->regs_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(dev->regs_base))
 		return PTR_ERR(dev->regs_base);
#52 lore raw

PATCH 27/29 drivers/ata/sata_rcar.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/ata/sata_rcar.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/ata/sata_rcar.c +1 -4
index 8108eb0..c2d95e9 100644
@@ -778,10 +778,6 @@ static int sata_rcar_probe(struct platform_device *pdev)
 	int irq;
 	int ret = 0;
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (mem = NULL)
-		return -EINVAL;
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq <= 0)
 		return -EINVAL;
@@ -807,6 +803,7 @@ static int sata_rcar_probe(struct platform_device *pdev)
 
 	host->private_data = priv;
 
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	priv->base = devm_ioremap_resource(&pdev->dev, mem);
 	if (IS_ERR(priv->base)) {
 		ret = PTR_ERR(priv->base);
#53 lore raw

PATCH 27/29 drivers/ata/sata_rcar.c: simplify use of devm_ioremap_resource

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/input/keyboard/imx_keypad.c     |    7 +------
 drivers/input/keyboard/nspire-keypad.c  |    7 +------
 drivers/input/keyboard/spear-keyboard.c |    7 +------
 drivers/input/serio/arc_ps2.c           |    7 +------
 drivers/input/serio/olpc_apsp.c         |    3 ---
 5 files changed, 4 insertions(+), 27 deletions(-)
drivers/input/keyboard/imx_keypad.c +1 -6
index 03c8cc5..328cfc1 100644
@@ -442,12 +442,6 @@ static int imx_keypad_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res = NULL) {
-		dev_err(&pdev->dev, "no I/O memory defined in platform data\n");
-		return -EINVAL;
-	}
-
 	input_dev = devm_input_allocate_device(&pdev->dev);
 	if (!input_dev) {
 		dev_err(&pdev->dev, "failed to allocate the input device\n");
@@ -468,6 +462,7 @@ static int imx_keypad_probe(struct platform_device *pdev)
 	setup_timer(&keypad->check_matrix_timer,
 		    imx_keypad_check_for_events, (unsigned long) keypad);
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(keypad->mmio_base))
 		return PTR_ERR(keypad->mmio_base);
drivers/input/keyboard/nspire-keypad.c +1 -6
index 20d872d..b3e3eda 100644
@@ -171,12 +171,6 @@ static int nspire_keypad_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "missing platform resources\n");
-		return -EINVAL;
-	}
-
 	keypad = devm_kzalloc(&pdev->dev, sizeof(struct nspire_keypad),
 			      GFP_KERNEL);
 	if (!keypad) {
@@ -208,6 +202,7 @@ static int nspire_keypad_probe(struct platform_device *pdev)
 		return PTR_ERR(keypad->clk);
 	}
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	keypad->reg_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(keypad->reg_base))
 		return PTR_ERR(keypad->reg_base);
drivers/input/keyboard/spear-keyboard.c +1 -6
index 7111124..85ff530 100644
@@ -191,12 +191,6 @@ static int spear_kbd_probe(struct platform_device *pdev)
 	int irq;
 	int error;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "no keyboard resource defined\n");
-		return -EBUSY;
-	}
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "not able to get irq for the device\n");
@@ -228,6 +222,7 @@ static int spear_kbd_probe(struct platform_device *pdev)
 		kbd->suspended_rate = pdata->suspended_rate;
 	}
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	kbd->io_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(kbd->io_base))
 		return PTR_ERR(kbd->io_base);
drivers/input/serio/arc_ps2.c +1 -6
index 3fb7727..8024a6d 100644
@@ -189,12 +189,6 @@ static int arc_ps2_probe(struct platform_device *pdev)
 	int irq;
 	int error, id, i;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "no IO memory defined\n");
-		return -EINVAL;
-	}
-
 	irq = platform_get_irq_byname(pdev, "arc_ps2_irq");
 	if (irq < 0) {
 		dev_err(&pdev->dev, "no IRQ defined\n");
@@ -208,6 +202,7 @@ static int arc_ps2_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	arc_ps2->addr = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(arc_ps2->addr))
 		return PTR_ERR(arc_ps2->addr);
drivers/input/serio/olpc_apsp.c +0 -3
index 818aa46..51b1d40 100644
@@ -183,9 +183,6 @@ static int olpc_apsp_probe(struct platform_device *pdev)
 
 	np = pdev->dev.of_node;
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENOENT;
-
 	priv->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(priv->base)) {
 		dev_err(&pdev->dev, "Failed to map WTM registers\n");
Applied
#54 lore raw

Re: [PATCH 27/29] drivers/ata/sata_rcar.c: simplify use of devm_ioremap_resource

In reply to Julia Lawall
Quoted 26 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

Quoted 1 line

Applied to libata/for-3.12.

Thanks.

Signature · 1 line
tejun
#55 lore raw

PATCH 29/29 usb: dwc3: omap: simplify use of devm_ioremap_resource

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res
- if (res = NULL) { ... \(goto l;\|return ret;\) } ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res);
// </smpl>

---
 drivers/usb/dwc3/dwc3-omap.c |    5 -----
 1 file changed, 5 deletions(-)
drivers/usb/dwc3/dwc3-omap.c +0 -5
index 7f7ea62..cbcd972 100644
@@ -432,11 +432,6 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(dev, "missing memory base resource\n");
-		return -EINVAL;
-	}
-
 	base = devm_ioremap_resource(dev, res);
 	if (IS_ERR(base))
 		return PTR_ERR(base);