Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: omapdrm: Simplify platform registration

Currently, calls into each file are used to register the various
platform drivers. Change this to a table of pointers to platform_driver
structs to allow using platform_register_drivers.

Signed-off-by: Andrew F. Davis <afd@ti.com>

authored by

Andrew F. Davis and committed by
Tomi Valkeinen
d66c36a3 bb5cdf8d

+36 -124
+15 -38
drivers/gpu/drm/omapdrm/dss/core.c
··· 28 28 #include "dss.h" 29 29 30 30 /* INIT */ 31 - static int (*dss_output_drv_reg_funcs[])(void) __initdata = { 32 - dss_init_platform_driver, 33 - dispc_init_platform_driver, 31 + static struct platform_driver * const omap_dss_drivers[] = { 32 + &omap_dsshw_driver, 33 + &omap_dispchw_driver, 34 34 #ifdef CONFIG_OMAP2_DSS_DSI 35 - dsi_init_platform_driver, 35 + &omap_dsihw_driver, 36 36 #endif 37 37 #ifdef CONFIG_OMAP2_DSS_VENC 38 - venc_init_platform_driver, 38 + &omap_venchw_driver, 39 39 #endif 40 40 #ifdef CONFIG_OMAP4_DSS_HDMI 41 - hdmi4_init_platform_driver, 41 + &omapdss_hdmi4hw_driver, 42 42 #endif 43 43 #ifdef CONFIG_OMAP5_DSS_HDMI 44 - hdmi5_init_platform_driver, 44 + &omapdss_hdmi5hw_driver, 45 45 #endif 46 - }; 47 - 48 - static void (*dss_output_drv_unreg_funcs[])(void) = { 49 - #ifdef CONFIG_OMAP5_DSS_HDMI 50 - hdmi5_uninit_platform_driver, 51 - #endif 52 - #ifdef CONFIG_OMAP4_DSS_HDMI 53 - hdmi4_uninit_platform_driver, 54 - #endif 55 - #ifdef CONFIG_OMAP2_DSS_VENC 56 - venc_uninit_platform_driver, 57 - #endif 58 - #ifdef CONFIG_OMAP2_DSS_DSI 59 - dsi_uninit_platform_driver, 60 - #endif 61 - dispc_uninit_platform_driver, 62 - dss_uninit_platform_driver, 63 46 }; 64 47 65 48 static struct platform_device *omap_drm_device; ··· 50 67 static int __init omap_dss_init(void) 51 68 { 52 69 int r; 53 - int i; 54 70 55 - for (i = 0; i < ARRAY_SIZE(dss_output_drv_reg_funcs); ++i) { 56 - r = dss_output_drv_reg_funcs[i](); 57 - if (r) 58 - goto err_reg; 59 - } 71 + r = platform_register_drivers(omap_dss_drivers, 72 + ARRAY_SIZE(omap_dss_drivers)); 73 + if (r) 74 + goto err_reg; 60 75 61 76 omap_drm_device = platform_device_register_simple("omapdrm", 0, NULL, 0); 62 77 if (IS_ERR(omap_drm_device)) { ··· 65 84 return 0; 66 85 67 86 err_reg: 68 - for (i = ARRAY_SIZE(dss_output_drv_reg_funcs) - i; 69 - i < ARRAY_SIZE(dss_output_drv_reg_funcs); 70 - ++i) 71 - dss_output_drv_unreg_funcs[i](); 87 + platform_unregister_drivers(omap_dss_drivers, 88 + ARRAY_SIZE(omap_dss_drivers)); 72 89 73 90 return r; 74 91 } 75 92 76 93 static void __exit omap_dss_exit(void) 77 94 { 78 - int i; 79 - 80 95 platform_device_unregister(omap_drm_device); 81 96 82 - for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i) 83 - dss_output_drv_unreg_funcs[i](); 97 + platform_unregister_drivers(omap_dss_drivers, 98 + ARRAY_SIZE(omap_dss_drivers)); 84 99 } 85 100 86 101 module_init(omap_dss_init);
+1 -11
drivers/gpu/drm/omapdrm/dss/dispc.c
··· 4696 4696 .runtime_resume = dispc_runtime_resume, 4697 4697 }; 4698 4698 4699 - static struct platform_driver omap_dispchw_driver = { 4699 + struct platform_driver omap_dispchw_driver = { 4700 4700 .probe = dispc_probe, 4701 4701 .remove = dispc_remove, 4702 4702 .driver = { ··· 4706 4706 .suppress_bind_attrs = true, 4707 4707 }, 4708 4708 }; 4709 - 4710 - int __init dispc_init_platform_driver(void) 4711 - { 4712 - return platform_driver_register(&omap_dispchw_driver); 4713 - } 4714 - 4715 - void dispc_uninit_platform_driver(void) 4716 - { 4717 - platform_driver_unregister(&omap_dispchw_driver); 4718 - }
+1 -11
drivers/gpu/drm/omapdrm/dss/dsi.c
··· 5658 5658 .runtime_resume = dsi_runtime_resume, 5659 5659 }; 5660 5660 5661 - static struct platform_driver omap_dsihw_driver = { 5661 + struct platform_driver omap_dsihw_driver = { 5662 5662 .probe = dsi_probe, 5663 5663 .remove = dsi_remove, 5664 5664 .driver = { ··· 5668 5668 .suppress_bind_attrs = true, 5669 5669 }, 5670 5670 }; 5671 - 5672 - int __init dsi_init_platform_driver(void) 5673 - { 5674 - return platform_driver_register(&omap_dsihw_driver); 5675 - } 5676 - 5677 - void dsi_uninit_platform_driver(void) 5678 - { 5679 - platform_driver_unregister(&omap_dsihw_driver); 5680 - }
+1 -11
drivers/gpu/drm/omapdrm/dss/dss.c
··· 1534 1534 .runtime_resume = dss_runtime_resume, 1535 1535 }; 1536 1536 1537 - static struct platform_driver omap_dsshw_driver = { 1537 + struct platform_driver omap_dsshw_driver = { 1538 1538 .probe = dss_probe, 1539 1539 .remove = dss_remove, 1540 1540 .shutdown = dss_shutdown, ··· 1545 1545 .suppress_bind_attrs = true, 1546 1546 }, 1547 1547 }; 1548 - 1549 - int __init dss_init_platform_driver(void) 1550 - { 1551 - return platform_driver_register(&omap_dsshw_driver); 1552 - } 1553 - 1554 - void dss_uninit_platform_driver(void) 1555 - { 1556 - platform_driver_unregister(&omap_dsshw_driver); 1557 - }
+15 -20
drivers/gpu/drm/omapdrm/dss/dss.h
··· 262 262 } 263 263 #endif /* CONFIG_OMAP2_DSS_DEBUGFS */ 264 264 265 - int dss_init_platform_driver(void) __init; 266 - void dss_uninit_platform_driver(void); 267 - 268 265 int dss_runtime_get(void); 269 266 void dss_runtime_put(void); 270 267 ··· 323 326 struct dentry; 324 327 struct file_operations; 325 328 326 - int dsi_init_platform_driver(void) __init; 327 - void dsi_uninit_platform_driver(void); 328 - 329 329 void dsi_dump_clocks(struct seq_file *s); 330 330 331 331 void dsi_irq_handler(void); ··· 346 352 #endif 347 353 348 354 /* DISPC */ 349 - int dispc_init_platform_driver(void) __init; 350 - void dispc_uninit_platform_driver(void); 351 355 void dispc_dump_clocks(struct seq_file *s); 352 356 353 357 int dispc_runtime_get(void); ··· 389 397 int dispc_wb_setup(const struct omap_dss_writeback_info *wi, 390 398 bool mem_to_mem, const struct videomode *vm); 391 399 392 - /* VENC */ 393 - int venc_init_platform_driver(void) __init; 394 - void venc_uninit_platform_driver(void); 395 - 396 - /* HDMI */ 397 - int hdmi4_init_platform_driver(void) __init; 398 - void hdmi4_uninit_platform_driver(void); 399 - 400 - int hdmi5_init_platform_driver(void) __init; 401 - void hdmi5_uninit_platform_driver(void); 402 - 403 - 404 400 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS 405 401 static inline void dss_collect_irq_stats(u32 irqstatus, unsigned *irq_arr) 406 402 { ··· 431 451 int dss_pll_write_config_type_b(struct dss_pll *pll, 432 452 const struct dss_pll_clock_info *cinfo); 433 453 int dss_pll_wait_reset_done(struct dss_pll *pll); 454 + 455 + extern struct platform_driver omap_dsshw_driver; 456 + extern struct platform_driver omap_dispchw_driver; 457 + #ifdef CONFIG_OMAP2_DSS_DSI 458 + extern struct platform_driver omap_dsihw_driver; 459 + #endif 460 + #ifdef CONFIG_OMAP2_DSS_VENC 461 + extern struct platform_driver omap_venchw_driver; 462 + #endif 463 + #ifdef CONFIG_OMAP4_DSS_HDMI 464 + extern struct platform_driver omapdss_hdmi4hw_driver; 465 + #endif 466 + #ifdef CONFIG_OMAP5_DSS_HDMI 467 + extern struct platform_driver omapdss_hdmi5hw_driver; 468 + #endif 434 469 435 470 #endif
+1 -11
drivers/gpu/drm/omapdrm/dss/hdmi4.c
··· 845 845 {}, 846 846 }; 847 847 848 - static struct platform_driver omapdss_hdmihw_driver = { 848 + struct platform_driver omapdss_hdmi4hw_driver = { 849 849 .probe = hdmi4_probe, 850 850 .remove = hdmi4_remove, 851 851 .driver = { ··· 855 855 .suppress_bind_attrs = true, 856 856 }, 857 857 }; 858 - 859 - int __init hdmi4_init_platform_driver(void) 860 - { 861 - return platform_driver_register(&omapdss_hdmihw_driver); 862 - } 863 - 864 - void hdmi4_uninit_platform_driver(void) 865 - { 866 - platform_driver_unregister(&omapdss_hdmihw_driver); 867 - }
+1 -11
drivers/gpu/drm/omapdrm/dss/hdmi5.c
··· 841 841 {}, 842 842 }; 843 843 844 - static struct platform_driver omapdss_hdmihw_driver = { 844 + struct platform_driver omapdss_hdmi5hw_driver = { 845 845 .probe = hdmi5_probe, 846 846 .remove = hdmi5_remove, 847 847 .driver = { ··· 851 851 .suppress_bind_attrs = true, 852 852 }, 853 853 }; 854 - 855 - int __init hdmi5_init_platform_driver(void) 856 - { 857 - return platform_driver_register(&omapdss_hdmihw_driver); 858 - } 859 - 860 - void hdmi5_uninit_platform_driver(void) 861 - { 862 - platform_driver_unregister(&omapdss_hdmihw_driver); 863 - }
+1 -11
drivers/gpu/drm/omapdrm/dss/venc.c
··· 984 984 {}, 985 985 }; 986 986 987 - static struct platform_driver omap_venchw_driver = { 987 + struct platform_driver omap_venchw_driver = { 988 988 .probe = venc_probe, 989 989 .remove = venc_remove, 990 990 .driver = { ··· 994 994 .suppress_bind_attrs = true, 995 995 }, 996 996 }; 997 - 998 - int __init venc_init_platform_driver(void) 999 - { 1000 - return platform_driver_register(&omap_venchw_driver); 1001 - } 1002 - 1003 - void venc_uninit_platform_driver(void) 1004 - { 1005 - platform_driver_unregister(&omap_venchw_driver); 1006 - }