[PATCH 2/8] spi: cadence-quadspi: fix controller deregistration

Johan Hovold
2026-04-14T13:45:41Z

Make sure to deregister the controller before dropping the reference
count that allows new operations to start to allow SPI drivers to do I/O
during deregistration.

Fixes: 7446284023e8 ("spi: cadence-quadspi: Implement refcount to handle unbind during busy")
Cc: stable@vger.kernel.org # 6.17
Cc: Khairul Anuar Romli <khairul.anuar.romli@altera.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/spi/spi-cadence-quadspi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 2ead419e896e..50ef65fc5ded 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -2020,13 +2020,13 @@ static void cqspi_remove(struct platform_device *pdev)

ddata = of_device_get_match_data(dev);

+ spi_unregister_controller(cqspi->host);
+
refcount_set(&cqspi->refcount, 0);

if (!refcount_dec_and_test(&cqspi->inflight_ops))
cqspi_wait_idle(cqspi);

- spi_unregister_controller(cqspi->host);
-
if (cqspi->rx_chan)
dma_release_channel(cqspi->rx_chan);

--
2.52.0