linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: st_spi_fsm: Use devm_platform_ioremap_resource() in stfsm_probe()
@ 2019-09-18 12:50 Markus Elfring
  2019-09-19  9:10 ` Miquel Raynal
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Elfring @ 2019-09-18 12:50 UTC (permalink / raw)
  To: linux-mtd, Allison Randal, Armijn Hemel, Brian Norris,
	David Woodhouse, Greg Kroah-Hartman, Lee Jones, Marek Vasut,
	Miquel Raynal, Richard Weinberger, Thomas Gleixner,
	Vignesh Raghavendra
  Cc: Bartosz Golaszewski, kernel-janitors, LKML, Himanshu Jha

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


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mtd: st_spi_fsm: Use devm_platform_ioremap_resource() in stfsm_probe()
  2019-09-18 12:50 [PATCH] mtd: st_spi_fsm: Use devm_platform_ioremap_resource() in stfsm_probe() Markus Elfring
@ 2019-09-19  9:10 ` Miquel Raynal
  2019-09-19 10:50   ` Markus Elfring
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Miquel Raynal @ 2019-09-19  9:10 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Vignesh Raghavendra, Bartosz Golaszewski, Greg Kroah-Hartman,
	kernel-janitors, LKML, Marek Vasut, Armijn Hemel, linux-mtd,
	Himanshu Jha, Richard Weinberger, Lee Jones, Brian Norris,
	David Woodhouse, Thomas Gleixner, Allison Randal

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

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mtd: st_spi_fsm: Use devm_platform_ioremap_resource() in stfsm_probe()
  2019-09-19  9:10 ` Miquel Raynal
@ 2019-09-19 10:50   ` Markus Elfring
  2019-09-19 11:29   ` Greg Kroah-Hartman
  2019-09-19 12:04   ` [PATCH v2] " Markus Elfring
  2 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2019-09-19 10:50 UTC (permalink / raw)
  To: Miquel Raynal, linux-mtd
  Cc: Vignesh Raghavendra, Bartosz Golaszewski, Greg Kroah-Hartman,
	kernel-janitors, LKML, Marek Vasut, Armijn Hemel, Himanshu Jha,
	Richard Weinberger, Lee Jones, Brian Norris, David Woodhouse,
	Thomas Gleixner, Allison Randal

>> +++ 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

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mtd: st_spi_fsm: Use devm_platform_ioremap_resource() in stfsm_probe()
  2019-09-19  9:10 ` Miquel Raynal
  2019-09-19 10:50   ` Markus Elfring
@ 2019-09-19 11:29   ` Greg Kroah-Hartman
  2019-09-19 11:35     ` Miquel Raynal
  2019-09-19 12:04   ` [PATCH v2] " Markus Elfring
  2 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2019-09-19 11:29 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Vignesh Raghavendra, Bartosz Golaszewski, Lee Jones,
	kernel-janitors, LKML, Marek Vasut, Armijn Hemel, linux-mtd,
	Himanshu Jha, Richard Weinberger, Markus Elfring,
	Thomas Gleixner, Brian Norris, David Woodhouse, Allison Randal

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

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mtd: st_spi_fsm: Use devm_platform_ioremap_resource() in stfsm_probe()
  2019-09-19 11:29   ` Greg Kroah-Hartman
@ 2019-09-19 11:35     ` Miquel Raynal
  2019-09-19 12:16       ` Markus Elfring
  0 siblings, 1 reply; 7+ messages in thread
From: Miquel Raynal @ 2019-09-19 11:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Vignesh Raghavendra, Bartosz Golaszewski, Lee Jones,
	kernel-janitors, LKML, Marek Vasut, Armijn Hemel, linux-mtd,
	Himanshu Jha, Richard Weinberger, Markus Elfring,
	Thomas Gleixner, Brian Norris, David Woodhouse, Allison Randal

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

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] mtd: st_spi_fsm: Use devm_platform_ioremap_resource() in stfsm_probe()
  2019-09-19  9:10 ` Miquel Raynal
  2019-09-19 10:50   ` Markus Elfring
  2019-09-19 11:29   ` Greg Kroah-Hartman
@ 2019-09-19 12:04   ` Markus Elfring
  2 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2019-09-19 12:04 UTC (permalink / raw)
  To: Miquel Raynal, Allison Randal, Armijn Hemel, Brian Norris,
	David Woodhouse, Greg Kroah-Hartman, Lee Jones, Marek Vasut,
	Richard Weinberger, Thomas Gleixner, Vignesh Raghavendra,
	linux-mtd
  Cc: Bartosz Golaszewski, kernel-janitors, LKML, Himanshu Jha

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 19 Sep 2019 13:30:51 +0200

Simplify this function implementation by using a known wrapper function.
* Thus reduce also a bit of exception handling code.
* Delete the local variable “res”.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
Further changes were requested by Miquel Raynal.
https://lore.kernel.org/r/20190919111014.6c569cf3@xps13/

* An error message was adjusted another bit.
* A variable was removed.


 drivers/mtd/devices/st_spi_fsm.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
index f4d1667daaf9..ce18198301d5 100644
--- a/drivers/mtd/devices/st_spi_fsm.c
+++ b/drivers/mtd/devices/st_spi_fsm.c
@@ -2017,7 +2017,6 @@ static int stfsm_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct flash_info *info;
-	struct resource *res;
 	struct stfsm *fsm;
 	int ret;

@@ -2033,17 +2032,9 @@ static int stfsm_probe(struct platform_device *pdev)
 	fsm->dev = &pdev->dev;

 	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);
+		dev_err(&pdev->dev, "Failed to reserve memory region\n");
 		return PTR_ERR(fsm->base);
 	}

--
2.23.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: mtd: st_spi_fsm: Use devm_platform_ioremap_resource() in stfsm_probe()
  2019-09-19 11:35     ` Miquel Raynal
@ 2019-09-19 12:16       ` Markus Elfring
  0 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2019-09-19 12:16 UTC (permalink / raw)
  To: Miquel Raynal, Greg Kroah-Hartman, linux-mtd, kernel-janitors
  Cc: Vignesh Raghavendra, Bartosz Golaszewski, David Woodhouse, LKML,
	Marek Vasut, Armijn Hemel, Himanshu Jha, Richard Weinberger,
	Thomas Gleixner, Brian Norris, Lee Jones, Allison Randal

> 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

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-09-19 12:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18 12:50 [PATCH] mtd: st_spi_fsm: Use devm_platform_ioremap_resource() in stfsm_probe() Markus Elfring
2019-09-19  9:10 ` Miquel Raynal
2019-09-19 10:50   ` Markus Elfring
2019-09-19 11:29   ` Greg Kroah-Hartman
2019-09-19 11:35     ` Miquel Raynal
2019-09-19 12:16       ` Markus Elfring
2019-09-19 12:04   ` [PATCH v2] " Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).