spi: Check we have a spi_device_id for each DT compatible
authorMark Brown <broonie@kernel.org>
Tue, 21 Sep 2021 19:21:49 +0000 (20:21 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 22 Sep 2021 12:23:33 +0000 (13:23 +0100)
commit5fa6863ba69265cb7e45567d12614790ff26bd56
tree32ecf93f86d382ee8d94f61560eeb15459c89464
parentf1e5ecc5b7cc9d91ce975680a2f1f84b235f7e07
spi: Check we have a spi_device_id for each DT compatible

Currently for SPI devices we use the spi_device_id for module autoloading
even on systems using device tree, meaning that listing a compatible string
in the of_match_table isn't enough to have the module for a SPI driver
autoloaded.

We attempted to fix this by generating OF based modaliases for devices
instantiated from DT in 3ce6c9e2617e ("spi: add of_device_uevent_modalias
support") but this meant we no longer reported spi_device_id based aliases
which broke drivers such as spi-nor which don't list all the compatible
strings they support directly for DT, and in at least that case it's not
super practical to do so given the very large number of compatibles
needed, much larger than the number spi_device_ids due to vendor strings.
As a result fell back to using spi_device_id based modalises.

Try to close the gap by printing a warning when a SPI driver has a DT
compatible that won't be matched as a SPI device ID with the goal of having
drivers provide both. Given fallback compatibles this check is going to be
excessive but it should be robust which is probably more important here.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210921192149.50740-1-broonie@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c