Commit 72390677 authored by Andrzej Hajda's avatar Andrzej Hajda Committed by Inki Dae

drm/exynos: remove ifdeferry from initialization code

The patch replaces separate calls to driver (de)registration by
loops over the array of drivers. As a result it significantly
decreases number of ifdefs. Additionally it moves device registration
related ifdefs to header file.

Changelog v2:
- Rebased.
- Consider non kms driver in respect to infinite loop issue.
Signed-off-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
parent 421ee18d
...@@ -547,85 +547,74 @@ static const struct component_master_ops exynos_drm_ops = { ...@@ -547,85 +547,74 @@ static const struct component_master_ops exynos_drm_ops = {
.unbind = exynos_drm_unbind, .unbind = exynos_drm_unbind,
}; };
static int exynos_drm_platform_probe(struct platform_device *pdev) static struct platform_driver *const exynos_drm_kms_drivers[] = {
{
struct component_match *match;
int ret;
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
#ifdef CONFIG_DRM_EXYNOS_FIMD #ifdef CONFIG_DRM_EXYNOS_FIMD
ret = platform_driver_register(&fimd_driver); &fimd_driver,
if (ret < 0)
return ret;
#endif #endif
#ifdef CONFIG_DRM_EXYNOS_DP #ifdef CONFIG_DRM_EXYNOS_DP
ret = platform_driver_register(&dp_driver); &dp_driver,
if (ret < 0)
goto err_unregister_fimd_drv;
#endif #endif
#ifdef CONFIG_DRM_EXYNOS_DSI #ifdef CONFIG_DRM_EXYNOS_DSI
ret = platform_driver_register(&dsi_driver); &dsi_driver,
if (ret < 0)
goto err_unregister_dp_drv;
#endif #endif
#ifdef CONFIG_DRM_EXYNOS_HDMI #ifdef CONFIG_DRM_EXYNOS_HDMI
ret = platform_driver_register(&mixer_driver); &mixer_driver,
if (ret < 0) &hdmi_driver,
goto err_unregister_dsi_drv; #endif
ret = platform_driver_register(&hdmi_driver); };
if (ret < 0)
goto err_unregister_mixer_drv; static struct platform_driver *const exynos_drm_non_kms_drivers[] = {
#ifdef CONFIG_DRM_EXYNOS_G2D
&g2d_driver,
#endif
#ifdef CONFIG_DRM_EXYNOS_FIMC
&fimc_driver,
#endif
#ifdef CONFIG_DRM_EXYNOS_ROTATOR
&rotator_driver,
#endif
#ifdef CONFIG_DRM_EXYNOS_GSC
&gsc_driver,
#endif #endif
#ifdef CONFIG_DRM_EXYNOS_IPP
&ipp_driver,
#endif
};
static int exynos_drm_platform_probe(struct platform_device *pdev)
{
struct component_match *match;
int ret, i, j;
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
for (i = 0; i < ARRAY_SIZE(exynos_drm_kms_drivers); ++i) {
ret = platform_driver_register(exynos_drm_kms_drivers[i]);
if (ret < 0)
goto err_unregister_kms_drivers;
}
match = exynos_drm_match_add(&pdev->dev); match = exynos_drm_match_add(&pdev->dev);
if (IS_ERR(match)) { if (IS_ERR(match)) {
ret = PTR_ERR(match); ret = PTR_ERR(match);
goto err_unregister_hdmi_drv; goto err_unregister_kms_drivers;
} }
ret = component_master_add_with_match(&pdev->dev, &exynos_drm_ops, ret = component_master_add_with_match(&pdev->dev, &exynos_drm_ops,
match); match);
if (ret < 0) if (ret < 0)
goto err_unregister_hdmi_drv; goto err_unregister_kms_drivers;
#ifdef CONFIG_DRM_EXYNOS_G2D for (j = 0; j < ARRAY_SIZE(exynos_drm_non_kms_drivers); ++j) {
ret = platform_driver_register(&g2d_driver); ret = platform_driver_register(exynos_drm_non_kms_drivers[j]);
if (ret < 0) if (ret < 0)
goto err_del_component_master; goto err_del_component_master;
#endif }
#ifdef CONFIG_DRM_EXYNOS_FIMC
ret = platform_driver_register(&fimc_driver);
if (ret < 0)
goto err_unregister_g2d_drv;
#endif
#ifdef CONFIG_DRM_EXYNOS_ROTATOR
ret = platform_driver_register(&rotator_driver);
if (ret < 0)
goto err_unregister_fimc_drv;
#endif
#ifdef CONFIG_DRM_EXYNOS_GSC
ret = platform_driver_register(&gsc_driver);
if (ret < 0)
goto err_unregister_rotator_drv;
#endif
#ifdef CONFIG_DRM_EXYNOS_IPP
ret = platform_driver_register(&ipp_driver);
if (ret < 0)
goto err_unregister_gsc_drv;
ret = exynos_platform_device_ipp_register(); ret = exynos_platform_device_ipp_register();
if (ret < 0) if (ret < 0)
goto err_unregister_ipp_drv; goto err_unregister_non_kms_drivers;
#endif
/* Probe non kms sub drivers and virtual display driver. */ /* Probe non kms sub drivers and virtual display driver. */
ret = exynos_drm_device_subdrv_probe(platform_get_drvdata(pdev)); ret = exynos_drm_device_subdrv_probe(platform_get_drvdata(pdev));
...@@ -637,98 +626,39 @@ static int exynos_drm_platform_probe(struct platform_device *pdev) ...@@ -637,98 +626,39 @@ static int exynos_drm_platform_probe(struct platform_device *pdev)
err_unregister_resources: err_unregister_resources:
#ifdef CONFIG_DRM_EXYNOS_IPP #ifdef CONFIG_DRM_EXYNOS_IPP
exynos_platform_device_ipp_unregister(); exynos_platform_device_ipp_unregister();
err_unregister_ipp_drv:
platform_driver_unregister(&ipp_driver);
err_unregister_gsc_drv:
#endif
#ifdef CONFIG_DRM_EXYNOS_GSC
platform_driver_unregister(&gsc_driver);
err_unregister_rotator_drv:
#endif
#ifdef CONFIG_DRM_EXYNOS_ROTATOR
platform_driver_unregister(&rotator_driver);
err_unregister_fimc_drv:
#endif
#ifdef CONFIG_DRM_EXYNOS_FIMC
platform_driver_unregister(&fimc_driver);
err_unregister_g2d_drv:
#endif #endif
err_unregister_non_kms_drivers:
while (--j >= 0)
platform_driver_unregister(exynos_drm_non_kms_drivers[j]);
#ifdef CONFIG_DRM_EXYNOS_G2D
platform_driver_unregister(&g2d_driver);
err_del_component_master: err_del_component_master:
#endif
component_master_del(&pdev->dev, &exynos_drm_ops); component_master_del(&pdev->dev, &exynos_drm_ops);
err_unregister_hdmi_drv: err_unregister_kms_drivers:
#ifdef CONFIG_DRM_EXYNOS_HDMI while (--i >= 0)
platform_driver_unregister(&hdmi_driver); platform_driver_unregister(exynos_drm_kms_drivers[i]);
err_unregister_mixer_drv:
platform_driver_unregister(&mixer_driver);
err_unregister_dsi_drv:
#endif
#ifdef CONFIG_DRM_EXYNOS_DSI
platform_driver_unregister(&dsi_driver);
err_unregister_dp_drv:
#endif
#ifdef CONFIG_DRM_EXYNOS_DP
platform_driver_unregister(&dp_driver);
err_unregister_fimd_drv:
#endif
#ifdef CONFIG_DRM_EXYNOS_FIMD
platform_driver_unregister(&fimd_driver);
#endif
return ret; return ret;
} }
static int exynos_drm_platform_remove(struct platform_device *pdev) static int exynos_drm_platform_remove(struct platform_device *pdev)
{ {
int i;
exynos_drm_device_subdrv_remove(platform_get_drvdata(pdev)); exynos_drm_device_subdrv_remove(platform_get_drvdata(pdev));
#ifdef CONFIG_DRM_EXYNOS_IPP #ifdef CONFIG_DRM_EXYNOS_IPP
exynos_platform_device_ipp_unregister(); exynos_platform_device_ipp_unregister();
platform_driver_unregister(&ipp_driver);
#endif #endif
#ifdef CONFIG_DRM_EXYNOS_GSC for (i = ARRAY_SIZE(exynos_drm_non_kms_drivers) - 1; i >= 0; --i)
platform_driver_unregister(&gsc_driver); platform_driver_unregister(exynos_drm_non_kms_drivers[i]);
#endif
#ifdef CONFIG_DRM_EXYNOS_ROTATOR
platform_driver_unregister(&rotator_driver);
#endif
#ifdef CONFIG_DRM_EXYNOS_FIMC
platform_driver_unregister(&fimc_driver);
#endif
#ifdef CONFIG_DRM_EXYNOS_G2D
platform_driver_unregister(&g2d_driver);
#endif
#ifdef CONFIG_DRM_EXYNOS_HDMI
platform_driver_unregister(&mixer_driver);
platform_driver_unregister(&hdmi_driver);
#endif
#ifdef CONFIG_DRM_EXYNOS_FIMD component_master_del(&pdev->dev, &exynos_drm_ops);
platform_driver_unregister(&fimd_driver);
#endif
#ifdef CONFIG_DRM_EXYNOS_DSI for (i = ARRAY_SIZE(exynos_drm_kms_drivers) - 1; i >= 0; --i)
platform_driver_unregister(&dsi_driver); platform_driver_unregister(exynos_drm_kms_drivers[i]);
#endif
#ifdef CONFIG_DRM_EXYNOS_DP
platform_driver_unregister(&dp_driver);
#endif
component_master_del(&pdev->dev, &exynos_drm_ops);
return 0; return 0;
} }
...@@ -763,11 +693,9 @@ static int exynos_drm_init(void) ...@@ -763,11 +693,9 @@ static int exynos_drm_init(void)
if (IS_ERR(exynos_drm_pdev)) if (IS_ERR(exynos_drm_pdev))
return PTR_ERR(exynos_drm_pdev); return PTR_ERR(exynos_drm_pdev);
#ifdef CONFIG_DRM_EXYNOS_VIDI
ret = exynos_drm_probe_vidi(); ret = exynos_drm_probe_vidi();
if (ret < 0) if (ret < 0)
goto err_unregister_pd; goto err_unregister_pd;
#endif
ret = platform_driver_register(&exynos_drm_platform_driver); ret = platform_driver_register(&exynos_drm_platform_driver);
if (ret) if (ret)
...@@ -776,11 +704,9 @@ static int exynos_drm_init(void) ...@@ -776,11 +704,9 @@ static int exynos_drm_init(void)
return 0; return 0;
err_remove_vidi: err_remove_vidi:
#ifdef CONFIG_DRM_EXYNOS_VIDI
exynos_drm_remove_vidi(); exynos_drm_remove_vidi();
err_unregister_pd: err_unregister_pd:
#endif
platform_device_unregister(exynos_drm_pdev); platform_device_unregister(exynos_drm_pdev);
return ret; return ret;
...@@ -789,9 +715,9 @@ static int exynos_drm_init(void) ...@@ -789,9 +715,9 @@ static int exynos_drm_init(void)
static void exynos_drm_exit(void) static void exynos_drm_exit(void)
{ {
platform_driver_unregister(&exynos_drm_platform_driver); platform_driver_unregister(&exynos_drm_platform_driver);
#ifdef CONFIG_DRM_EXYNOS_VIDI
exynos_drm_remove_vidi(); exynos_drm_remove_vidi();
#endif
platform_device_unregister(exynos_drm_pdev); platform_device_unregister(exynos_drm_pdev);
} }
......
...@@ -323,15 +323,14 @@ int exynos_platform_device_hdmi_register(void); ...@@ -323,15 +323,14 @@ int exynos_platform_device_hdmi_register(void);
*/ */
void exynos_platform_device_hdmi_unregister(void); void exynos_platform_device_hdmi_unregister(void);
/* #ifdef CONFIG_DRM_EXYNOS_IPP
* this function registers exynos drm ipp platform device.
*/
int exynos_platform_device_ipp_register(void); int exynos_platform_device_ipp_register(void);
/*
* this function unregisters exynos drm ipp platform device if it exists.
*/
void exynos_platform_device_ipp_unregister(void); void exynos_platform_device_ipp_unregister(void);
#else
static inline int exynos_platform_device_ipp_register(void) { return 0; }
static inline void exynos_platform_device_ipp_unregister(void) {}
#endif
#ifdef CONFIG_DRM_EXYNOS_DPI #ifdef CONFIG_DRM_EXYNOS_DPI
struct exynos_drm_display * exynos_dpi_probe(struct device *dev); struct exynos_drm_display * exynos_dpi_probe(struct device *dev);
...@@ -342,15 +341,13 @@ exynos_dpi_probe(struct device *dev) { return NULL; } ...@@ -342,15 +341,13 @@ exynos_dpi_probe(struct device *dev) { return NULL; }
static inline int exynos_dpi_remove(struct device *dev) { return 0; } static inline int exynos_dpi_remove(struct device *dev) { return 0; }
#endif #endif
/* #ifdef CONFIG_DRM_EXYNOS_VIDI
* this function registers exynos drm vidi platform device/driver.
*/
int exynos_drm_probe_vidi(void); int exynos_drm_probe_vidi(void);
/*
* this function unregister exynos drm vidi platform device/driver.
*/
void exynos_drm_remove_vidi(void); void exynos_drm_remove_vidi(void);
#else
static inline int exynos_drm_probe_vidi(void) { return 0; }
static inline void exynos_drm_remove_vidi(void) {}
#endif
/* This function creates a encoder and a connector, and initializes them. */ /* This function creates a encoder and a connector, and initializes them. */
int exynos_drm_create_enc_conn(struct drm_device *dev, int exynos_drm_create_enc_conn(struct drm_device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment