Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: spidev: Make probe to fail early if a spidev compatible is used

Some Device Trees don't use a real device name in the compatible string
for SPI devices nodes, abusing the fact that the spidev driver name is
used to match as a fallback when a SPI device ID table is not defined.

But since commit 6840615f85f6 ("spi: spidev: Add SPI ID table") a table
for SPI device IDs was added to the driver breaking the assumption that
these DTs were relying on.

There has been a warning message for some time since commit 956b200a846e
("spi: spidev: Warn loudly if instantiated from DT as "spidev""), making
quite clear that this case is not really supported by the spidev driver.

Since these devices won't match anyways after the mentioned commit, there
is no point to continue if an spidev compatible is used. Let's just make
the driver probe to fail early.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/r/20211109225920.1158920-1-javierm@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Javier Martinez Canillas and committed by
Mark Brown
fffc84fd 44ec41b7

+4 -3
+4 -3
drivers/spi/spidev.c
··· 751 751 * compatible string, it is a Linux implementation thing 752 752 * rather than a description of the hardware. 753 753 */ 754 - WARN(spi->dev.of_node && 755 - of_device_is_compatible(spi->dev.of_node, "spidev"), 756 - "%pOF: buggy DT: spidev listed directly in DT\n", spi->dev.of_node); 754 + if (spi->dev.of_node && of_device_is_compatible(spi->dev.of_node, "spidev")) { 755 + dev_err(&spi->dev, "spidev listed directly in DT is not supported\n"); 756 + return -EINVAL; 757 + } 757 758 758 759 spidev_probe_acpi(spi); 759 760