Skip to content

Commit 86357e1

Browse files
Pei Xiaogregkh
authored andcommitted
spi: mtk-snfi: unregister ECC engine on probe failure and remove() callback
[ Upstream commit ab00feb ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0109830 commit 86357e1

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
@@ -1307,6 +1307,13 @@ static const struct spi_controller_mem_caps mtk_snand_mem_caps = {
13071307
.ecc = true,
13081308
};
13091309

1310+
static void mtk_unregister_ecc_engine(void *data)
1311+
{
1312+
struct nand_ecc_engine *eng = data;
1313+
1314+
nand_ecc_unregister_on_host_hw_engine(eng);
1315+
}
1316+
13101317
static irqreturn_t mtk_snand_irq(int irq, void *id)
13111318
{
13121319
struct mtk_snand *snf = id;
@@ -1447,6 +1454,13 @@ static int mtk_snand_probe(struct platform_device *pdev)
14471454
goto release_ecc;
14481455
}
14491456

1457+
ret = devm_add_action_or_reset(&pdev->dev, mtk_unregister_ecc_engine,
1458+
&ms->ecc_eng);
1459+
if (ret) {
1460+
dev_err_probe(&pdev->dev, ret, "failed to add ECC unregister action\n");
1461+
goto release_ecc;
1462+
}
1463+
14501464
ctlr->num_chipselect = 1;
14511465
ctlr->mem_ops = &mtk_snand_mem_ops;
14521466
ctlr->mem_caps = &mtk_snand_mem_caps;

0 commit comments

Comments
 (0)