[12/18] mtd: nand: omap: Use devm_platform_get_and_ioremap_resource()

Message ID 20230707040622.78174-12-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/onenand/onenand_omap2.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
  

Comments

Miquel Raynal July 13, 2023, 7:57 a.m. UTC | #1
On Fri, 2023-07-07 at 04:06:16 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>

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

Miquel
  
Nathan Chancellor July 14, 2023, 3:27 p.m. UTC | #2
On Thu, Jul 13, 2023 at 09:57:51AM +0200, Miquel Raynal wrote:
> On Fri, 2023-07-07 at 04:06:16 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>
> 
> Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Please apply the updated version at [1], the current version is
obviously not correct, as clang points out in next-20230714:

  drivers/mtd/nand/onenand/onenand_omap2.c:470:2: warning: variable 'c' is uninitialized when used here [-Wuninitialized]
    470 |         c->onenand.base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
        |         ^
  drivers/mtd/nand/onenand/onenand_omap2.c:465:25: note: initialize the variable 'c' to silence this warning
    465 |         struct omap2_onenand *c;
        |                                ^
        |                                 = NULL
  1 warning generated.

KernelCI also reported this at [2]. I apologize if this has already been
reported or fixed locally, I did not see your branch updated.

[1]: https://lore.kernel.org/20230713104422.29222-1-frank.li@vivo.com/
[2]: https://lore.kernel.org/64b137dc.170a0220.b8a13.feee@mx.google.com/

Cheers,
Nathan
  
Miquel Raynal July 15, 2023, 4:06 p.m. UTC | #3
Hi Nathan,

nathan@kernel.org wrote on Fri, 14 Jul 2023 08:27:01 -0700:

> On Thu, Jul 13, 2023 at 09:57:51AM +0200, Miquel Raynal wrote:
> > On Fri, 2023-07-07 at 04:06:16 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>  
> > 
> > Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.  
> 
> Please apply the updated version at [1], the current version is
> obviously not correct, as clang points out in next-20230714:

I will replace the first version by the corrected one.

> 
>   drivers/mtd/nand/onenand/onenand_omap2.c:470:2: warning: variable 'c' is uninitialized when used here [-Wuninitialized]
>     470 |         c->onenand.base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
>         |         ^
>   drivers/mtd/nand/onenand/onenand_omap2.c:465:25: note: initialize the variable 'c' to silence this warning
>     465 |         struct omap2_onenand *c;
>         |                                ^
>         |                                 = NULL
>   1 warning generated.
> 
> KernelCI also reported this at [2]. I apologize if this has already been
> reported or fixed locally, I did not see your branch updated.
> 
> [1]: https://lore.kernel.org/20230713104422.29222-1-frank.li@vivo.com/
> [2]: https://lore.kernel.org/64b137dc.170a0220.b8a13.feee@mx.google.com/
> 
> Cheers,
> Nathan


Thanks,
Miquèl
  

Patch

diff --git a/drivers/mtd/nand/onenand/onenand_omap2.c b/drivers/mtd/nand/onenand/onenand_omap2.c
index ff7af98604df..b39aee023103 100644
--- a/drivers/mtd/nand/onenand/onenand_omap2.c
+++ b/drivers/mtd/nand/onenand/onenand_omap2.c
@@ -467,11 +467,9 @@  static int omap2_onenand_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(dev, "error getting memory resource\n");
-		return -EINVAL;
-	}
+	c->onenand.base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+	if (IS_ERR(c->onenand.base))
+		return PTR_ERR(c->onenand.base);
 
 	r = of_property_read_u32(np, "reg", &val);
 	if (r) {
@@ -488,10 +486,6 @@  static int omap2_onenand_probe(struct platform_device *pdev)
 	c->gpmc_cs = val;
 	c->phys_base = res->start;
 
-	c->onenand.base = devm_ioremap_resource(dev, res);
-	if (IS_ERR(c->onenand.base))
-		return PTR_ERR(c->onenand.base);
-
 	c->int_gpiod = devm_gpiod_get_optional(dev, "int", GPIOD_IN);
 	if (IS_ERR(c->int_gpiod)) {
 		/* Just try again if this happens */