Message ID | 1572426234-30019-1-git-send-email-luhua.xu@mediatek.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [V2] spi: add power control when set_cs | expand |
Hi, * Mark Brown <broonie@kernel.org> [191031 13:24]: > The patch > > spi: add power control when set_cs > > has been applied to the spi tree at > > https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.5 This patch causes a regression for many SPI devices as they assume spi_setup() return 0 on success and not a positive value. I've sent a fix for this as: spi: Fix regression to return zero on success instead of positive value Regards, Tony
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index f9502db..19007e0 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3091,7 +3091,20 @@ int spi_setup(struct spi_device *spi) if (spi->controller->setup) status = spi->controller->setup(spi); - spi_set_cs(spi, false); + if (spi->controller->auto_runtime_pm && spi->controller->set_cs) { + status = pm_runtime_get_sync(spi->controller->dev.parent); + if (status < 0) { + pm_runtime_put_noidle(spi->controller->dev.parent); + dev_err(&spi->controller->dev, "Failed to power device: %d\n", + status); + return status; + } + spi_set_cs(spi, false); + pm_runtime_mark_last_busy(spi->controller->dev.parent); + pm_runtime_put_autosuspend(spi->controller->dev.parent); + } else { + spi_set_cs(spi, false); + } if (spi->rt && !spi->controller->rt) { spi->controller->rt = true;