]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: slave-mt27xx: fix controller deregistration
authorJohan Hovold <johan@kernel.org>
Fri, 10 Apr 2026 08:17:45 +0000 (10:17 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 10 Apr 2026 12:22:36 +0000 (13:22 +0100)
Make sure to deregister the controller before disabling underlying
resources like clocks (by disabling runtime PM) during driver unbind.

Fixes: 805be7ddf367 ("spi: mediatek: add spi slave for Mediatek MT2712")
Cc: stable@vger.kernel.org # 4.20
Cc: Leilk Liu <leilk.liu@mediatek.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260410081757.503099-16-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-slave-mt27xx.c

index ce889cb33228f38cb8b4c2c71093534e56ecbc06..7aedeaa5889db2fedb61f82112684b8b0eff6ce8 100644 (file)
@@ -453,7 +453,7 @@ static int mtk_spi_slave_probe(struct platform_device *pdev)
 
        pm_runtime_enable(&pdev->dev);
 
-       ret = devm_spi_register_controller(&pdev->dev, ctlr);
+       ret = spi_register_controller(ctlr);
        clk_disable_unprepare(mdata->spi_clk);
        if (ret) {
                dev_err(&pdev->dev,
@@ -473,7 +473,15 @@ err_put_ctlr:
 
 static void mtk_spi_slave_remove(struct platform_device *pdev)
 {
+       struct spi_controller *ctlr = platform_get_drvdata(pdev);
+
+       spi_controller_get(ctlr);
+
+       spi_unregister_controller(ctlr);
+
        pm_runtime_disable(&pdev->dev);
+
+       spi_controller_put(ctlr);
 }
 
 #ifdef CONFIG_PM_SLEEP