2021-09-01 06:26:48

by Cai,Huoqing

[permalink] [raw]
Subject: [PATCH] media: rcar_drif: Make use of the helper function devm_platform_ioremap_resource()

Use the devm_platform_ioremap_resource() helper instead of
calling platform_get_resource() and devm_ioremap_resource()
separately

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/media/platform/rcar_drif.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
index a505d991548b..f0a1edb57841 100644
--- a/drivers/media/platform/rcar_drif.c
+++ b/drivers/media/platform/rcar_drif.c
@@ -1376,7 +1376,6 @@ static int rcar_drif_probe(struct platform_device *pdev)
struct rcar_drif_sdr *sdr;
struct device_node *np;
struct rcar_drif *ch;
- struct resource *res;
int ret;

/* Reserve memory for enabled channel */
@@ -1395,8 +1394,7 @@ static int rcar_drif_probe(struct platform_device *pdev)
}

/* Register map */
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- ch->base = devm_ioremap_resource(&pdev->dev, res);
+ ch->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(ch->base))
return PTR_ERR(ch->base);

--
2.25.1


2021-09-01 18:50:14

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH] media: rcar_drif: Make use of the helper function devm_platform_ioremap_resource()

On 01/09/2021 07:55, Cai Huoqing wrote:
> Use the devm_platform_ioremap_resource() helper instead of
> calling platform_get_resource() and devm_ioremap_resource()
> separately
>
> Signed-off-by: Cai Huoqing <[email protected]>
> ---
> drivers/media/platform/rcar_drif.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
> index a505d991548b..f0a1edb57841 100644
> --- a/drivers/media/platform/rcar_drif.c
> +++ b/drivers/media/platform/rcar_drif.c
> @@ -1376,7 +1376,6 @@ static int rcar_drif_probe(struct platform_device *pdev)
> struct rcar_drif_sdr *sdr;
> struct device_node *np;
> struct rcar_drif *ch;
> - struct resource *res;
> int ret;
>
> /* Reserve memory for enabled channel */
> @@ -1395,8 +1394,7 @@ static int rcar_drif_probe(struct platform_device *pdev)
> }
>
> /* Register map */
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - ch->base = devm_ioremap_resource(&pdev->dev, res);
> + ch->base = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(ch->base))
> return PTR_ERR(ch->base);
>
>

Compile error:

drivers/media/platform/rcar_drif.c: In function ‘rcar_drif_probe’:
drivers/media/platform/rcar_drif.c:1401:14: error: ‘res’ undeclared (first use in this function); did you mean ‘ret’?
1401 | ch->start = res->start;
| ^~~
| ret
drivers/media/platform/rcar_drif.c:1401:14: note: each undeclared identifier is reported only once for each function it appears in

Regards,

Hans

2021-09-01 21:52:47

by Kieran Bingham

[permalink] [raw]
Subject: Re: [PATCH] media: rcar_drif: Make use of the helper function devm_platform_ioremap_resource()

On 01/09/2021 09:19, Hans Verkuil wrote:
> On 01/09/2021 07:55, Cai Huoqing wrote:
>> Use the devm_platform_ioremap_resource() helper instead of
>> calling platform_get_resource() and devm_ioremap_resource()
>> separately
>>
>> Signed-off-by: Cai Huoqing <[email protected]>
>> ---
>> drivers/media/platform/rcar_drif.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
>> index a505d991548b..f0a1edb57841 100644
>> --- a/drivers/media/platform/rcar_drif.c
>> +++ b/drivers/media/platform/rcar_drif.c
>> @@ -1376,7 +1376,6 @@ static int rcar_drif_probe(struct platform_device *pdev)
>> struct rcar_drif_sdr *sdr;
>> struct device_node *np;
>> struct rcar_drif *ch;
>> - struct resource *res;
>> int ret;
>>
>> /* Reserve memory for enabled channel */
>> @@ -1395,8 +1394,7 @@ static int rcar_drif_probe(struct platform_device *pdev)
>> }
>>
>> /* Register map */
>> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> - ch->base = devm_ioremap_resource(&pdev->dev, res);
>> + ch->base = devm_platform_ioremap_resource(pdev, 0);

This could keep struct resource *res above and use:

ch->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res)

With that, (and the commit message / subject updated accordingly):

Reviewed-by: Kieran Bingham <[email protected]>



>> if (IS_ERR(ch->base))
>> return PTR_ERR(ch->base);
>>
>>
>
> Compile error:
>
> drivers/media/platform/rcar_drif.c: In function ‘rcar_drif_probe’:
> drivers/media/platform/rcar_drif.c:1401:14: error: ‘res’ undeclared (first use in this function); did you mean ‘ret’?
> 1401 | ch->start = res->start;
> | ^~~
> | ret
> drivers/media/platform/rcar_drif.c:1401:14: note: each undeclared identifier is reported only once for each function it appears in
>
> Regards,
>
> Hans
>