Message ID | 20220720155210.365977-9-jagan@amarulasolutions.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Hi Jagan, On 20.07.2022 17:52, Jagan Teki wrote: > Add module init and exit functions for the bridge to register > and unregister dsi_driver. > > Exynos drm driver stack will register the platform_driver separately > in the common of it's exynos_drm_drv.c including dsi_driver. > > Register again would return -EBUSY, so return 0 for such cases as > dsi_driver is already registered. I've already pointed that this is a bad style solution. It will also not work in the following cases: 1. exynos drm and samsung-dsim compiled as modules - samsung-dsim module, once loaded, will register the driver and exynos_drm won't be able to register the exynos_dsi. 2. multi-arch case - if one compiles a kernel (disto-style) with drivers for both supported architectures (exynos and imx) - in such case it will not work on imx, because exynos_drm driver will always register exynos_dsi driver first (even if the kernel is booted on non-exynos board). Best regards
Hi Marek, On Thu, Jul 21, 2022 at 4:39 PM Marek Szyprowski <m.szyprowski@samsung.com> wrote: > > Hi Jagan, > > On 20.07.2022 17:52, Jagan Teki wrote: > > Add module init and exit functions for the bridge to register > > and unregister dsi_driver. > > > > Exynos drm driver stack will register the platform_driver separately > > in the common of it's exynos_drm_drv.c including dsi_driver. > > > > Register again would return -EBUSY, so return 0 for such cases as > > dsi_driver is already registered. > > I've already pointed that this is a bad style solution. It will also not > work in the following cases: Yes, I have seen it in v2. (sending again since its part of the series and resolved other issues on v2) > > 1. exynos drm and samsung-dsim compiled as modules - samsung-dsim > module, once loaded, will register the driver and exynos_drm won't be > able to register the exynos_dsi. > > 2. multi-arch case - if one compiles a kernel (disto-style) with drivers > for both supported architectures (exynos and imx) - in such case it will > not work on imx, because exynos_drm driver will always register > exynos_dsi driver first (even if the kernel is booted on non-exynos board). Okay. I need to check the best way to handle this - so far this seems new. any suggestions, please let me know. Thanks, Jagan.
diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index 5eb594ea0bdf..5a0fea30e9e8 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -1737,6 +1737,28 @@ struct platform_driver dsi_driver = { }, }; +static int __init samsung_mipi_dsim_init(void) +{ + int ret; + + ret = platform_driver_register(&dsi_driver); + + /** + * Exynos drm driver stack will register the platform_driver + * separately in the common of it's exynos_drm_drv.c including + * dsi_driver. Register again would return -EBUSY, so return 0 + * for such cases as dsi_driver is already registered. + */ + return ret == -EBUSY ? 0 : ret; +} +module_init(samsung_mipi_dsim_init); + +static void __exit samsung_mipi_dsim_exit(void) +{ + platform_driver_unregister(&dsi_driver); +} +module_exit(samsung_mipi_dsim_exit); + MODULE_AUTHOR("Jagan Teki <jagan@amarulasolutions.com>"); MODULE_DESCRIPTION("Samsung MIPI DSIM controller bridge"); MODULE_LICENSE("GPL");
Add module init and exit functions for the bridge to register and unregister dsi_driver. Exynos drm driver stack will register the platform_driver separately in the common of it's exynos_drm_drv.c including dsi_driver. Register again would return -EBUSY, so return 0 for such cases as dsi_driver is already registered. v3, v2, v1: * none Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> --- drivers/gpu/drm/bridge/samsung-dsim.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)