mirror of
https://github.com/torvalds/linux.git
synced 2026-12-03 11:53:53 +00:00
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
This commit is contained in:
+11
-6
@@ -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 ||
|
||||
|
||||
Reference in New Issue
Block a user