* [PATCH 0/29] simplify use of devm_ioremap_resource
@ 2013-08-14 9:11 Julia Lawall
2013-08-14 9:11 ` [PATCH 23/29] drivers/i2c/busses/i2c-ocores.c: " Julia Lawall
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2013-08-14 9:11 UTC (permalink / raw)
To: dri-devel
Cc: alsa-devel, kernel-janitors, linux-fbdev, linux-ide, linux-mtd,
linux-i2c, linux-samsung-soc, linux-scsi, linux-serial,
linux-input, linux-media, linux-pwm, linux-watchdog, rtc-linux,
linux-pm, linux-gpio, linux-tegra, linux-omap, linux-arm-kernel,
linux-usb, linux-kernel, linux-spi
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 23/29] drivers/i2c/busses/i2c-ocores.c: simplify use of devm_ioremap_resource
2013-08-14 9:11 [PATCH 0/29] simplify use of devm_ioremap_resource Julia Lawall
@ 2013-08-14 9:11 ` Julia Lawall
2013-08-15 14:18 ` Wolfram Sang
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2013-08-14 9:11 UTC (permalink / raw)
To: Peter Korsgaard; +Cc: kernel-janitors, Wolfram Sang, linux-i2c, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6.fr>
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 <Julia.Lawall@lip6.fr>
---
drivers/i2c/busses/i2c-ocores.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 0e1f824..e686e2c 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -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);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 23/29] drivers/i2c/busses/i2c-ocores.c: simplify use of devm_ioremap_resource
2013-08-14 9:11 ` [PATCH 23/29] drivers/i2c/busses/i2c-ocores.c: " Julia Lawall
@ 2013-08-15 14:18 ` Wolfram Sang
0 siblings, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2013-08-15 14:18 UTC (permalink / raw)
To: Julia Lawall; +Cc: Peter Korsgaard, kernel-janitors, linux-i2c, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 979 bytes --]
On Wed, Aug 14, 2013 at 11:11:27AM +0200, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> 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 <Julia.Lawall@lip6.fr>
Applied to for-next, thanks!
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-15 14:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-14 9:11 [PATCH 0/29] simplify use of devm_ioremap_resource Julia Lawall
2013-08-14 9:11 ` [PATCH 23/29] drivers/i2c/busses/i2c-ocores.c: " Julia Lawall
2013-08-15 14:18 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).