mtd: rawnand: ndfc: use devm_platform_ioremap_resource()
Subsystems (2)
PATCH v2 1/1 mtd: rawnand: ndfc: use devm_platform_ioremap_resource()
Replace the open-coded of_iomap()/iounmap() with the managed devm_platform_ioremap_resource() helper. This fixes a mapping leak on driver remove (the old code never called iounmap()) and simplifies the error path by dropping the manual cleanup in ndfc_probe().
There is no overlapping memory-region concern introduced by this
change: each supported board DT describes a single ndfc node with a unique 0x2000 register region, and the EBC parent uses dcr-reg rather than a MEM reg resource, so the newly added request_mem_region() cannot conflict with an existing reservation. Distinct chip selects map to distinct 64-bit physical addresses, so CS instances do not overlap.
---
v2: add Fixes: and Cc: tags
drivers/mtd/nand/raw/ndfc.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/mtd/nand/raw/ndfc.c +8 -13
@@ -185,10 +185,15 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,static int ndfc_probe (struct platform_device *ofdev) {struct ndfc_controller *ndfc; +void __iomem *ndfcbase;const __be32 *reg;u32 ccr;u32 cs; -int err, len =0 ; +int len =0 ; + + ndfcbase =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (ndfcbase)) +return PTR_ERR (ndfcbase);/* Read the reg property to get the chip select */ reg =of_get_property (ofdev->dev.of_node,"reg" , &len);
@@ -210,11 +215,7 @@ static int ndfc_probe(struct platform_device *ofdev) ndfc->ofdev = ofdev;dev_set_drvdata (&ofdev->dev, ndfc); - ndfc->ndfcbase =of_iomap (ofdev->dev.of_node,0 ); -if (!ndfc->ndfcbase) { -dev_err (&ofdev->dev,"failed to get memory\n" ); -return -EIO ; - } + ndfc->ndfcbase = ndfcbase; ccr =NDFC_CCR_BS (ndfc->chip_select);
@@ -232,13 +233,7 @@ static int ndfc_probe(struct platform_device *ofdev)iowrite32be (be32_to_cpup (reg), ndfc->ndfcbase + offset); } - err =ndfc_chip_init (ndfc, ofdev->dev.of_node); -if (err) { -iounmap (ndfc->ndfcbase); -return err; - } - -return 0 ; +return ndfc_chip_init (ndfc, ofdev->dev.of_node); }static void ndfc_remove (struct platform_device *ofdev)
Signature · 1 line
2.55.0
Quoted 5 lines · Rosen Penev
Replace the open-coded of_iomap()/iounmap() with the managed
devm_platform_ioremap_resource()helper. This fixes a mapping leak on driver remove (the old code never callediounmap()) and simplifies the error path by dropping the manual cleanup inndfc_probe().
Quoted 8 lines
There is no overlapping memory-region concern introduced by this
change: each supported board DT describes a single ndfc node with a unique0x2000register region, and the EBC parent uses dcr-reg rather than a MEM reg resource, so the newly addedrequest_mem_region()cannot conflict with an existing reservation. Distinct chip selects map to distinct 64-bit physical addresses, so CS instances do not overlap.[...]
Applied to nand/next, thanks!
[1/1] mtd: rawnand: ndfc: use devm_platform_ioremap_resource()
commit: 0d66f9895f286d2fab396a71e6efeb95c4a7e5a6
Patche(s) should be available on mtd/linux.git and will be part of the next PR (provided that no robot complains by then).
Kind regards,
Miquèl