Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 764f1b748164 ("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>

authored by

Pei Xiao and committed by
Mark Brown
ab00feba 45daacbe

+14
+14
drivers/spi/spi-mtk-snfi.c
··· 1303 1303 .ecc = true, 1304 1304 }; 1305 1305 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 + 1306 1313 static irqreturn_t mtk_snand_irq(int irq, void *id) 1307 1314 { 1308 1315 struct mtk_snand *snf = id; ··· 1447 1440 ret = nand_ecc_register_on_host_hw_engine(&ms->ecc_eng); 1448 1441 if (ret) { 1449 1442 dev_err(&pdev->dev, "failed to register ecc engine.\n"); 1443 + goto release_ecc; 1444 + } 1445 + 1446 + ret = devm_add_action_or_reset(&pdev->dev, mtk_unregister_ecc_engine, 1447 + &ms->ecc_eng); 1448 + if (ret) { 1449 + dev_err_probe(&pdev->dev, ret, "failed to add ECC unregister action\n"); 1450 1450 goto release_ecc; 1451 1451 } 1452 1452