Skip to content

Commit c914dbf

Browse files
jabjoebroonie
authored andcommitted
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>
1 parent d347b4a commit c914dbf

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/spi/spi.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3378,8 +3378,15 @@ int spi_setup(struct spi_device *spi)
33783378

33793379
mutex_lock(&spi->controller->io_mutex);
33803380

3381-
if (spi->controller->setup)
3381+
if (spi->controller->setup) {
33823382
status = spi->controller->setup(spi);
3383+
if (status) {
3384+
mutex_unlock(&spi->controller->io_mutex);
3385+
dev_err(&spi->controller->dev, "Failed to setup device: %d\n",
3386+
status);
3387+
return status;
3388+
}
3389+
}
33833390

33843391
if (spi->controller->auto_runtime_pm && spi->controller->set_cs) {
33853392
status = pm_runtime_get_sync(spi->controller->dev.parent);

0 commit comments

Comments
 (0)