Skip to content

Commit

Permalink
spi: Handle SPI device setup callback failure.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joe Burmeister authored and Mark Brown committed Apr 19, 2021
1 parent d347b4a commit c914dbf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c914dbf

Please sign in to comment.