From: Julia Lawall <hidden> Date: 2013-08-14 09:18:54
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>
From: Julia Lawall <hidden> Date: 2013-08-14 09:11:39
From: Julia Lawall <redacted>
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>
Signed-off-by: Julia Lawall <redacted>
---
drivers/pinctrl/pinctrl-nomadik.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
From: Julia Lawall <hidden> Date: 2013-08-14 09:12:28
From: Julia Lawall <redacted>
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>
Signed-off-by: Julia Lawall <redacted>
---
drivers/spi/spi-sirf.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
@@ -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;-gotofree_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);
From: Julia Lawall <hidden> Date: 2013-08-14 09:14:46
From: Julia Lawall <redacted>
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>
Signed-off-by: Julia Lawall <redacted>
---
drivers/watchdog/s3c2410_wdt.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
@@ -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);
From: Julia Lawall <hidden> Date: 2013-08-14 09:18:21
From: Julia Lawall <redacted>
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>
Signed-off-by: Julia Lawall <redacted>
---
sound/soc/samsung/ac97.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
@@ -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))returnPTR_ERR(s3c_ac97.regs);
From: Julia Lawall <hidden> Date: 2013-08-14 09:18:57
From: Julia Lawall <redacted>
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>
Signed-off-by: Julia Lawall <redacted>
---
drivers/watchdog/nuc900_wdt.c | 5 -----
1 file changed, 5 deletions(-)
From: Barry Song <hidden> Date: 2013-08-14 10:20:57
-----Original Message-----
From: Julia Lawall [mailto:Julia.Lawall at lip6.fr]
Sent: Wednesday, August 14, 2013 5:11 PM
To: Barry Song
Cc: kernel-janitors at vger.kernel.org; Mark Brown;
linux-arm-kernel at lists.infradead.org; linux-spi at vger.kernel.org;
linux-kernel at vger.kernel.org
Subject: [PATCH 25/29] drivers/spi/spi-sirf.c: simplify use of
devm_ioremap_resource
From: Julia Lawall <redacted>
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>
Signed-off-by: Julia Lawall <redacted>
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
From: Mark Brown <broonie@kernel.org> Date: 2013-08-14 18:09:34
On Wed, Aug 14, 2013 at 11:11:29AM +0200, Julia Lawall wrote:
From: Julia Lawall <redacted>
Remove unneeded error handling on the result of a call to
platform_get_resource when the value is passed to devm_ioremap_resource.
From: Mark Brown <broonie@kernel.org> Date: 2013-08-14 18:15:36
On Wed, Aug 14, 2013 at 11:11:16AM +0200, Julia Lawall wrote:
From: Julia Lawall <redacted>
Remove unneeded error handling on the result of a call to
platform_get_resource when the value is passed to devm_ioremap_resource.
From: Julia Lawall <redacted>
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>
Signed-off-by: Julia Lawall <redacted>
From: Julia Lawall <redacted>
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>
Signed-off-by: Julia Lawall <redacted>
From: Wan ZongShun <hidden> Date: 2013-08-15 03:29:41
2013/8/15 Guenter Roeck [off-list ref]:
On 08/14/2013 02:11 AM, Julia Lawall wrote:
quoted
From: Julia Lawall <redacted>
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>
Signed-off-by: Julia Lawall <redacted>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Wan Zongshun <redacted>
Thanks for your patch.
On Wed, Aug 14, 2013 at 11:11 AM, Julia Lawall [off-list ref] wrote:
From: Julia Lawall <redacted>
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>
Signed-off-by: Julia Lawall <redacted>