diff options
author | Paul Kocialkowski <paul.kocialkowski@bootlin.com> | 2022-04-12 14:22:07 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2022-04-12 17:17:21 +0100 |
commit | b3fe2e516741368a643d79527ebccfe557217a53 (patch) | |
tree | ebc4ba21b57446cdbde278bbab5c285c9903c283 /drivers/spi/spi.c | |
parent | c6cf1fafb65dda10f3babcec76991cbc304d02b9 (diff) | |
download | linux-b3fe2e516741368a643d79527ebccfe557217a53.tar.bz2 |
spi: core: Only check bits_per_word validity when explicitly provided
On SPI device probe, the core will call spi_setup in spi_add_device
before the corresponding driver was probed. When this happens, the
bits_per_word member of the device is not yet set by the driver,
resulting in the default being set to 8 bits-per-word.
However some controllers do not support 8 bits-per-word at all, which
results in a failure when checking the bits-per-word validity.
In order to support these devices, skip the bits-per-word validity
check when it is not explicitly provided by drivers.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Link: https://lore.kernel.org/r/20220412122207.130181-1-paul.kocialkowski@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index c4dd1200fe99..3d4dddd1b456 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3513,13 +3513,18 @@ int spi_setup(struct spi_device *spi) return -EINVAL; } - if (!spi->bits_per_word) + if (!spi->bits_per_word) { spi->bits_per_word = 8; - - status = __spi_validate_bits_per_word(spi->controller, - spi->bits_per_word); - if (status) - return status; + } else { + /* + * Some controllers may not support the default 8 bits-per-word + * so only perform the check when this is explicitly provided. + */ + status = __spi_validate_bits_per_word(spi->controller, + spi->bits_per_word); + if (status) + return status; + } if (spi->controller->max_speed_hz && (!spi->max_speed_hz || |