Skip to content

Commit ab00feb

Browse files
Pei Xiaobroonie
authored andcommitted
spi: mtk-snfi: unregister ECC engine on probe failure and remove() callback
mtk_snand_probe() registers the on-host NAND ECC engine, but teardown was missing from both probe unwind and remove-time cleanup. Add a devm cleanup action after successful registration so nand_ecc_unregister_on_host_hw_engine() runs automatically on probe failures and during device removal. Fixes: 764f1b7 ("spi: add driver for MTK SPI NAND Flash Interface") Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn> Link: https://patch.msgid.link/20263f885f1a9c9d559f95275298cd6de4b11ed5.1775546401.git.xiaopei01@kylinos.cn Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 45daacb commit ab00feb

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

drivers/spi/spi-mtk-snfi.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,13 @@ static const struct spi_controller_mem_caps mtk_snand_mem_caps = {
13031303
.ecc = true,
13041304
};
13051305

1306+
static void mtk_unregister_ecc_engine(void *data)
1307+
{
1308+
struct nand_ecc_engine *eng = data;
1309+
1310+
nand_ecc_unregister_on_host_hw_engine(eng);
1311+
}
1312+
13061313
static irqreturn_t mtk_snand_irq(int irq, void *id)
13071314
{
13081315
struct mtk_snand *snf = id;
@@ -1443,6 +1450,13 @@ static int mtk_snand_probe(struct platform_device *pdev)
14431450
goto release_ecc;
14441451
}
14451452

1453+
ret = devm_add_action_or_reset(&pdev->dev, mtk_unregister_ecc_engine,
1454+
&ms->ecc_eng);
1455+
if (ret) {
1456+
dev_err_probe(&pdev->dev, ret, "failed to add ECC unregister action\n");
1457+
goto release_ecc;
1458+
}
1459+
14461460
ctlr->num_chipselect = 1;
14471461
ctlr->mem_ops = &mtk_snand_mem_ops;
14481462
ctlr->mem_caps = &mtk_snand_mem_caps;

0 commit comments

Comments
 (0)