mtd: rawnand: fsl_ifc: use devm_platform_get_and_ioremap_resource
Subsystems (2)
PATCH v2 1/1 mtd: rawnand: fsl_ifc: use devm_platform_get_and_ioremap_resource
Replace the manual of_address_to_resource(), ioremap(), and iounmap() in the probe/remove paths with devm_platform_get_and_ioremap_resource() so the resource is managed and released automatically on probe failure and driver removal.
---
v2: rebase and remove now unused header.
drivers/mtd/nand/raw/fsl_ifc_nand.c | 30 +++++++++-------------------- 1 file changed, 9 insertions(+), 21 deletions(-)
drivers/mtd/nand/raw/fsl_ifc_nand.c +9 -21
@@ -12,7 +12,6 @@#include <linux/platform_device.h> #include <linux/types.h> #include <linux/kernel.h> -#include <linux/of_address.h> #include <linux/slab.h> #include <linux/mtd/mtd.h> #include <linux/mtd/rawnand.h>
@@ -968,9 +967,6 @@ static int fsl_ifc_chip_remove(struct fsl_ifc_mtd *priv)kfree (mtd->name); -if (priv->vbase) -iounmap (priv->vbase); - ifc_nand_ctrl->chips[priv->bank] =NULL ;return 0 ;
@@ -995,12 +991,12 @@ static int fsl_ifc_nand_probe(struct platform_device *dev) {struct fsl_ifc_runtime __iomem *ifc;struct fsl_ifc_mtd *priv; -struct resource res; +struct resource *res; +void __iomem *vbase;static const char *part_probe_types[] = {"cmdlinepart" ,"RedBoot" ,"ofpart" ,NULL };int ret;int bank; -struct device_node *node = dev->dev.of_node;struct mtd_info *mtd;if (!fsl_ifc_ctrl_dev || !fsl_ifc_ctrl_dev->rregs)
@@ -1008,15 +1004,13 @@ static int fsl_ifc_nand_probe(struct platform_device *dev) ifc = fsl_ifc_ctrl_dev->rregs;/* get, allocate and map the memory resource */ - ret =of_address_to_resource (node,0 , &res); -if (ret) { -dev_err (&dev->dev,"%s: failed to get resource\n" , __func__); -return ret; - } + vbase =devm_platform_get_and_ioremap_resource (dev,0 , &res); +if (IS_ERR (vbase)) +return PTR_ERR (vbase);/* find which chip select it is connected to */ for (bank =0 ; bank < fsl_ifc_ctrl_dev->banks; bank++) { -if (match_bank (fsl_ifc_ctrl_dev->gregs, bank, res.start)) +if (match_bank (fsl_ifc_ctrl_dev->gregs, bank, res->start))break ; }
@@ -1051,13 +1045,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev) priv->bank = bank; priv->ctrl = fsl_ifc_ctrl_dev; priv->dev = &dev->dev; - - priv->vbase =ioremap (res.start,resource_size (&res)); -if (!priv->vbase) { -dev_err (priv->dev,"%s: failed to map chip region\n" , __func__); - ret = -ENOMEM ; - goto err; - } + priv->vbase = vbase;dev_set_drvdata (priv->dev, priv);
@@ -1073,7 +1061,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev) &ifc->ifc_nand.nand_evter_intr_en); mtd =nand_to_mtd (&priv->chip); - mtd->name =kasprintf (GFP_KERNEL ,"%llx.flash" , (u64 )res.start); + mtd->name =kasprintf (GFP_KERNEL ,"%llx.flash" , (u64 )res->start);if (!mtd->name) { ret = -ENOMEM ; goto err;
@@ -1095,7 +1083,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev) goto cleanup_nand;dev_info (priv->dev,"IFC NAND device at 0x%llx, bank %d\n" , - (unsigned long long )res.start, priv->bank); + (unsigned long long )res->start, priv->bank);return 0 ;
Signature · 1 line
2.55.0
Quoted 6 lines · Rosen Penev
Replace the manual
of_address_to_resource(),ioremap(), andiounmap()in the probe/remove paths withdevm_platform_get_and_ioremap_resource()so the resource is managed and released automatically on probe failure and driver removal.
Applied to nand/next, thanks!
[1/1] mtd: rawnand: fsl_ifc: use devm_platform_get_and_ioremap_resource
commit: 2b7e16d565af2b4715290d9de513187a7374b2ed
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
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/