After 5fa6863ba692 ("spi: Check we have a spi_device_id for each DT compatible") we need to add spi id_tables. Changing existing macro FBTFT_REGISTER_DRIVER would have meant to change arguments and therefore adjust all fbtft drivers.
This series adds a new and simplified macro FBTFT_REGISTER_SPI_DRIVER that includes a spi id_table, and in addition to that: - does not define a platform driver - uses macro module_spi_driver()
Also the MODULE_ALIASes can be removed.
Works for me with a SH1106-based OLED display incl. module autoload. For now I changed this driver only because I have hw to test it.
v2: - consider that spi id_table name consists of device part of compatible string only - instead of changing the existing macro, add a new one and make fb_sh1106 the first user
Heiner Kallweit (2): staging: fbtft: add macro FBTFT_REGISTER_SPI_DRIVER staging: fbtft: sh1106: use new macro FBTFT_REGISTER_SPI_DRIVER
drivers/staging/fbtft/fb_sh1106.c | 7 +----- drivers/staging/fbtft/fbtft.h | 41 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 6 deletions(-)
After 5fa6863ba692 ("spi: Check we have a spi_device_id for each DT compatible") we need to add spi id_tables. Changing existing macro FBTFT_REGISTER_DRIVER would have meant to change arguments and therefore adjust all fbtft drivers.
This patch adds a new and simplified macro FBTFT_REGISTER_SPI_DRIVER that includes a spi id_table, and in addition to that: - does not define a platform driver - uses macro module_spi_driver()
Signed-off-by: Heiner Kallweit hkallweit1@gmail.com --- drivers/staging/fbtft/fbtft.h | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h index 6869f3603..4cdec34e2 100644 --- a/drivers/staging/fbtft/fbtft.h +++ b/drivers/staging/fbtft/fbtft.h @@ -346,6 +346,47 @@ static void __exit fbtft_driver_module_exit(void) \ module_init(fbtft_driver_module_init); \ module_exit(fbtft_driver_module_exit);
+#define FBTFT_REGISTER_SPI_DRIVER(_name, _comp_vend, _comp_dev, _display) \ + \ +static int fbtft_driver_probe_spi(struct spi_device *spi) \ +{ \ + return fbtft_probe_common(_display, spi, NULL); \ +} \ + \ +static int fbtft_driver_remove_spi(struct spi_device *spi) \ +{ \ + struct fb_info *info = spi_get_drvdata(spi); \ + \ + fbtft_remove_common(&spi->dev, info); \ + return 0; \ +} \ + \ +static const struct of_device_id dt_ids[] = { \ + { .compatible = _comp_vend "," _comp_dev }, \ + {}, \ +}; \ + \ +MODULE_DEVICE_TABLE(of, dt_ids); \ + \ +static const struct spi_device_id spi_ids[] = { \ + { .name = _comp_dev }, \ + {}, \ +}; \ + \ +MODULE_DEVICE_TABLE(spi, spi_ids); \ + \ +static struct spi_driver fbtft_driver_spi_driver = { \ + .driver = { \ + .name = _name, \ + .of_match_table = dt_ids, \ + }, \ + .id_table = spi_ids, \ + .probe = fbtft_driver_probe_spi, \ + .remove = fbtft_driver_remove_spi, \ +}; \ + \ +module_spi_driver(fbtft_driver_spi_driver); + /* Debug macros */
/* shorthand debug levels */
Make fb_sh1106 the first user of new macro FBTFT_REGISTER_SPI_DRIVER. In addition the MODULE_ALIASes can be removed. Module auto-loading was successfully tested with a SH1106-based OLED module connected to an Odroid C2.
Signed-off-by: Heiner Kallweit hkallweit1@gmail.com --- drivers/staging/fbtft/fb_sh1106.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/staging/fbtft/fb_sh1106.c b/drivers/staging/fbtft/fb_sh1106.c index 7b9ab39e1..9685ca516 100644 --- a/drivers/staging/fbtft/fb_sh1106.c +++ b/drivers/staging/fbtft/fb_sh1106.c @@ -173,12 +173,7 @@ static struct fbtft_display display = { }, };
-FBTFT_REGISTER_DRIVER(DRVNAME, "sinowealth,sh1106", &display); - -MODULE_ALIAS("spi:" DRVNAME); -MODULE_ALIAS("platform:" DRVNAME); -MODULE_ALIAS("spi:sh1106"); -MODULE_ALIAS("platform:sh1106"); +FBTFT_REGISTER_SPI_DRIVER(DRVNAME, "sinowealth", "sh1106", &display);
MODULE_DESCRIPTION("SH1106 OLED Driver"); MODULE_AUTHOR("Heiner Kallweit");
dri-devel@lists.freedesktop.org