@@ -251,7 +251,8 @@ void fbtft_register_backlight(struct fbtft_par *par);
251
251
void fbtft_unregister_backlight (struct fbtft_par * par );
252
252
int fbtft_init_display (struct fbtft_par * par );
253
253
int fbtft_probe_common (struct fbtft_display * display , struct spi_device * sdev ,
254
- struct platform_device * pdev );
254
+ struct platform_device * pdev ,
255
+ const struct of_device_id * dt_ids );
255
256
void fbtft_remove_common (struct device * dev , struct fb_info * info );
256
257
257
258
/* fbtft-io.c */
@@ -272,42 +273,25 @@ void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...);
272
273
void fbtft_write_reg16_bus8 (struct fbtft_par * par , int len , ...);
273
274
void fbtft_write_reg16_bus16 (struct fbtft_par * par , int len , ...);
274
275
275
- #define FBTFT_DT_TABLE (_compatible ) \
276
- static const struct of_device_id dt_ids[] = { \
277
- { .compatible = _compatible }, \
278
- {}, \
279
- }; \
280
- MODULE_DEVICE_TABLE(of, dt_ids);
281
-
282
- #define FBTFT_SPI_DRIVER (_name , _compatible , _display , _spi_ids ) \
283
- \
284
- static int fbtft_driver_probe_spi(struct spi_device *spi) \
285
- { \
286
- return fbtft_probe_common(_display, spi, NULL); \
287
- } \
288
- \
289
- static void fbtft_driver_remove_spi(struct spi_device *spi) \
290
- { \
291
- struct fb_info *info = spi_get_drvdata(spi); \
292
- \
293
- fbtft_remove_common(&spi->dev, info); \
294
- } \
295
- \
296
- static struct spi_driver fbtft_driver_spi_driver = { \
297
- .driver = { \
298
- .name = _name, \
299
- .of_match_table = dt_ids, \
300
- }, \
301
- .id_table = _spi_ids, \
302
- .probe = fbtft_driver_probe_spi, \
303
- .remove = fbtft_driver_remove_spi, \
304
- };
305
-
306
- #define FBTFT_REGISTER_DRIVER (_name , _compatible , _display ) \
276
+ #define FBTFT_REGISTER_DRIVER_START (_display ) \
277
+ \
278
+ static const struct of_device_id dt_ids[]; \
279
+ \
280
+ static int fbtft_driver_probe_spi(struct spi_device *spi) \
281
+ { \
282
+ return fbtft_probe_common(_display, spi, NULL, dt_ids); \
283
+ } \
284
+ \
285
+ static void fbtft_driver_remove_spi(struct spi_device *spi) \
286
+ { \
287
+ struct fb_info *info = spi_get_drvdata(spi); \
288
+ \
289
+ fbtft_remove_common(&spi->dev, info); \
290
+ } \
307
291
\
308
292
static int fbtft_driver_probe_pdev(struct platform_device *pdev) \
309
293
{ \
310
- return fbtft_probe_common(_display, NULL, pdev); \
294
+ return fbtft_probe_common(_display, NULL, pdev, dt_ids); \
311
295
} \
312
296
\
313
297
static void fbtft_driver_remove_pdev(struct platform_device *pdev) \
@@ -317,9 +301,30 @@ static void fbtft_driver_remove_pdev(struct platform_device *pdev) \
317
301
fbtft_remove_common(&pdev->dev, info); \
318
302
} \
319
303
\
320
- FBTFT_DT_TABLE(_compatible) \
304
+ static const struct of_device_id dt_ids[] = {
305
+
306
+ #define FBTFT_COMPATIBLE (_compatible ) \
307
+ { .compatible = _compatible },
308
+
309
+ #define FBTFT_VARIANT_COMPATIBLE (_compatible , _variant ) \
310
+ { .compatible = _compatible, .data = _variant },
311
+
312
+ #define FBTFT_REGISTER_DRIVER_END (_name , _display ) \
313
+ \
314
+ {}, \
315
+ }; \
321
316
\
322
- FBTFT_SPI_DRIVER(_name, _compatible, _display, NULL) \
317
+ MODULE_DEVICE_TABLE(of, dt_ids); \
318
+ \
319
+ \
320
+ static struct spi_driver fbtft_driver_spi_driver = { \
321
+ .driver = { \
322
+ .name = _name, \
323
+ .of_match_table = dt_ids, \
324
+ }, \
325
+ .probe = fbtft_driver_probe_spi, \
326
+ .remove = fbtft_driver_remove_spi, \
327
+ }; \
323
328
\
324
329
static struct platform_driver fbtft_driver_platform_driver = { \
325
330
.driver = { \
@@ -355,18 +360,49 @@ module_exit(fbtft_driver_module_exit);
355
360
356
361
#define FBTFT_REGISTER_SPI_DRIVER (_name , _comp_vend , _comp_dev , _display ) \
357
362
\
358
- FBTFT_DT_TABLE(_comp_vend "," _comp_dev) \
363
+ static const struct of_device_id dt_ids[] = { \
364
+ { .compatible = _comp_vend "," _comp_dev }, \
365
+ {}, \
366
+ }; \
367
+ \
368
+ static int fbtft_driver_probe_spi(struct spi_device *spi) \
369
+ { \
370
+ return fbtft_probe_common(_display, spi, NULL, dt_ids); \
371
+ } \
372
+ \
373
+ static void fbtft_driver_remove_spi(struct spi_device *spi) \
374
+ { \
375
+ struct fb_info *info = spi_get_drvdata(spi); \
376
+ \
377
+ fbtft_remove_common(&spi->dev, info); \
378
+ } \
379
+ \
380
+ MODULE_DEVICE_TABLE(of, dt_ids); \
359
381
\
360
382
static const struct spi_device_id spi_ids[] = { \
361
383
{ .name = _comp_dev }, \
362
384
{}, \
363
385
}; \
386
+ \
364
387
MODULE_DEVICE_TABLE(spi, spi_ids); \
365
388
\
366
- FBTFT_SPI_DRIVER(_name, _comp_vend "," _comp_dev, _display, spi_ids) \
389
+ static struct spi_driver fbtft_driver_spi_driver = { \
390
+ .driver = { \
391
+ .name = _name, \
392
+ .of_match_table = dt_ids, \
393
+ }, \
394
+ .id_table = spi_ids, \
395
+ .probe = fbtft_driver_probe_spi, \
396
+ .remove = fbtft_driver_remove_spi, \
397
+ }; \
367
398
\
368
399
module_spi_driver(fbtft_driver_spi_driver);
369
400
401
+ #define FBTFT_REGISTER_DRIVER (_name , _compatible , _display ) \
402
+ FBTFT_REGISTER_DRIVER_START(_display) \
403
+ FBTFT_COMPATIBLE(_compatible) \
404
+ FBTFT_REGISTER_DRIVER_END(_name, _display)
405
+
370
406
/* Debug macros */
371
407
372
408
/* shorthand debug levels */
0 commit comments