[01/18] mtd: rawnand: sunxi: Use devm_platform_get_and_ioremap_resource()

Message ID 20230707040622.78174-1-frank.li@vivo.com
State New
Headers
Series [01/18] mtd: rawnand: sunxi: Use devm_platform_get_and_ioremap_resource() |

Commit Message

李扬韬 July 7, 2023, 4:06 a.m. UTC
  Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/mtd/nand/raw/sunxi_nand.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Jernej Škrabec July 11, 2023, 6:23 p.m. UTC | #1
Dne petek, 07. julij 2023 ob 06:06:05 CEST je Yangtao Li napisal(a):
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>

Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>

Best regards,
Jernej

> ---
>  drivers/mtd/nand/raw/sunxi_nand.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c
> b/drivers/mtd/nand/raw/sunxi_nand.c index 9884304634f6..db36bd755b8d 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> @@ -2087,8 +2087,7 @@ static int sunxi_nfc_probe(struct platform_device
> *pdev) nand_controller_init(&nfc->controller);
>  	INIT_LIST_HEAD(&nfc->chips);
> 
> -	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	nfc->regs = devm_ioremap_resource(dev, r);
> +	nfc->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
>  	if (IS_ERR(nfc->regs))
>  		return PTR_ERR(nfc->regs);
  
Miquel Raynal July 12, 2023, 11:54 a.m. UTC | #2
Hi Yangtao,

frank.li@vivo.com wrote on Fri,  7 Jul 2023 12:06:05 +0800:

> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  drivers/mtd/nand/raw/sunxi_nand.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> index 9884304634f6..db36bd755b8d 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> @@ -2087,8 +2087,7 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
>  	nand_controller_init(&nfc->controller);
>  	INIT_LIST_HEAD(&nfc->chips);
>  
> -	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	nfc->regs = devm_ioremap_resource(dev, r);
> +	nfc->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r);

Why do you keep a reference over the resource? Why not just
devm_platform_ioremap_resource(pdev, 0) ?

This comment is valid for almost all the cases in this series.

When the resource is only needed in an error printk, I am also in favor
of modifying the error message to avoid having to grab the resource.

>  	if (IS_ERR(nfc->regs))
>  		return PTR_ERR(nfc->regs);
>  

These comments apply to the 18 patches.

Thanks,
Miquèl
  
Miquel Raynal July 12, 2023, 12:06 p.m. UTC | #3
miquel.raynal@bootlin.com wrote on Wed, 12 Jul 2023 13:54:55 +0200:

> Hi Yangtao,
> 
> frank.li@vivo.com wrote on Fri,  7 Jul 2023 12:06:05 +0800:
> 
> > Convert platform_get_resource(), devm_ioremap_resource() to a single
> > call to devm_platform_get_and_ioremap_resource(), as this is exactly
> > what this function does.
> > 
> > Signed-off-by: Yangtao Li <frank.li@vivo.com>
> > ---
> >  drivers/mtd/nand/raw/sunxi_nand.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> > index 9884304634f6..db36bd755b8d 100644
> > --- a/drivers/mtd/nand/raw/sunxi_nand.c
> > +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> > @@ -2087,8 +2087,7 @@ static int sunxi_nfc_probe(struct platform_device *pdev)
> >  	nand_controller_init(&nfc->controller);
> >  	INIT_LIST_HEAD(&nfc->chips);
> >  
> > -	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > -	nfc->regs = devm_ioremap_resource(dev, r);
> > +	nfc->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
> 
> Why do you keep a reference over the resource? Why not just
> devm_platform_ioremap_resource(pdev, 0) ?
> 
> This comment is valid for almost all the cases in this series.

Actually 'r' is used at the bottom, so the patch is good. I reviewed
all the patches, 17 look right, I have a minor comment on one of them.
In order to avoid resending all the patches, I'll first apply the 17
good ones and ask you to resend just the last one.

> When the resource is only needed in an error printk, I am also in favor
> of modifying the error message to avoid having to grab the resource.
> 
> >  	if (IS_ERR(nfc->regs))
> >  		return PTR_ERR(nfc->regs);
> >  
> 
> These comments apply to the 18 patches.
> 
> Thanks,
> Miquèl


Thanks,
Miquèl
  
Miquel Raynal July 13, 2023, 7:58 a.m. UTC | #4
On Fri, 2023-07-07 at 04:06:05 UTC, Yangtao Li wrote:
> Convert platform_get_resource(), devm_ioremap_resource() to a single
> call to devm_platform_get_and_ioremap_resource(), as this is exactly
> what this function does.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel
  

Patch

diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
index 9884304634f6..db36bd755b8d 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -2087,8 +2087,7 @@  static int sunxi_nfc_probe(struct platform_device *pdev)
 	nand_controller_init(&nfc->controller);
 	INIT_LIST_HEAD(&nfc->chips);
 
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	nfc->regs = devm_ioremap_resource(dev, r);
+	nfc->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
 	if (IS_ERR(nfc->regs))
 		return PTR_ERR(nfc->regs);