On Wed, Dec 18, 2024 at 11:32:16AM +0100, Geert Uytterhoeven wrote: > Hi Uwe, > > On Tue, Dec 17, 2024 at 12:42 PM Uwe Kleine-König > <u.kleine-koenig@xxxxxxxxxxxx> wrote: > > 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@xxxxxxxxxxxx> > > Thanks for your patch! > > > --- 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" }, > > Pity we can't use > > { .name = strchr("cisco,spi-petra", ',') + 1 }, My suggestion is nice enough IMHO. > else we could do some macros on top to keep the tables in sync... I thought about that already before sending this patch. The best one I came up with is: static const struct spi_device_id spidev_spi_ids[] = { #define DEVICE(vendor, devname) { .name = devname }, #include "spidevices.c" #undef DEVICE {} }; MODULE_DEVICE_TABLE(spi, spidev_spi_ids); static const struct of_device_id spidev_dt_ids[] = { #define DEVICE(vendor, devname) { .compatible = vendor "," devname, .data = &spidev_of_check }, #include "spidevices.c" #undef DEVICE {} }; MODULE_DEVICE_TABLE(of, spidev_dt_ids); where spidevices.c looks as follows: DEVICE("cisco", "spi-petra") DEVICE("dh", "dhcom-board") DEVICE("elgin", "jg10309-01") DEVICE("lineartechnology", "ltc2488") DEVICE("lwn", "bk4") DEVICE("menlo", "m53cpld") DEVICE("micron", "spi-authenta") DEVICE("rohm", "bh2228fv") DEVICE("rohm", "dh2228fv") DEVICE("semtech", "sx1301") DEVICE("silabs", "em3581") DEVICE("silabs", "si3210") I didn't like that enough to propose it. Also I didn't test, but I think this could work. Best regards Uwe
Attachment:
signature.asc
Description: PGP signature