diff mbox series

[1/3] DRM: ingenic: Use devm_platform_ioremap_resource

Message ID 20190627182114.27299-1-paul@crapouillou.net (mailing list archive)
State New, archived
Headers show
Series [1/3] DRM: ingenic: Use devm_platform_ioremap_resource | expand

Commit Message

Paul Cercueil June 27, 2019, 6:21 p.m. UTC
Simplify a bit the probe function by using the newly introduced
devm_platform_ioremap_resource(), instead of having to call
platform_get_resource() followed by devm_ioremap_resource().

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/gpu/drm/ingenic/ingenic-drm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Sam Ravnborg June 30, 2019, 8:18 a.m. UTC | #1
Hi Paul.

On Thu, Jun 27, 2019 at 08:21:12PM +0200, Paul Cercueil wrote:
> Simplify a bit the probe function by using the newly introduced
> devm_platform_ioremap_resource(), instead of having to call
> platform_get_resource() followed by devm_ioremap_resource().
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/gpu/drm/ingenic/ingenic-drm.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c
> index a069579ca749..02c4788ef1c7 100644
> --- a/drivers/gpu/drm/ingenic/ingenic-drm.c
> +++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
> @@ -580,7 +580,6 @@ static int ingenic_drm_probe(struct platform_device *pdev)
>  	struct drm_bridge *bridge;
>  	struct drm_panel *panel;
>  	struct drm_device *drm;
> -	struct resource *mem;
>  	void __iomem *base;
>  	long parent_rate;
>  	int ret, irq;
> @@ -614,8 +613,7 @@ static int ingenic_drm_probe(struct platform_device *pdev)
>  	drm->mode_config.max_height = 600;
>  	drm->mode_config.funcs = &ingenic_drm_mode_config_funcs;
>  
> -	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	base = devm_ioremap_resource(dev, mem);
> +	base = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(base)) {
>  		dev_err(dev, "Failed to get memory resource");
Consider to include the error code in the error message here.
>  		return PTR_ERR(base);

With the above fixed/considered:
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Paul Cercueil June 30, 2019, 11:09 a.m. UTC | #2
Le dim. 30 juin 2019 à 10:18, Sam Ravnborg <sam@ravnborg.org> a écrit 
:
> Hi Paul.
> 
> On Thu, Jun 27, 2019 at 08:21:12PM +0200, Paul Cercueil wrote:
>>  Simplify a bit the probe function by using the newly introduced
>>  devm_platform_ioremap_resource(), instead of having to call
>>  platform_get_resource() followed by devm_ioremap_resource().
>> 
>>  Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>>  ---
>>   drivers/gpu/drm/ingenic/ingenic-drm.c | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>> 
>>  diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c 
>> b/drivers/gpu/drm/ingenic/ingenic-drm.c
>>  index a069579ca749..02c4788ef1c7 100644
>>  --- a/drivers/gpu/drm/ingenic/ingenic-drm.c
>>  +++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
>>  @@ -580,7 +580,6 @@ static int ingenic_drm_probe(struct 
>> platform_device *pdev)
>>   	struct drm_bridge *bridge;
>>   	struct drm_panel *panel;
>>   	struct drm_device *drm;
>>  -	struct resource *mem;
>>   	void __iomem *base;
>>   	long parent_rate;
>>   	int ret, irq;
>>  @@ -614,8 +613,7 @@ static int ingenic_drm_probe(struct 
>> platform_device *pdev)
>>   	drm->mode_config.max_height = 600;
>>   	drm->mode_config.funcs = &ingenic_drm_mode_config_funcs;
>> 
>>  -	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>  -	base = devm_ioremap_resource(dev, mem);
>>  +	base = devm_platform_ioremap_resource(pdev, 0);
>>   	if (IS_ERR(base)) {
>>   		dev_err(dev, "Failed to get memory resource");
> Consider to include the error code in the error message here.

I don't think it's needed; a non-zero error code in the probe function 
will
have the drivers core automatically print a message with the name of the
failing driver and the return code.


>>   		return PTR_ERR(base);
> 
> With the above fixed/considered:
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Sam Ravnborg June 30, 2019, 8:56 p.m. UTC | #3
Hi Paul.

> > > 
> > >  -	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > >  -	base = devm_ioremap_resource(dev, mem);
> > >  +	base = devm_platform_ioremap_resource(pdev, 0);
> > >   	if (IS_ERR(base)) {
> > >   		dev_err(dev, "Failed to get memory resource");
> > Consider to include the error code in the error message here.
> 
> I don't think it's needed; a non-zero error code in the probe function will
> have the drivers core automatically print a message with the name of the
> failing driver and the return code.

You are right, I continue to forget this.
So the above is fine.

	Sam
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c
index a069579ca749..02c4788ef1c7 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
@@ -580,7 +580,6 @@  static int ingenic_drm_probe(struct platform_device *pdev)
 	struct drm_bridge *bridge;
 	struct drm_panel *panel;
 	struct drm_device *drm;
-	struct resource *mem;
 	void __iomem *base;
 	long parent_rate;
 	int ret, irq;
@@ -614,8 +613,7 @@  static int ingenic_drm_probe(struct platform_device *pdev)
 	drm->mode_config.max_height = 600;
 	drm->mode_config.funcs = &ingenic_drm_mode_config_funcs;
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	base = devm_ioremap_resource(dev, mem);
+	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base)) {
 		dev_err(dev, "Failed to get memory resource");
 		return PTR_ERR(base);