mtd: bcm47xxnflash: Use devm_kzalloc
devm_kzalloc is device managed and simplifies the code. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
This commit is contained in:
Родитель
994bbd0e91
Коммит
7e3019e364
|
@ -29,11 +29,9 @@ static int bcm47xxnflash_probe(struct platform_device *pdev)
|
||||||
struct bcm47xxnflash *b47n;
|
struct bcm47xxnflash *b47n;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
b47n = kzalloc(sizeof(*b47n), GFP_KERNEL);
|
b47n = devm_kzalloc(&pdev->dev, sizeof(*b47n), GFP_KERNEL);
|
||||||
if (!b47n) {
|
if (!b47n)
|
||||||
err = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
b47n->nand_chip.priv = b47n;
|
b47n->nand_chip.priv = b47n;
|
||||||
b47n->mtd.owner = THIS_MODULE;
|
b47n->mtd.owner = THIS_MODULE;
|
||||||
|
@ -48,22 +46,16 @@ static int bcm47xxnflash_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
pr_err("Initialization failed: %d\n", err);
|
pr_err("Initialization failed: %d\n", err);
|
||||||
goto err_init;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = mtd_device_parse_register(&b47n->mtd, probes, NULL, NULL, 0);
|
err = mtd_device_parse_register(&b47n->mtd, probes, NULL, NULL, 0);
|
||||||
if (err) {
|
if (err) {
|
||||||
pr_err("Failed to register MTD device: %d\n", err);
|
pr_err("Failed to register MTD device: %d\n", err);
|
||||||
goto err_dev_reg;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_dev_reg:
|
|
||||||
err_init:
|
|
||||||
kfree(b47n);
|
|
||||||
out:
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bcm47xxnflash_remove(struct platform_device *pdev)
|
static int bcm47xxnflash_remove(struct platform_device *pdev)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче