Skip to content

Commit 0016648

Browse files
bbrezillonmiquelraynal
authored andcommitted
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: Boris Brezillon <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent f760bf2 commit 0016648

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/mtd/nand/raw/fsl_upm.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,9 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
176176
return -ENODEV;
177177

178178
nand_set_flash_node(&fun->chip, flash_np);
179-
mtd->name = kasprintf(GFP_KERNEL, "0x%llx.%pOFn", (u64)io_res->start,
180-
flash_np);
179+
mtd->name = devm_kasprintf(fun->dev, GFP_KERNEL, "0x%llx.%pOFn",
180+
(u64)io_res->start,
181+
flash_np);
181182
if (!mtd->name) {
182183
ret = -ENOMEM;
183184
goto err;
@@ -190,8 +191,6 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
190191
ret = mtd_device_register(mtd, NULL, 0);
191192
err:
192193
of_node_put(flash_np);
193-
if (ret)
194-
kfree(mtd->name);
195194
return ret;
196195
}
197196

@@ -318,7 +317,6 @@ static int fun_remove(struct platform_device *ofdev)
318317
ret = mtd_device_unregister(mtd);
319318
WARN_ON(ret);
320319
nand_cleanup(chip);
321-
kfree(mtd->name);
322320

323321
for (i = 0; i < fun->mchip_count; i++) {
324322
if (fun->rnb_gpio[i] < 0)

0 commit comments

Comments
 (0)