spi: sync up initial chipselect state
authorDavid Bauer <mail@david-bauer.net>
Fri, 16 Apr 2021 19:59:56 +0000 (21:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 May 2021 12:47:22 +0000 (14:47 +0200)
commitc5aa9ea54a0006a984fc713632233d955e05d50f
treec81ee3911d205d44714df9228a5b3fe8aa4d98d3
parentb82e8f0bb0288406d2b3ac82104c6488cb18a4ee
spi: sync up initial chipselect state

[ Upstream commit d347b4aaa1a042ea528e385d9070b74c77a14321 ]

When initially probing the SPI slave device, the call for disabling an
SPI device without the SPI_CS_HIGH flag is not applied, as the
condition for checking whether or not the state to be applied equals the
one currently set evaluates to true.

This however might not necessarily be the case, as the chipselect might
be active.

Add a force flag to spi_set_cs which allows to override this
early exit condition. Set it to false everywhere except when called
from spi_setup to sync up the initial CS state.

Fixes commit d40f0b6f2e21 ("spi: Avoid setting the chip select if we don't
need to")

Signed-off-by: David Bauer <mail@david-bauer.net>
Link: https://lore.kernel.org/r/20210416195956.121811-1-mail@david-bauer.net
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi.c