Commit 0016648c authored by Boris Brezillon's avatar Boris Brezillon Committed by Miquel Raynal

mtd: rawnand: fsl_upm: Use devm_kasprintf() to allocate the MTD name

This simplifies the init() error path and the remove() handler.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200603134922.1352340-5-boris.brezillon@collabora.com
parent f760bf29
...@@ -176,8 +176,9 @@ static int fun_chip_init(struct fsl_upm_nand *fun, ...@@ -176,8 +176,9 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
return -ENODEV; return -ENODEV;
nand_set_flash_node(&fun->chip, flash_np); nand_set_flash_node(&fun->chip, flash_np);
mtd->name = kasprintf(GFP_KERNEL, "0x%llx.%pOFn", (u64)io_res->start, mtd->name = devm_kasprintf(fun->dev, GFP_KERNEL, "0x%llx.%pOFn",
flash_np); (u64)io_res->start,
flash_np);
if (!mtd->name) { if (!mtd->name) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
...@@ -190,8 +191,6 @@ static int fun_chip_init(struct fsl_upm_nand *fun, ...@@ -190,8 +191,6 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
ret = mtd_device_register(mtd, NULL, 0); ret = mtd_device_register(mtd, NULL, 0);
err: err:
of_node_put(flash_np); of_node_put(flash_np);
if (ret)
kfree(mtd->name);
return ret; return ret;
} }
...@@ -318,7 +317,6 @@ static int fun_remove(struct platform_device *ofdev) ...@@ -318,7 +317,6 @@ static int fun_remove(struct platform_device *ofdev)
ret = mtd_device_unregister(mtd); ret = mtd_device_unregister(mtd);
WARN_ON(ret); WARN_ON(ret);
nand_cleanup(chip); nand_cleanup(chip);
kfree(mtd->name);
for (i = 0; i < fun->mchip_count; i++) { for (i = 0; i < fun->mchip_count; i++) {
if (fun->rnb_gpio[i] < 0) if (fun->rnb_gpio[i] < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment