linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Archit Taneja <a0393947@ti.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-omap@vger.kernel.org, linux-fbdev@vger.kernel.org
Subject: Re: [PATCH 16/21] OMAPDSS: handle output-driver reg/unreg more dynamically
Date: Thu, 08 Mar 2012 08:46:05 +0000	[thread overview]
Message-ID: <4F586EFD.1020208@ti.com> (raw)
In-Reply-To: <1331124290-6285-17-git-send-email-tomi.valkeinen@ti.com>

On Wednesday 07 March 2012 06:14 PM, Tomi Valkeinen wrote:
> Initialize and uninitialize the output drivers by using arrays of
> pointers to the init/uninit functions. This simplifies the code
> slightly.
>
> Signed-off-by: Tomi Valkeinen<tomi.valkeinen@ti.com>
> ---
>   drivers/video/omap2/dss/core.c |  111 +++++++++++++++++++++-------------------
>   drivers/video/omap2/dss/dss.h  |   41 ---------------
>   2 files changed, 59 insertions(+), 93 deletions(-)
>
> diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
> index 654962a..ac4f2cb 100644
> --- a/drivers/video/omap2/dss/core.c
> +++ b/drivers/video/omap2/dss/core.c
> @@ -503,10 +503,54 @@ static int omap_dss_bus_register(void)
>   }
>
>   /* INIT */
> +static int (*dss_output_drv_reg_funcs[])(void) __initdata = {
> +#ifdef CONFIG_OMAP2_DSS_DPI
> +	dpi_init_platform_driver,
> +#endif
> +#ifdef CONFIG_OMAP2_DSS_SDI
> +	sdi_init_platform_driver,
> +#endif
> +#ifdef CONFIG_OMAP2_DSS_RFBI
> +	rfbi_init_platform_driver,
> +#endif
> +#ifdef CONFIG_OMAP2_DSS_VENC
> +	venc_init_platform_driver,
> +#endif
> +#ifdef CONFIG_OMAP2_DSS_DSI
> +	dsi_init_platform_driver,
> +#endif
> +#ifdef CONFIG_OMAP4_DSS_HDMI
> +	hdmi_init_platform_driver,
> +#endif
> +};
> +
> +static void (*dss_output_drv_unreg_funcs[])(void) __exitdata = {
> +#ifdef CONFIG_OMAP2_DSS_DPI
> +	dpi_uninit_platform_driver,
> +#endif
> +#ifdef CONFIG_OMAP2_DSS_SDI
> +	sdi_uninit_platform_driver,
> +#endif
> +#ifdef CONFIG_OMAP2_DSS_RFBI
> +	rfbi_uninit_platform_driver,
> +#endif
> +#ifdef CONFIG_OMAP2_DSS_VENC
> +	venc_uninit_platform_driver,
> +#endif
> +#ifdef CONFIG_OMAP2_DSS_DSI
> +	dsi_uninit_platform_driver,
> +#endif
> +#ifdef CONFIG_OMAP4_DSS_HDMI
> +	hdmi_uninit_platform_driver,
> +#endif
> +};
> +
> +static bool dss_output_drv_loaded[ARRAY_SIZE(dss_output_drv_reg_funcs)];
>
>   static int __init omap_dss_register_drivers(void)
>   {
>   	int r;
> +	int i;
>
>   	r = platform_driver_probe(&omap_dss_driver, omap_dss_probe);
>   	if (r)
> @@ -524,56 +568,18 @@ static int __init omap_dss_register_drivers(void)
>   		goto err_dispc;
>   	}
>
> -	r = dpi_init_platform_driver();
> -	if (r) {
> -		DSSERR("Failed to initialize dpi platform driver\n");
> -		goto err_dpi;
> -	}
> -
> -	r = sdi_init_platform_driver();
> -	if (r) {
> -		DSSERR("Failed to initialize sdi platform driver\n");
> -		goto err_sdi;
> -	}
> -
> -	r = rfbi_init_platform_driver();
> -	if (r) {
> -		DSSERR("Failed to initialize rfbi platform driver\n");
> -		goto err_rfbi;
> -	}
> -
> -	r = venc_init_platform_driver();
> -	if (r) {
> -		DSSERR("Failed to initialize venc platform driver\n");
> -		goto err_venc;
> -	}
> -
> -	r = dsi_init_platform_driver();
> -	if (r) {
> -		DSSERR("Failed to initialize DSI platform driver\n");
> -		goto err_dsi;
> -	}
> -
> -	r = hdmi_init_platform_driver();
> -	if (r) {
> -		DSSERR("Failed to initialize hdmi\n");
> -		goto err_hdmi;
> +	/*
> +	 * It's ok if the output-driver register fails. It happens, for example,
> +	 * when there is no output-device (e.g. SDI for OMAP4).
> +	 */

Suppose we do a omap2plus_defconfig, CONFIG_OMAP2_DSS_SDI would be 
selected, and sdi.c would be built, if we boot on OMAP4, why would a sdi 
driver register cause a failure? Wouldn't the sdi driver just get 
registered, and wait till eternity for the corresponding sdi platform 
device to get registered?

Archit

> +	for (i = 0; i<  ARRAY_SIZE(dss_output_drv_reg_funcs); ++i) {
> +		r = dss_output_drv_reg_funcs[i]();
> +		if (r = 0)
> +			dss_output_drv_loaded[i] = true;
>   	}
>
>   	return 0;
>
> -err_hdmi:
> -	dsi_uninit_platform_driver();
> -err_dsi:
> -	venc_uninit_platform_driver();
> -err_venc:
> -	rfbi_uninit_platform_driver();
> -err_rfbi:
> -	sdi_uninit_platform_driver();
> -err_sdi:
> -	dpi_uninit_platform_driver();
> -err_dpi:
> -	dispc_uninit_platform_driver();
>   err_dispc:
>   	dss_uninit_platform_driver();
>   err_dss:
> @@ -584,12 +590,13 @@ err_dss:
>
>   static void __exit omap_dss_unregister_drivers(void)
>   {
> -	hdmi_uninit_platform_driver();
> -	dsi_uninit_platform_driver();
> -	venc_uninit_platform_driver();
> -	rfbi_uninit_platform_driver();
> -	sdi_uninit_platform_driver();
> -	dpi_uninit_platform_driver();
> +	int i;
> +
> +	for (i = 0; i<  ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i) {
> +		if (dss_output_drv_loaded[i])
> +			dss_output_drv_unreg_funcs[i]();
> +	}
> +
>   	dispc_uninit_platform_driver();
>   	dss_uninit_platform_driver();
>
> diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
> index 24aadde..af7bed1 100644
> --- a/drivers/video/omap2/dss/dss.h
> +++ b/drivers/video/omap2/dss/dss.h
> @@ -265,14 +265,9 @@ int dss_calc_clock_div(bool is_tft, unsigned long req_pck,
>   		struct dispc_clock_info *dispc_cinfo);
>
>   /* SDI */
> -#ifdef CONFIG_OMAP2_DSS_SDI
>   int sdi_init_platform_driver(void);
>   void sdi_uninit_platform_driver(void);
>   int sdi_init_display(struct omap_dss_device *display);
> -#else
> -static inline int sdi_init_platform_driver(void) { return 0; }
> -static inline void sdi_uninit_platform_driver(void) { }
> -#endif
>
>   /* DSI */
>   #ifdef CONFIG_OMAP2_DSS_DSI
> @@ -309,13 +304,6 @@ void dsi_wait_pll_hsdiv_dispc_active(struct platform_device *dsidev);
>   void dsi_wait_pll_hsdiv_dsi_active(struct platform_device *dsidev);
>   struct platform_device *dsi_get_dsidev_from_id(int module);
>   #else
> -static inline int dsi_init_platform_driver(void)
> -{
> -	return 0;
> -}
> -static inline void dsi_uninit_platform_driver(void)
> -{
> -}
>   static inline int dsi_runtime_get(struct platform_device *dsidev)
>   {
>   	return 0;
> @@ -372,14 +360,9 @@ static inline struct platform_device *dsi_get_dsidev_from_id(int module)
>   #endif
>
>   /* DPI */
> -#ifdef CONFIG_OMAP2_DSS_DPI
>   int dpi_init_platform_driver(void);
>   void dpi_uninit_platform_driver(void);
>   int dpi_init_display(struct omap_dss_device *dssdev);
> -#else
> -static inline int dpi_init_platform_driver(void) { return 0; }
> -static inline void dpi_uninit_platform_driver(void) { }
> -#endif
>
>   /* DISPC */
>   int dispc_init_platform_driver(void);
> @@ -456,13 +439,6 @@ void venc_dump_regs(struct seq_file *s);
>   int venc_init_display(struct omap_dss_device *display);
>   unsigned long venc_get_pixel_clock(void);
>   #else
> -static inline int venc_init_platform_driver(void)
> -{
> -	return 0;
> -}
> -static inline void venc_uninit_platform_driver(void)
> -{
> -}
>   static inline unsigned long venc_get_pixel_clock(void)
>   {
>   	WARN("%s: VENC not compiled in, returning pclk as 0\n", __func__);
> @@ -482,13 +458,6 @@ static inline int hdmi_init_display(struct omap_dss_device *dssdev)
>   {
>   	return 0;
>   }
> -static inline int hdmi_init_platform_driver(void)
> -{
> -	return 0;
> -}
> -static inline void hdmi_uninit_platform_driver(void)
> -{
> -}
>   static inline unsigned long hdmi_get_pixel_clock(void)
>   {
>   	WARN("%s: HDMI not compiled in, returning pclk as 0\n", __func__);
> @@ -506,20 +475,10 @@ int hdmi_panel_init(void);
>   void hdmi_panel_exit(void);
>
>   /* RFBI */
> -#ifdef CONFIG_OMAP2_DSS_RFBI
>   int rfbi_init_platform_driver(void);
>   void rfbi_uninit_platform_driver(void);
>   void rfbi_dump_regs(struct seq_file *s);
>   int rfbi_init_display(struct omap_dss_device *display);
> -#else
> -static inline int rfbi_init_platform_driver(void)
> -{
> -	return 0;
> -}
> -static inline void rfbi_uninit_platform_driver(void)
> -{
> -}
> -#endif
>
>
>   #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS


  reply	other threads:[~2012-03-08  8:46 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-07 12:44 [PATCH 00/21] OMAPDSS: DT preparation patches Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 01/21] OMAPDSS: panel-dvi: add PD gpio handling Tomi Valkeinen
2012-03-07 17:59   ` Archit Taneja
2012-03-08  7:54     ` Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 02/21] OMAP: board-files: remove custom PD GPIO handling for DVI output Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 03/21] OMAPDSS: TFP410: rename dvi -> tfp410 Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 04/21] OMAPDSS: TFP410: rename dvi files to tfp410 Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 05/21] OMAPDSS: TFP410: pdata rewrite Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 06/21] OMAPDSS: DSI: use dsi_get_dsidev_id(dsidev) instead of dsidev->id Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 07/21] OMAPDSS: Taal: move reset gpio handling to taal driver Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 08/21] OMAPDSS: clean up the omapdss platform data mess Tomi Valkeinen
2012-03-07 18:23   ` Archit Taneja
2012-03-08  8:02     ` Tomi Valkeinen
2012-03-08  8:29       ` Archit Taneja
2012-03-08  8:33         ` Tomi Valkeinen
2012-03-08  8:55           ` Archit Taneja
2012-03-07 12:44 ` [PATCH 09/21] OMAPDSS: remove return from platform_driver_unreg Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 10/21] OMAPDSS: use platform_driver_probe for core/dispc/dss Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 11/21] OMAPDSS: register dss drivers in module init Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 12/21] OMAPDSS: create custom pdevs for DSS omap_devices Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 13/21] OMAPDSS: create DPI & SDI devices Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 14/21] OMAPDSS: create DPI & SDI drivers Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 15/21] OMAPDSS: remove uses of dss_runtime_get/put Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 16/21] OMAPDSS: handle output-driver reg/unreg more dynamically Tomi Valkeinen
2012-03-08  8:46   ` Archit Taneja [this message]
2012-03-08  8:46     ` Tomi Valkeinen
2012-03-08  9:34       ` Archit Taneja
2012-03-08  9:34         ` Tomi Valkeinen
2012-03-08  9:51           ` Archit Taneja
2012-03-07 12:44 ` [PATCH 17/21] OMAPDSS: move the creation of debugfs files Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 18/21] OMAPDSS: use platform_driver_probe for dsi/hdmi/rfbi/venc/dpi/sdi Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 19/21] OMAPDSS: add __init & __exit Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 20/21] OMAPFB: " Tomi Valkeinen
2012-03-07 12:44 ` [PATCH 21/21] OMAPDSS: change default_device handling Tomi Valkeinen

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=4F586EFD.1020208@ti.com \
    --to=a0393947@ti.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=tomi.valkeinen@ti.com \
    /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;
as well as URLs for NNTP newsgroup(s).