Skip to content

Commit 8485567

Browse files
l1kbroonie
authored andcommitted
spi: Fix controller unregister order
When an SPI controller unregisters, it unbinds all its slave devices. For this, their drivers may need to access the SPI bus, e.g. to quiesce interrupts. However since commit ffbbdd2 ("spi: create a message queueing infrastructure"), spi_destroy_queue() is executed before unbinding the slaves. It sets ctlr->running = false, thereby preventing SPI bus access and causing unbinding of slave devices to fail. Fix by unbinding slaves before calling spi_destroy_queue(). Fixes: ffbbdd2 ("spi: create a message queueing infrastructure") Signed-off-by: Lukas Wunner <[email protected]> Cc: [email protected] # v3.4+ Cc: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/8aaf9d44c153fe233b17bc2dec4eb679898d7e7b.1589557526.git.lukas@wunner.de Signed-off-by: Mark Brown <[email protected]>
1 parent 0392727 commit 8485567

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/spi/spi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2763,6 +2763,8 @@ void spi_unregister_controller(struct spi_controller *ctlr)
27632763
struct spi_controller *found;
27642764
int id = ctlr->bus_num;
27652765

2766+
device_for_each_child(&ctlr->dev, NULL, __unregister);
2767+
27662768
/* First make sure that this controller was ever added */
27672769
mutex_lock(&board_lock);
27682770
found = idr_find(&spi_master_idr, id);
@@ -2775,7 +2777,6 @@ void spi_unregister_controller(struct spi_controller *ctlr)
27752777
list_del(&ctlr->list);
27762778
mutex_unlock(&board_lock);
27772779

2778-
device_for_each_child(&ctlr->dev, NULL, __unregister);
27792780
device_unregister(&ctlr->dev);
27802781
/* free bus id */
27812782
mutex_lock(&board_lock);

0 commit comments

Comments
 (0)