* [PATCH 0/29] simplify use of devm_ioremap_resource
@ 2013-08-14 9:11 Julia Lawall
2013-08-14 9:11 ` [PATCH 10/29] drivers/watchdog/nuc900_wdt.c: " Julia Lawall
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Julia Lawall @ 2013-08-14 9:11 UTC (permalink / raw)
To: dri-devel
Cc: kernel-janitors, linux-serial, linux-scsi, alsa-devel,
linux-samsung-soc, linux-watchdog, linux-pm, linux-mtd,
linux-fbdev, linux-kernel, linux-arm-kernel, linux-gpio,
linux-spi, linux-media, linux-input, linux-tegra, rtc-linux,
linux-pwm, linux-i2c, linux-ide, linux-usb, linux-omap
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] 8+ messages in thread* [PATCH 10/29] drivers/watchdog/nuc900_wdt.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 3:17 ` Guenter Roeck
2013-08-14 9:11 ` [PATCH 19/29] watchdog: ts72xx_wdt: " Julia Lawall
2013-08-14 9:11 ` [PATCH 20/29] watchdog: s3c2410_wdt: " Julia Lawall
2 siblings, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2013-08-14 9:11 UTC (permalink / raw)
To: Wan ZongShun
Cc: kernel-janitors, Wim Van Sebroeck, linux-arm-kernel,
linux-watchdog, 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.
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/watchdog/nuc900_wdt.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/watchdog/nuc900_wdt.c b/drivers/watchdog/nuc900_wdt.c
index e2b6d2c..b15b6ef 100644
--- a/drivers/watchdog/nuc900_wdt.c
+++ b/drivers/watchdog/nuc900_wdt.c
@@ -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);
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 10/29] drivers/watchdog/nuc900_wdt.c: simplify use of devm_ioremap_resource
2013-08-14 9:11 ` [PATCH 10/29] drivers/watchdog/nuc900_wdt.c: " Julia Lawall
@ 2013-08-15 3:17 ` Guenter Roeck
2013-08-15 3:29 ` Wan ZongShun
0 siblings, 1 reply; 8+ messages in thread
From: Guenter Roeck @ 2013-08-15 3:17 UTC (permalink / raw)
To: Julia Lawall
Cc: Wan ZongShun, kernel-janitors, Wim Van Sebroeck, linux-arm-kernel,
linux-watchdog, linux-kernel
On 08/14/2013 02:11 AM, 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.
>
> 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>
>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 10/29] drivers/watchdog/nuc900_wdt.c: simplify use of devm_ioremap_resource
2013-08-15 3:17 ` Guenter Roeck
@ 2013-08-15 3:29 ` Wan ZongShun
0 siblings, 0 replies; 8+ messages in thread
From: Wan ZongShun @ 2013-08-15 3:29 UTC (permalink / raw)
To: Guenter Roeck
Cc: Julia Lawall, kernel-janitors, Wim Van Sebroeck, linux-arm-kernel,
linux-watchdog, linux-kernel
2013/8/15 Guenter Roeck <linux@roeck-us.net>:
> On 08/14/2013 02:11 AM, 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.
>>
>> 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>
>>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Wan Zongshun <mcuos.com@gmail.com>
Thanks for your patch.
>
>
--
Wan ZongShun.
www.mcuos.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 19/29] watchdog: ts72xx_wdt: 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 ` [PATCH 10/29] drivers/watchdog/nuc900_wdt.c: " Julia Lawall
@ 2013-08-14 9:11 ` Julia Lawall
2013-08-15 3:18 ` Guenter Roeck
2013-08-14 9:11 ` [PATCH 20/29] watchdog: s3c2410_wdt: " Julia Lawall
2 siblings, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2013-08-14 9:11 UTC (permalink / raw)
To: Wim Van Sebroeck; +Cc: kernel-janitors, linux-watchdog, 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.
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/watchdog/ts72xx_wdt.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/drivers/watchdog/ts72xx_wdt.c b/drivers/watchdog/ts72xx_wdt.c
index 4da59b4..42913f1 100644
--- a/drivers/watchdog/ts72xx_wdt.c
+++ b/drivers/watchdog/ts72xx_wdt.c
@@ -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);
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 19/29] watchdog: ts72xx_wdt: simplify use of devm_ioremap_resource
2013-08-14 9:11 ` [PATCH 19/29] watchdog: ts72xx_wdt: " Julia Lawall
@ 2013-08-15 3:18 ` Guenter Roeck
0 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2013-08-15 3:18 UTC (permalink / raw)
To: Julia Lawall
Cc: Wim Van Sebroeck, kernel-janitors, linux-watchdog, linux-kernel
On 08/14/2013 02:11 AM, 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.
>
> 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>
>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 20/29] watchdog: s3c2410_wdt: 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 ` [PATCH 10/29] drivers/watchdog/nuc900_wdt.c: " Julia Lawall
2013-08-14 9:11 ` [PATCH 19/29] watchdog: ts72xx_wdt: " Julia Lawall
@ 2013-08-14 9:11 ` Julia Lawall
2013-08-15 3:19 ` Guenter Roeck
2 siblings, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2013-08-14 9:11 UTC (permalink / raw)
To: Ben Dooks
Cc: kernel-janitors, Kukjin Kim, Wim Van Sebroeck, linux-arm-kernel,
linux-samsung-soc, linux-watchdog, 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/watchdog/s3c2410_wdt.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index 6a22cf5..9fbc993 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -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);
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 20/29] watchdog: s3c2410_wdt: simplify use of devm_ioremap_resource
2013-08-14 9:11 ` [PATCH 20/29] watchdog: s3c2410_wdt: " Julia Lawall
@ 2013-08-15 3:19 ` Guenter Roeck
0 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2013-08-15 3:19 UTC (permalink / raw)
To: Julia Lawall
Cc: Ben Dooks, kernel-janitors, Kukjin Kim, Wim Van Sebroeck,
linux-arm-kernel, linux-samsung-soc, linux-watchdog, linux-kernel
On 08/14/2013 02:11 AM, 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>
>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-08-15 3:29 UTC | newest]
Thread overview: 8+ 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 10/29] drivers/watchdog/nuc900_wdt.c: " Julia Lawall
2013-08-15 3:17 ` Guenter Roeck
2013-08-15 3:29 ` Wan ZongShun
2013-08-14 9:11 ` [PATCH 19/29] watchdog: ts72xx_wdt: " Julia Lawall
2013-08-15 3:18 ` Guenter Roeck
2013-08-14 9:11 ` [PATCH 20/29] watchdog: s3c2410_wdt: " Julia Lawall
2013-08-15 3:19 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox