* [PATCH 0/29] simplify use of devm_ioremap_resource
@ 2013-08-14 9:11 Julia Lawall
2013-08-14 9:11 ` [PATCH 21/29] pwm: " Julia Lawall
0 siblings, 1 reply; 4+ 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>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 21/29] pwm: 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-14 9:16 ` Viresh Kumar
2013-08-14 9:17 ` Thierry Reding
0 siblings, 2 replies; 4+ messages in thread
From: Julia Lawall @ 2013-08-14 9:11 UTC (permalink / raw)
To: Thierry Reding; +Cc: kernel-janitors, linux-pwm, 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/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(-)
diff --git a/drivers/pwm/pwm-lpc32xx.c b/drivers/pwm/pwm-lpc32xx.c
index efb6c7b..efac99e 100644
--- a/drivers/pwm/pwm-lpc32xx.c
+++ b/drivers/pwm/pwm-lpc32xx.c
@@ -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);
diff --git a/drivers/pwm/pwm-renesas-tpu.c b/drivers/pwm/pwm-renesas-tpu.c
index 2600892..444d589 100644
--- a/drivers/pwm/pwm-renesas-tpu.c
+++ b/drivers/pwm/pwm-renesas-tpu.c
@@ -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);
diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c
index a54d214..8ad26b8 100644
--- a/drivers/pwm/pwm-spear.c
+++ b/drivers/pwm/pwm-spear.c
@@ -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);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 21/29] pwm: simplify use of devm_ioremap_resource
2013-08-14 9:11 ` [PATCH 21/29] pwm: " Julia Lawall
@ 2013-08-14 9:16 ` Viresh Kumar
2013-08-14 9:17 ` Thierry Reding
1 sibling, 0 replies; 4+ messages in thread
From: Viresh Kumar @ 2013-08-14 9:16 UTC (permalink / raw)
To: Julia Lawall
Cc: Thierry Reding, kernel-janitors, linux-pwm,
linux-kernel@vger.kernel.org, spear-devel
On Wed, Aug 14, 2013 at 2:41 PM, Julia Lawall <Julia.Lawall@lip6.fr> 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>
>
> ---
> drivers/pwm/pwm-spear.c | 7 +------
For SPEAr:
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c
> index a54d214..8ad26b8 100644
> --- a/drivers/pwm/pwm-spear.c
> +++ b/drivers/pwm/pwm-spear.c
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 21/29] pwm: simplify use of devm_ioremap_resource
2013-08-14 9:11 ` [PATCH 21/29] pwm: " Julia Lawall
2013-08-14 9:16 ` Viresh Kumar
@ 2013-08-14 9:17 ` Thierry Reding
1 sibling, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2013-08-14 9:17 UTC (permalink / raw)
To: Julia Lawall; +Cc: kernel-janitors, linux-pwm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]
On Wed, Aug 14, 2013 at 11:11:25AM +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>
>
> ---
> 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
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-08-14 9:17 UTC | newest]
Thread overview: 4+ 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 21/29] pwm: " Julia Lawall
2013-08-14 9:16 ` Viresh Kumar
2013-08-14 9:17 ` Thierry Reding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox