mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-05-03 03:41:02 +02:00
mtd: rawnand: sunxi: clean sunxi_nand_chip_init()
In sunxi_nand_chip_init there's quite a lot of kfree/return, it's easy to forget a kfree(), so use a goto/kfree instead. Signed-off-by: Richard Genoud <richard.genoud@bootlin.com> [Andre: rename goto label, keep return 0;] Reviewed-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
This commit is contained in:
parent
6b33232e32
commit
a776cb833d
@ -1600,21 +1600,20 @@ static int sunxi_nand_chip_init(struct udevice *dev, struct sunxi_nfc *nfc,
|
||||
if (ret) {
|
||||
dev_err(dev, "could not retrieve reg property: %d\n",
|
||||
ret);
|
||||
kfree(chip);
|
||||
return ret;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
if (tmp > NFC_MAX_CS) {
|
||||
dev_err(dev,
|
||||
"invalid reg value: %u (max CS = 7)\n", tmp);
|
||||
kfree(chip);
|
||||
return -EINVAL;
|
||||
ret = -EINVAL;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
if (test_and_set_bit(tmp, &nfc->assigned_cs)) {
|
||||
dev_err(dev, "CS %d already assigned\n", tmp);
|
||||
kfree(chip);
|
||||
return -EINVAL;
|
||||
ret = -EINVAL;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
chip->sels[i].cs = tmp;
|
||||
@ -1640,15 +1639,13 @@ static int sunxi_nand_chip_init(struct udevice *dev, struct sunxi_nfc *nfc,
|
||||
dev_err(dev,
|
||||
"could not retrieve timings for ONFI mode 0: %d\n",
|
||||
ret);
|
||||
kfree(chip);
|
||||
return ret;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
ret = sunxi_nand_chip_set_timings(nfc, chip, timings);
|
||||
if (ret) {
|
||||
dev_err(dev, "could not configure chip timings: %d\n", ret);
|
||||
kfree(chip);
|
||||
return ret;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
nand = &chip->nand;
|
||||
@ -1669,10 +1666,8 @@ static int sunxi_nand_chip_init(struct udevice *dev, struct sunxi_nfc *nfc,
|
||||
|
||||
mtd = nand_to_mtd(nand);
|
||||
ret = nand_scan_ident(mtd, nsels, NULL);
|
||||
if (ret) {
|
||||
kfree(chip);
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
goto err_free;
|
||||
|
||||
if (nand->bbt_options & NAND_BBT_USE_FLASH)
|
||||
nand->bbt_options |= NAND_BBT_NO_OOB;
|
||||
@ -1685,34 +1680,35 @@ static int sunxi_nand_chip_init(struct udevice *dev, struct sunxi_nfc *nfc,
|
||||
ret = sunxi_nand_chip_init_timings(nfc, chip);
|
||||
if (ret) {
|
||||
dev_err(dev, "could not configure chip timings: %d\n", ret);
|
||||
kfree(chip);
|
||||
return ret;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
ret = sunxi_nand_ecc_init(mtd, &nand->ecc);
|
||||
if (ret) {
|
||||
dev_err(dev, "ECC init failed: %d\n", ret);
|
||||
kfree(chip);
|
||||
return ret;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
ret = nand_scan_tail(mtd);
|
||||
if (ret) {
|
||||
dev_err(dev, "nand_scan_tail failed: %d\n", ret);
|
||||
kfree(chip);
|
||||
return ret;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
ret = nand_register(devnum, mtd);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to register mtd device: %d\n", ret);
|
||||
kfree(chip);
|
||||
return ret;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
list_add_tail(&chip->node, &nfc->chips);
|
||||
|
||||
return 0;
|
||||
|
||||
err_free:
|
||||
kfree(chip);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int sunxi_nand_chips_init(struct udevice *dev, struct sunxi_nfc *nfc)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user