Skip to content

Commit b60c724

Browse files
Sachin KamatDavid Woodhouse
authored andcommitted
mtd: gpio: Use devm_kzalloc()
devm_kzalloc() is device managed and makes cleanup simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent c4f8cde commit b60c724

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

‎drivers/mtd/nand/gpio.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ static int gpio_nand_remove(struct platform_device *dev)
259259
if (gpio_is_valid(gpiomtd->plat.gpio_rdy))
260260
gpio_free(gpiomtd->plat.gpio_rdy);
261261

262-
kfree(gpiomtd);
263-
264262
return 0;
265263
}
266264

@@ -297,7 +295,7 @@ static int gpio_nand_probe(struct platform_device *dev)
297295
if (!res0)
298296
return -EINVAL;
299297

300-
gpiomtd = kzalloc(sizeof(*gpiomtd), GFP_KERNEL);
298+
gpiomtd = devm_kzalloc(&dev->dev, sizeof(*gpiomtd), GFP_KERNEL);
301299
if (gpiomtd == NULL) {
302300
dev_err(&dev->dev, "failed to create NAND MTD\n");
303301
return -ENOMEM;
@@ -412,7 +410,6 @@ static int gpio_nand_probe(struct platform_device *dev)
412410
iounmap(gpiomtd->nand_chip.IO_ADDR_R);
413411
release_mem_region(res0->start, resource_size(res0));
414412
err_map:
415-
kfree(gpiomtd);
416413
return ret;
417414
}
418415

0 commit comments

Comments
 (0)