summaryrefslogtreecommitdiff
path: root/drivers/spi
diff options
context:
space:
mode:
authorJoe Burmeister <joe.burmeister@devtank.co.uk>2021-04-19 16:06:31 +0300
committerMark Brown <broonie@kernel.org>2021-04-19 16:18:46 +0300
commitc914dbf88fa8619602e0913e8a952a19631ed195 (patch)
tree47a370f8bd2a95996715f218db274b390df9caa5 /drivers/spi
parentd347b4aaa1a042ea528e385d9070b74c77a14321 (diff)
downloadlinux-c914dbf88fa8619602e0913e8a952a19631ed195.tar.xz
spi: Handle SPI device setup callback failure.
If the setup callback failed, but the controller has auto_runtime_pm and set_cs, the setup failure could be missed. Signed-off-by: Joe Burmeister <joe.burmeister@devtank.co.uk> Link: https://lore.kernel.org/r/20210419130631.4586-1-joe.burmeister@devtank.co.uk Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index cf231ff46781..cc6d43d7895f 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3378,8 +3378,15 @@ int spi_setup(struct spi_device *spi)
mutex_lock(&spi->controller->io_mutex);
- if (spi->controller->setup)
+ if (spi->controller->setup) {
status = spi->controller->setup(spi);
+ if (status) {
+ mutex_unlock(&spi->controller->io_mutex);
+ dev_err(&spi->controller->dev, "Failed to setup device: %d\n",
+ status);
+ return status;
+ }
+ }
if (spi->controller->auto_runtime_pm && spi->controller->set_cs) {
status = pm_runtime_get_sync(spi->controller->dev.parent);