* [PATCH] spi: core: Only check bits_per_word validity when explicitly provided
@ 2022-04-12 12:22 Paul Kocialkowski
2022-04-12 20:43 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Paul Kocialkowski @ 2022-04-12 12:22 UTC (permalink / raw)
To: linux-spi, linux-kernel; +Cc: Mark Brown, Thomas Petazzoni, Paul Kocialkowski
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>
---
drivers/spi/spi.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 2e6d6bbeb784..563a56ce34a0 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3518,13 +3518,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 ||
--
2.35.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] spi: core: Only check bits_per_word validity when explicitly provided
2022-04-12 12:22 [PATCH] spi: core: Only check bits_per_word validity when explicitly provided Paul Kocialkowski
@ 2022-04-12 20:43 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2022-04-12 20:43 UTC (permalink / raw)
To: linux-spi, linux-kernel, paul.kocialkowski; +Cc: thomas.petazzoni
On Tue, 12 Apr 2022 14:22:07 +0200, Paul Kocialkowski wrote:
> 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.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: core: Only check bits_per_word validity when explicitly provided
commit: b3fe2e516741368a643d79527ebccfe557217a53
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-12 21:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 12:22 [PATCH] spi: core: Only check bits_per_word validity when explicitly provided Paul Kocialkowski
2022-04-12 20:43 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®