[PATCH 13/26] spi: sh-msiof: fix controller deregistration

Johan Hovold
2026-04-10T08:18:57Z

Make sure to deregister the controller before releasing underlying
resources like DMA during driver unbind.

Fixes: 1bd6363bc0c6 ("spi: sh-msiof: Use core message handling instead of spi-bitbang")
Cc: stable@vger.kernel.org # 3.15
Cc: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/spi/spi-sh-msiof.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 7f3e08810560..f114b6313f4f 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -1289,9 +1289,9 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
if (ret < 0)
dev_warn(dev, "DMA not available, using PIO\n");

- ret = devm_spi_register_controller(dev, ctlr);
+ ret = spi_register_controller(ctlr);
if (ret < 0) {
- dev_err(dev, "devm_spi_register_controller error.\n");
+ dev_err(dev, "failed to register controller\n");
goto err2;
}

@@ -1309,8 +1309,14 @@ static void sh_msiof_spi_remove(struct platform_device *pdev)
{
struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);

+ spi_controller_get(p->ctlr);
+
+ spi_unregister_controller(p->ctlr);
+
sh_msiof_release_dma(p);
pm_runtime_disable(&pdev->dev);
+
+ spi_controller_put(p->ctlr);
}

static const struct platform_device_id spi_driver_ids[] = {
--
2.52.0