mtd: st_spi_fsm: Use devm_platform_ioremap_resource() in stfsm_probe()
diff mbox series

Message ID e1d32aa4-7c82-64e0-b7c4-33c94d9a2769@web.de
State Superseded
Headers show
Series
  • mtd: st_spi_fsm: Use devm_platform_ioremap_resource() in stfsm_probe()
Related show

Commit Message

Markus Elfring Sept. 18, 2019, 12:50 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Sep 2019 14:37:34 +0200

Simplify this function implementation by using a known wrapper function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mtd/devices/st_spi_fsm.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

--
2.23.0

Comments

Miquel Raynal Sept. 19, 2019, 9:10 a.m. UTC | #1
Hi Markus,

Markus Elfring <Markus.Elfring@web.de> wrote on Wed, 18 Sep 2019
14:50:27 +0200:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 18 Sep 2019 14:37:34 +0200
> 
> Simplify this function implementation by using a known wrapper function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mtd/devices/st_spi_fsm.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
> index f4d1667daaf9..5bd1c44ae529 100644
> --- a/drivers/mtd/devices/st_spi_fsm.c
> +++ b/drivers/mtd/devices/st_spi_fsm.c
> @@ -2034,13 +2034,7 @@ static int stfsm_probe(struct platform_device *pdev)
> 
>  	platform_set_drvdata(pdev, fsm);
> 
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(&pdev->dev, "Resource not found\n");
> -		return -ENODEV;
> -	}
> -
> -	fsm->base = devm_ioremap_resource(&pdev->dev, res);
> +	fsm->base = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(fsm->base)) {
>  		dev_err(&pdev->dev,
>  			"Failed to reserve memory region %pR\n", res);
> --
> 2.23.0
> 


Is this even compiled tested? 'res' is not initialized anymore so you
can't use it in the error trace. I suppose you should even drop it from
the stack parameters.

Thanks,
Miquèl
Markus Elfring Sept. 19, 2019, 10:50 a.m. UTC | #2
>> +++ b/drivers/mtd/devices/st_spi_fsm.c
>> @@ -2034,13 +2034,7 @@ static int stfsm_probe(struct platform_device *pdev)
>>
>>  	platform_set_drvdata(pdev, fsm);
>>
>> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> -	if (!res) {
>> -		dev_err(&pdev->dev, "Resource not found\n");
>> -		return -ENODEV;
>> -	}
>> -
>> -	fsm->base = devm_ioremap_resource(&pdev->dev, res);
>> +	fsm->base = devm_platform_ioremap_resource(pdev, 0);
>>  	if (IS_ERR(fsm->base)) {
>>  		dev_err(&pdev->dev,
>>  			"Failed to reserve memory region %pR\n", res);
>> --
>> 2.23.0
>>
>
>
> Is this even compiled tested? 'res' is not initialized anymore so you
> can't use it in the error trace. I suppose you should even drop it from
> the stack parameters.

Would you accept to reduce the error message another bit?

Regards,
Markus
Greg Kroah-Hartman Sept. 19, 2019, 11:29 a.m. UTC | #3
On Thu, Sep 19, 2019 at 11:10:14AM +0200, Miquel Raynal wrote:
> Hi Markus,
> 
> Markus Elfring <Markus.Elfring@web.de> wrote on Wed, 18 Sep 2019
> 14:50:27 +0200:
> 
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Wed, 18 Sep 2019 14:37:34 +0200
> > 
> > Simplify this function implementation by using a known wrapper function.
> > 
> > This issue was detected by using the Coccinelle software.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> >  drivers/mtd/devices/st_spi_fsm.c | 8 +-------
> >  1 file changed, 1 insertion(+), 7 deletions(-)
> > 
> > diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
> > index f4d1667daaf9..5bd1c44ae529 100644
> > --- a/drivers/mtd/devices/st_spi_fsm.c
> > +++ b/drivers/mtd/devices/st_spi_fsm.c
> > @@ -2034,13 +2034,7 @@ static int stfsm_probe(struct platform_device *pdev)
> > 
> >  	platform_set_drvdata(pdev, fsm);
> > 
> > -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > -	if (!res) {
> > -		dev_err(&pdev->dev, "Resource not found\n");
> > -		return -ENODEV;
> > -	}
> > -
> > -	fsm->base = devm_ioremap_resource(&pdev->dev, res);
> > +	fsm->base = devm_platform_ioremap_resource(pdev, 0);
> >  	if (IS_ERR(fsm->base)) {
> >  		dev_err(&pdev->dev,
> >  			"Failed to reserve memory region %pR\n", res);
> > --
> > 2.23.0
> > 
> 
> 
> Is this even compiled tested? 'res' is not initialized anymore so you
> can't use it in the error trace. I suppose you should even drop it from
> the stack parameters.

You are responding to a email address/bot that is on a number of kernel
developers "black list" as something to just totally ignore.  I
recommend you do the same if possible...

greg k-h
Miquel Raynal Sept. 19, 2019, 11:35 a.m. UTC | #4
Hi Greg,

Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote on Thu, 19 Sep
2019 13:29:37 +0200:

> On Thu, Sep 19, 2019 at 11:10:14AM +0200, Miquel Raynal wrote:
> > Hi Markus,
> > 
> > Markus Elfring <Markus.Elfring@web.de> wrote on Wed, 18 Sep 2019
> > 14:50:27 +0200:
> >   
> > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > Date: Wed, 18 Sep 2019 14:37:34 +0200
> > > 
> > > Simplify this function implementation by using a known wrapper function.
> > > 
> > > This issue was detected by using the Coccinelle software.
> > > 
> > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > > ---
> > >  drivers/mtd/devices/st_spi_fsm.c | 8 +-------
> > >  1 file changed, 1 insertion(+), 7 deletions(-)
> > > 
> > > diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
> > > index f4d1667daaf9..5bd1c44ae529 100644
> > > --- a/drivers/mtd/devices/st_spi_fsm.c
> > > +++ b/drivers/mtd/devices/st_spi_fsm.c
> > > @@ -2034,13 +2034,7 @@ static int stfsm_probe(struct platform_device *pdev)
> > > 
> > >  	platform_set_drvdata(pdev, fsm);
> > > 
> > > -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > -	if (!res) {
> > > -		dev_err(&pdev->dev, "Resource not found\n");
> > > -		return -ENODEV;
> > > -	}
> > > -
> > > -	fsm->base = devm_ioremap_resource(&pdev->dev, res);
> > > +	fsm->base = devm_platform_ioremap_resource(pdev, 0);
> > >  	if (IS_ERR(fsm->base)) {
> > >  		dev_err(&pdev->dev,
> > >  			"Failed to reserve memory region %pR\n", res);
> > > --
> > > 2.23.0
> > >   
> > 
> > 
> > Is this even compiled tested? 'res' is not initialized anymore so you
> > can't use it in the error trace. I suppose you should even drop it from
> > the stack parameters.  
> 
> You are responding to a email address/bot that is on a number of kernel
> developers "black list" as something to just totally ignore.  I
> recommend you do the same if possible...
> 
> greg k-h

Oh right... Sure, I'll ignore it/him as well.

Thanks for the info,
Miquèl
Markus Elfring Sept. 19, 2019, 12:16 p.m. UTC | #5
> Oh right... Sure, I'll ignore it/him as well.

I hope that you will still care for further possible software improvements
because of presented transformation results around collateral evolution.

Regards,
Markus

Patch
diff mbox series

diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
index f4d1667daaf9..5bd1c44ae529 100644
--- a/drivers/mtd/devices/st_spi_fsm.c
+++ b/drivers/mtd/devices/st_spi_fsm.c
@@ -2034,13 +2034,7 @@  static int stfsm_probe(struct platform_device *pdev)

 	platform_set_drvdata(pdev, fsm);

-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "Resource not found\n");
-		return -ENODEV;
-	}
-
-	fsm->base = devm_ioremap_resource(&pdev->dev, res);
+	fsm->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(fsm->base)) {
 		dev_err(&pdev->dev,
 			"Failed to reserve memory region %pR\n", res);