Merge branch 'for-5.7' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[linux-2.6-microblaze.git] / drivers / spi / spi.c
index c083ee3..d32bdc6 100644 (file)
@@ -2761,6 +2761,8 @@ void spi_unregister_controller(struct spi_controller *ctlr)
        struct spi_controller *found;
        int id = ctlr->bus_num;
 
+       device_for_each_child(&ctlr->dev, NULL, __unregister);
+
        /* First make sure that this controller was ever added */
        mutex_lock(&board_lock);
        found = idr_find(&spi_master_idr, id);
@@ -2773,7 +2775,6 @@ void spi_unregister_controller(struct spi_controller *ctlr)
        list_del(&ctlr->list);
        mutex_unlock(&board_lock);
 
-       device_for_each_child(&ctlr->dev, NULL, __unregister);
        device_unregister(&ctlr->dev);
        /* free bus id */
        mutex_lock(&board_lock);