]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
spi: Don't have controller clean up spi device before driver unbind
authorSaravana Kannan <saravanak@google.com>
Wed, 5 May 2021 16:47:34 +0000 (09:47 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jun 2021 09:59:38 +0000 (11:59 +0200)
[ Upstream commit 27e7db56cf3dffd302bd7ddfacb1d405cf671a2a ]

When a spi device is unregistered and triggers a driver unbind, the
driver might need to access the spi device. So, don't have the
controller clean up the spi device before the driver is unbound. Clean
up the spi device after the driver is unbound.

Fixes: c7299fea6769 ("spi: Fix spi device unregister flow")
Reported-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Saravana Kannan <saravanak@google.com>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210505164734.175546-1-saravanak@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi.c

index c4b80cf825b8bf5e508b6af56fd857cabdf5550b..f8f3434d5ab1e5286473143485c224700a32f0a7 100644 (file)
@@ -708,15 +708,15 @@ void spi_unregister_device(struct spi_device *spi)
        if (!spi)
                return;
 
-       spi_cleanup(spi);
-
        if (spi->dev.of_node) {
                of_node_clear_flag(spi->dev.of_node, OF_POPULATED);
                of_node_put(spi->dev.of_node);
        }
        if (ACPI_COMPANION(&spi->dev))
                acpi_device_clear_enumerated(ACPI_COMPANION(&spi->dev));
-       device_unregister(&spi->dev);
+       device_del(&spi->dev);
+       spi_cleanup(spi);
+       put_device(&spi->dev);
 }
 EXPORT_SYMBOL_GPL(spi_unregister_device);