Message ID | 20241217114226.1223724-2-u.kleine-koenig@baylibre.com |
---|---|
State | New |
Headers | show |
Series | spi: spidev: Align ordering of spidev_spi_ids[] and spidev_dt_ids[] | expand |
On Wed, Dec 18, 2024 at 8:02 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > Further improvements could be: > - Generate spidev_spi_ids[] from spidev_dt_ids[] at runtime > during module_init() (consumes cycles :-(, > - Teach the subsystem matching code to strip the vendor prefix, > to get rid of spidev_spi_ids[]. Oops, and modutils, as the tables are used by userspace :-( Gr{oetje,eeting}s, Geert
Hello Geert, On Wed, Dec 18, 2024 at 08:10:57PM +0100, Geert Uytterhoeven wrote: > On Wed, Dec 18, 2024 at 8:02 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > Further improvements could be: > > - Generate spidev_spi_ids[] from spidev_dt_ids[] at runtime > > during module_init() (consumes cycles :-(, > > - Teach the subsystem matching code to strip the vendor prefix, > > to get rid of spidev_spi_ids[]. > > Oops, and modutils, as the tables are used by userspace :-( Then how about a build-time check comparing spi and of module info? Best regards Uwe
Hi Uwe, On Thu, Dec 19, 2024 at 9:02 AM Uwe Kleine-König <u.kleine-koenig@baylibre.com> wrote: > On Wed, Dec 18, 2024 at 08:10:57PM +0100, Geert Uytterhoeven wrote: > > On Wed, Dec 18, 2024 at 8:02 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > > Further improvements could be: > > > - Generate spidev_spi_ids[] from spidev_dt_ids[] at runtime > > > during module_init() (consumes cycles :-(, > > > - Teach the subsystem matching code to strip the vendor prefix, > > > to get rid of spidev_spi_ids[]. > > > > Oops, and modutils, as the tables are used by userspace :-( > > Then how about a build-time check comparing spi and of module info? That's a good and non-disruptive idea, also for i2c! Gr{oetje,eeting}s, Geert
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 2b87b9ae56c0..58ae4304fdab 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -698,20 +698,24 @@ static const struct class spidev_class = { .name = "spidev", }; +/* + * The spi device ids are expected to match the device names of the + * spidev_dt_ids array below. Both arrays are kept in the same ordering. + */ static const struct spi_device_id spidev_spi_ids[] = { - { .name = "bh2228fv" }, - { .name = "dh2228fv" }, - { .name = "jg10309-01" }, - { .name = "ltc2488" }, - { .name = "sx1301" }, - { .name = "bk4" }, - { .name = "bk4-spi" }, - { .name = "dhcom-board" }, - { .name = "m53cpld" }, - { .name = "spi-petra" }, - { .name = "spi-authenta" }, - { .name = "em3581" }, - { .name = "si3210" }, + { .name = /* cisco */ "spi-petra" }, + { .name = /* dh */ "dhcom-board" }, + { .name = /* elgin */ "jg10309-01" }, + { .name = /* lineartechnology */ "ltc2488" }, + { .name = /* lwn */ "bk4" }, + { .name = /* lwn */ "bk4-spi" }, + { .name = /* menlo */ "m53cpld" }, + { .name = /* micron */ "spi-authenta" }, + { .name = /* rohm */ "bh2228fv" }, + { .name = /* rohm */ "dh2228fv" }, + { .name = /* semtech */ "sx1301" }, + { .name = /* silabs */ "em3581" }, + { .name = /* silabs */ "si3210" }, {}, }; MODULE_DEVICE_TABLE(spi, spidev_spi_ids);
There is a 1:1 correspondance between the list of spi device-ids and the devicetree compatibles. The latter is ordered alphabetically by vendor and device. To simplify keeping the two lists in sync, mention the vendor in a comment for the spi device-ids and order alphabetically, too. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> --- drivers/spi/spidev.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) base-commit: fdb298fa865b0136f7be842e6c2e6310dede421a