2019-09-18 15:09:22

by Markus Elfring

[permalink] [raw]
Subject: [PATCH] media: platform: Use devm_platform_ioremap_resource() in two functions

From: Markus Elfring <[email protected]>
Date: Wed, 18 Sep 2019 11:20:48 +0200

Simplify these function implementations by using a known wrapper function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 8 +-------
drivers/media/platform/rcar-vin/rcar-core.c | 7 +------
2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 00d090df11bb..944771ee5f5c 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -253,13 +253,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
}

for (i = 0; i < NUM_MAX_VDEC_REG_BASE; i++) {
- res = platform_get_resource(pdev, IORESOURCE_MEM, i);
- if (res == NULL) {
- dev_err(&pdev->dev, "get memory resource failed.");
- ret = -ENXIO;
- goto err_res;
- }
- dev->reg_base[i] = devm_ioremap_resource(&pdev->dev, res);
+ dev->reg_base[i] = devm_platform_ioremap_resource(pdev, i);
if (IS_ERR((__force void *)dev->reg_base[i])) {
ret = PTR_ERR((__force void *)dev->reg_base[i]);
goto err_res;
diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index 6993484ff0f3..334c62805959 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -1282,7 +1282,6 @@ static int rcar_vin_probe(struct platform_device *pdev)
{
const struct soc_device_attribute *attr;
struct rvin_dev *vin;
- struct resource *mem;
int irq, ret;

vin = devm_kzalloc(&pdev->dev, sizeof(*vin), GFP_KERNEL);
@@ -1301,11 +1300,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
if (attr)
vin->info = attr->data;

- mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (mem == NULL)
- return -EINVAL;
-
- vin->base = devm_ioremap_resource(vin->dev, mem);
+ vin->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(vin->base))
return PTR_ERR(vin->base);

--
2.23.0


2019-09-21 18:17:45

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] media: platform: Use devm_platform_ioremap_resource() in two functions

On Wed, Sep 18, 2019 at 11:30 AM Markus Elfring <[email protected]> wrote:
> From: Markus Elfring <[email protected]>
> Date: Wed, 18 Sep 2019 11:20:48 +0200
>
> Simplify these function implementations by using a known wrapper function.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <[email protected]>

Reviewed-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2019-09-24 17:01:28

by Niklas Söderlund

[permalink] [raw]
Subject: Re: [PATCH] media: platform: Use devm_platform_ioremap_resource() in two functions

Hi Markus,

Thanks for your patch.

On 2019-09-18 11:30:30 +0200, Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Wed, 18 Sep 2019 11:20:48 +0200
>
> Simplify these function implementations by using a known wrapper function.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <[email protected]>
> ---
> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 8 +-------
> drivers/media/platform/rcar-vin/rcar-core.c | 7 +------

For rcar-vin:

Tested-by: Niklas S?derlund <[email protected]>

> 2 files changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> index 00d090df11bb..944771ee5f5c 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> @@ -253,13 +253,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
> }
>
> for (i = 0; i < NUM_MAX_VDEC_REG_BASE; i++) {
> - res = platform_get_resource(pdev, IORESOURCE_MEM, i);
> - if (res == NULL) {
> - dev_err(&pdev->dev, "get memory resource failed.");
> - ret = -ENXIO;
> - goto err_res;
> - }
> - dev->reg_base[i] = devm_ioremap_resource(&pdev->dev, res);
> + dev->reg_base[i] = devm_platform_ioremap_resource(pdev, i);
> if (IS_ERR((__force void *)dev->reg_base[i])) {
> ret = PTR_ERR((__force void *)dev->reg_base[i]);
> goto err_res;
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
> index 6993484ff0f3..334c62805959 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -1282,7 +1282,6 @@ static int rcar_vin_probe(struct platform_device *pdev)
> {
> const struct soc_device_attribute *attr;
> struct rvin_dev *vin;
> - struct resource *mem;
> int irq, ret;
>
> vin = devm_kzalloc(&pdev->dev, sizeof(*vin), GFP_KERNEL);
> @@ -1301,11 +1300,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
> if (attr)
> vin->info = attr->data;
>
> - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (mem == NULL)
> - return -EINVAL;
> -
> - vin->base = devm_ioremap_resource(vin->dev, mem);
> + vin->base = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(vin->base))
> return PTR_ERR(vin->base);
>
> --
> 2.23.0
>

--
Regards,
Niklas S?derlund