From: Inki Dae <inki.dae@samsung.com>
To: Andrzej Hajda <a.hajda@samsung.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/exynos: remove ifdeferry from initialization code
Date: Thu, 30 Oct 2014 23:29:35 +0900 [thread overview]
Message-ID: <54524B4F.9000303@samsung.com> (raw)
In-Reply-To: <1414674801-11198-1-git-send-email-a.hajda@samsung.com>
On 2014년 10월 30일 22:13, Andrzej Hajda wrote:
> 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.
Applied.
Thanks,
Inki Dae
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
> Hi Inki,
>
> Rebased on the latest exynos-drm-next.
>
> Regards
> Andrzej
> ---
> drivers/gpu/drm/exynos/exynos_drm_drv.c | 170 +++++++-------------------------
> drivers/gpu/drm/exynos/exynos_drm_drv.h | 25 +++--
> 2 files changed, 48 insertions(+), 147 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> index c57466e..fe250e4 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> @@ -550,74 +550,54 @@ static const struct component_master_ops exynos_drm_ops = {
> .unbind = exynos_drm_unbind,
> };
>
> -static int exynos_drm_platform_probe(struct platform_device *pdev)
> -{
> - struct component_match *match;
> - int ret;
> -
> - pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
> - exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
> -
> +static struct platform_driver * const exynos_drm_drivers[] = {
> #ifdef CONFIG_DRM_EXYNOS_FIMD
> - ret = platform_driver_register(&fimd_driver);
> - if (ret < 0)
> - return ret;
> + &fimd_driver,
> #endif
> -
> #ifdef CONFIG_DRM_EXYNOS_DP
> - ret = platform_driver_register(&dp_driver);
> - if (ret < 0)
> - goto err_unregister_fimd_drv;
> + &dp_driver,
> #endif
> -
> #ifdef CONFIG_DRM_EXYNOS_DSI
> - ret = platform_driver_register(&dsi_driver);
> - if (ret < 0)
> - goto err_unregister_dp_drv;
> + &dsi_driver,
> #endif
> -
> #ifdef CONFIG_DRM_EXYNOS_HDMI
> - ret = platform_driver_register(&mixer_driver);
> - if (ret < 0)
> - goto err_unregister_dsi_drv;
> - ret = platform_driver_register(&hdmi_driver);
> - if (ret < 0)
> - goto err_unregister_mixer_drv;
> + &mixer_driver,
> + &hdmi_driver,
> #endif
> -
> #ifdef CONFIG_DRM_EXYNOS_G2D
> - ret = platform_driver_register(&g2d_driver);
> - if (ret < 0)
> - goto err_unregister_hdmi_drv;
> + &g2d_driver,
> #endif
> -
> #ifdef CONFIG_DRM_EXYNOS_FIMC
> - ret = platform_driver_register(&fimc_driver);
> - if (ret < 0)
> - goto err_unregister_g2d_drv;
> + &fimc_driver,
> #endif
> -
> #ifdef CONFIG_DRM_EXYNOS_ROTATOR
> - ret = platform_driver_register(&rotator_driver);
> - if (ret < 0)
> - goto err_unregister_fimc_drv;
> + &rotator_driver,
> #endif
> -
> #ifdef CONFIG_DRM_EXYNOS_GSC
> - ret = platform_driver_register(&gsc_driver);
> - if (ret < 0)
> - goto err_unregister_rotator_drv;
> + &gsc_driver,
> #endif
> -
> #ifdef CONFIG_DRM_EXYNOS_IPP
> - ret = platform_driver_register(&ipp_driver);
> - if (ret < 0)
> - goto err_unregister_gsc_drv;
> + &ipp_driver,
> +#endif
> +};
> +
> +static int exynos_drm_platform_probe(struct platform_device *pdev)
> +{
> + struct component_match *match;
> + int ret, i;
> +
> + 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_drivers); ++i) {
> + ret = platform_driver_register(exynos_drm_drivers[i]);
> + if (ret < 0)
> + goto err_unregister_drivers;
> + }
>
> ret = exynos_platform_device_ipp_register();
> if (ret < 0)
> - goto err_unregister_ipp_drv;
> -#endif
> + goto err_unregister_drivers;
>
> match = exynos_drm_match_add(&pdev->dev);
> if (IS_ERR(match)) {
> @@ -633,96 +613,24 @@ static int exynos_drm_platform_probe(struct platform_device *pdev)
> return ret;
>
> err_unregister_resources:
> -
> -#ifdef CONFIG_DRM_EXYNOS_IPP
> 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
> +err_unregister_drivers:
> + while (--i >= 0)
> + platform_driver_unregister(exynos_drm_drivers[i]);
>
> -#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
> -
> -#ifdef CONFIG_DRM_EXYNOS_G2D
> - platform_driver_unregister(&g2d_driver);
> -err_unregister_hdmi_drv:
> -#endif
> -
> -#ifdef CONFIG_DRM_EXYNOS_HDMI
> - platform_driver_unregister(&hdmi_driver);
> -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;
> }
>
> static int exynos_drm_platform_remove(struct platform_device *pdev)
> {
> -#ifdef CONFIG_DRM_EXYNOS_IPP
> - exynos_platform_device_ipp_unregister();
> - platform_driver_unregister(&ipp_driver);
> -#endif
> -
> -#ifdef CONFIG_DRM_EXYNOS_GSC
> - platform_driver_unregister(&gsc_driver);
> -#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
> + int i;
>
> -#ifdef CONFIG_DRM_EXYNOS_FIMD
> - platform_driver_unregister(&fimd_driver);
> -#endif
> + exynos_platform_device_ipp_unregister();
>
> -#ifdef CONFIG_DRM_EXYNOS_DSI
> - platform_driver_unregister(&dsi_driver);
> -#endif
> + for (i = ARRAY_SIZE(exynos_drm_drivers) - 1; i >= 0; --i)
> + platform_driver_unregister(exynos_drm_drivers[i]);
>
> -#ifdef CONFIG_DRM_EXYNOS_DP
> - platform_driver_unregister(&dp_driver);
> -#endif
> component_master_del(&pdev->dev, &exynos_drm_ops);
> return 0;
> }
> @@ -746,11 +654,9 @@ static int exynos_drm_init(void)
> if (IS_ERR(exynos_drm_pdev))
> return PTR_ERR(exynos_drm_pdev);
>
> -#ifdef CONFIG_DRM_EXYNOS_VIDI
> ret = exynos_drm_probe_vidi();
> if (ret < 0)
> goto err_unregister_pd;
> -#endif
>
> ret = platform_driver_register(&exynos_drm_platform_driver);
> if (ret)
> @@ -759,11 +665,9 @@ static int exynos_drm_init(void)
> return 0;
>
> err_remove_vidi:
> -#ifdef CONFIG_DRM_EXYNOS_VIDI
> exynos_drm_remove_vidi();
>
> err_unregister_pd:
> -#endif
> platform_device_unregister(exynos_drm_pdev);
>
> return ret;
> @@ -772,9 +676,9 @@ err_unregister_pd:
> static void exynos_drm_exit(void)
> {
> platform_driver_unregister(&exynos_drm_platform_driver);
> -#ifdef CONFIG_DRM_EXYNOS_VIDI
> +
> exynos_drm_remove_vidi();
> -#endif
> +
> platform_device_unregister(exynos_drm_pdev);
> }
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> index d22e640..3c81c4b 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> @@ -323,15 +323,14 @@ int exynos_platform_device_hdmi_register(void);
> */
> void exynos_platform_device_hdmi_unregister(void);
>
> -/*
> - * this function registers exynos drm ipp platform device.
> - */
> +#ifdef CONFIG_DRM_EXYNOS_IPP
> 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);
> +#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
> struct exynos_drm_display * exynos_dpi_probe(struct device *dev);
> @@ -342,15 +341,13 @@ exynos_dpi_probe(struct device *dev) { return NULL; }
> static inline int exynos_dpi_remove(struct device *dev) { return 0; }
> #endif
>
> -/*
> - * this function registers exynos drm vidi platform device/driver.
> - */
> +#ifdef CONFIG_DRM_EXYNOS_VIDI
> int exynos_drm_probe_vidi(void);
> -
> -/*
> - * this function unregister exynos drm vidi platform device/driver.
> - */
> 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. */
> int exynos_drm_create_enc_conn(struct drm_device *dev,
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
prev parent reply other threads:[~2014-10-30 14:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-10 11:53 [PATCH] drm/exynos: remove ifdeferry from initialization code Andrzej Hajda
2014-09-30 11:29 ` Andrzej Hajda
2014-10-01 5:48 ` Inki Dae
2014-10-01 6:07 ` Inki Dae
2014-10-01 8:14 ` [PATCH] drm/exynos: fix vblank handling during dpms off Andrzej Hajda
2014-10-02 8:58 ` Joonyoung Shim
2014-10-02 10:52 ` Inki Dae
2014-10-02 11:52 ` Andrzej Hajda
2014-10-09 5:43 ` Alexandre Courbot
2014-10-09 8:52 ` Russell King - ARM Linux
2014-10-09 9:58 ` Thierry Reding
[not found] ` <54362066.9000504-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-10-09 10:08 ` Thierry Reding
2014-10-09 10:23 ` Alexandre Courbot
2014-10-10 12:39 ` Andrzej Hajda
2014-10-15 5:32 ` Inki Dae
2014-10-01 6:26 ` [PATCH] drm/exynos: remove ifdeferry from initialization code Ajay kumar
2014-10-30 12:36 ` Andrzej Hajda
2014-10-30 13:02 ` Inki Dae
2014-10-30 13:13 ` Andrzej Hajda
2014-10-30 14:29 ` Inki Dae [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54524B4F.9000303@samsung.com \
--to=inki.dae@samsung.com \
--cc=a.hajda@samsung.com \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox