Skip to contentSkip to conversation

mtd: rawnand: fsl_ifc: use devm_kasprintf for mtd name

PATCH Applied Rosen Penev 2 participants 3 messages Sep 9 – Sep 25

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: fsl_ifc: use devm_kasprintf for mtd name

Replace the manual kasprintf() in probe with devm_kasprintf() so the name is freed automatically on driver removal, and drop the now unnecessary kfree() in fsl_ifc_chip_remove() and its leftover mtd local.

Assisted-by opencode:big-pickle
---
 drivers/mtd/nand/raw/fsl_ifc_nand.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/mtd/nand/raw/fsl_ifc_nand.c +1 -5
index 469b233db73e..cc75b6a67e07 100644
@@ -963,10 +963,6 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
 
 static int fsl_ifc_chip_remove(struct fsl_ifc_mtd *priv)
 {
-	struct mtd_info *mtd = nand_to_mtd(&priv->chip);
-
-	kfree(mtd->name);
-
 	ifc_nand_ctrl->chips[priv->bank] = NULL;
 
 	return 0;
@@ -1061,7 +1057,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 = devm_kasprintf(priv->dev, GFP_KERNEL, "%llx.flash", (u64)res->start);
 	if (!mtd->name) {
 		ret = -ENOMEM;
 		goto err;
Signature · 6 lines
2.55.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#1 lore raw
Quoted 28 lines · Rosen Penev

Replace the manual kasprintf() in probe with devm_kasprintf() so the name is freed automatically on driver removal, and drop the now unnecessary kfree() in fsl_ifc_chip_remove() and its leftover mtd local.

Assisted-by opencode:big-pickle
---
 drivers/mtd/nand/raw/fsl_ifc_nand.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/mtd/nand/raw/fsl_ifc_nand.c +0 -4
index 469b233db73e..cc75b6a67e07 100644
@@ -963,10 +963,6 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
 
 static int fsl_ifc_chip_remove(struct fsl_ifc_mtd *priv)
 {
-       struct mtd_info *mtd = nand_to_mtd(&priv->chip);
-
-       kfree(mtd->name);
-
        ifc_nand_ctrl->chips[priv->bank] = NULL;
 
        return 0;

drivers/mtd/nand/raw/fsl_ifc_nand.c static int fsl_ifc_nand_probe(struct platform_device *dev) · line 1060

Quoted 5 lines
drivers/mtd/nand/raw/fsl_ifc_nand.c +1 -1
@@ -1061,7 +1057,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 = devm_kasprintf(priv->dev, GFP_KERNEL, "%llx.flash", (u64)res->start);

Having &mtd->dev as the first argument would be interesting but nobody does this.

Quoted 6 lines
drivers/mtd/nand/raw/fsl_ifc_nand.c +0 -1
        if (!mtd->name) {
                ret = -ENOMEM;
                goto err;
--

2.55.0

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

maintainer Applied
#2 lore raw
In reply to Rosen Penev
Quoted 6 lines · Rosen Penev

Replace the manual kasprintf() in probe with devm_kasprintf() so the name is freed automatically on driver removal, and drop the now unnecessary kfree() in fsl_ifc_chip_remove() and its leftover mtd local.

Applied to nand/next, thanks!

[1/1] mtd: rawnand: fsl_ifc: use devm_kasprintf for mtd name

      commit: 44c7b273e6b06fad31f2ca166307a41705ef15dd

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