Re: [PATCH] spi: spidev: Fix so the module is autoloaded when built as external

From: Gustav Wiklander
Date: Tue Jan 05 2021 - 04:45:35 EST


On 1/4/21 10:34 PM, Mark Brown wrote:
On Mon, Jan 04, 2021 at 04:34:35PM +0100, Gustav Wiklander wrote:
From: Gustav Wiklander <gustavwi@xxxxxxxx>

The spi framework sets the modalias for the spi device to belong in
either the acpi device table or the SPI device table. It can never
be in the OF table. Therefore the spidev driver should populate the
spi device table rather than the OF table.

NOTE: platform drivers and i2c drivers support aliases in the
OF device table.

Why is this a good solution rather than ensuring the the OF IDs can be
used directly?


Hi Mark,

You suggestion is of course a solid alternative forward. However, the downside with supporting the OF device table for automatic module loading is that a lot of spi device drivers must be updated. Also
it is unclear what is the preferred way to do this in the kernel see
this patch:
https://lore.kernel.org/lkml/20190618052644.32446-1-bjorn.andersson@xxxxxxxxxx/

If adding support of OF device table the spi device drivers must now include a MODULE_DEVICE_TABLE(of,...) as the spi device alias will no longer match the alias in the module.

This command gives 186 spi device drivers.
git grep "MODULE_DEVICE_TABLE(spi" | wc -l
186

Best regards
Gustav Wiklander