[PATCH v2 22/60] drm/omap: dss: Move src and dst check and set to connection handlers

Sebastian Reichel sre at kernel.org
Sun Jun 10 19:54:19 UTC 2018


Hi,

On Sat, May 26, 2018 at 08:24:40PM +0300, Laurent Pinchart wrote:
> The encoders duplicate the same omap_dss_device src and dst fields set
> and checks in their connect and disconnect handlers. Move the code to
> the connect and disconnect wrappers.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel at collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/displays/encoder-opa362.c  | 10 ---------
>  drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c  | 10 ---------
>  .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c   | 11 ----------
>  drivers/gpu/drm/omapdrm/dss/base.c                 | 24 ++++++++++++++++++++--
>  drivers/gpu/drm/omapdrm/dss/dpi.c                  |  5 -----
>  drivers/gpu/drm/omapdrm/dss/dsi.c                  |  5 -----
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c                |  5 -----
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c                |  5 -----
>  drivers/gpu/drm/omapdrm/dss/omapdss.h              |  8 +++-----
>  drivers/gpu/drm/omapdrm/dss/output.c               |  6 ------
>  drivers/gpu/drm/omapdrm/dss/sdi.c                  |  5 -----
>  drivers/gpu/drm/omapdrm/dss/venc.c                 |  5 -----
>  12 files changed, 25 insertions(+), 74 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
> index 5b9ef09e6b2d..6baca0dc2b62 100644
> --- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
> +++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
> @@ -51,9 +51,6 @@ static int opa362_connect(struct omap_dss_device *dssdev,
>  		return r;
>  	}
>  
> -	dst->src = dssdev;
> -	dssdev->dst = dst;
> -
>  	ddata->in = in;
>  	return 0;
>  }
> @@ -64,13 +61,6 @@ static void opa362_disconnect(struct omap_dss_device *dssdev,
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
>  	struct omap_dss_device *in = ddata->in;
>  
> -	WARN_ON(dst != dssdev->dst);
> -	if (dst != dssdev->dst)
> -		return;
> -
> -	dst->src = NULL;
> -	dssdev->dst = NULL;
> -
>  	omapdss_device_disconnect(in, &ddata->dssdev);
>  
>  	omap_dss_put_device(in);
> diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
> index b22c8f71c0e5..c1ae8bebf04d 100644
> --- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
> +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
> @@ -47,9 +47,6 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
>  		return r;
>  	}
>  
> -	dst->src = dssdev;
> -	dssdev->dst = dst;
> -
>  	ddata->in = in;
>  	return 0;
>  }
> @@ -60,13 +57,6 @@ static void tfp410_disconnect(struct omap_dss_device *dssdev,
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
>  	struct omap_dss_device *in = ddata->in;
>  
> -	WARN_ON(dst != dssdev->dst);
> -	if (dst != dssdev->dst)
> -		return;
> -
> -	dst->src = NULL;
> -	dssdev->dst = NULL;
> -
>  	omapdss_device_disconnect(in, &ddata->dssdev);
>  
>  	omap_dss_put_device(in);
> diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
> index 640f15b88467..8aa338d01bf7 100644
> --- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
> +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
> @@ -55,9 +55,6 @@ static int tpd_connect(struct omap_dss_device *dssdev,
>  		return r;
>  	}
>  
> -	dst->src = dssdev;
> -	dssdev->dst = dst;
> -
>  	gpiod_set_value_cansleep(ddata->ct_cp_hpd_gpio, 1);
>  	gpiod_set_value_cansleep(ddata->ls_oe_gpio, 1);
>  
> @@ -74,17 +71,9 @@ static void tpd_disconnect(struct omap_dss_device *dssdev,
>  	struct panel_drv_data *ddata = to_panel_data(dssdev);
>  	struct omap_dss_device *in = ddata->in;
>  
> -	WARN_ON(dst != dssdev->dst);
> -
> -	if (dst != dssdev->dst)
> -		return;
> -
>  	gpiod_set_value_cansleep(ddata->ct_cp_hpd_gpio, 0);
>  	gpiod_set_value_cansleep(ddata->ls_oe_gpio, 0);
>  
> -	dst->src = NULL;
> -	dssdev->dst = NULL;
> -
>  	omapdss_device_disconnect(in, &ddata->dssdev);
>  
>  	omap_dss_put_device(in);
> diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
> index 01c117d8775b..810dcddded8a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/base.c
> +++ b/drivers/gpu/drm/omapdrm/dss/base.c
> @@ -105,15 +105,27 @@ struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
>  int omapdss_device_connect(struct omap_dss_device *src,
>  			   struct omap_dss_device *dst)
>  {
> +	int ret;
> +
>  	dev_dbg(src->dev, "connect\n");
>  
>  	if (omapdss_device_is_connected(src))
>  		return -EBUSY;
>  
>  	if (src->driver)
> -		return src->driver->connect(src);
> +		ret = src->driver->connect(src);
>  	else
> -		return src->ops->connect(src, dst);
> +		ret = src->ops->connect(src, dst);
> +
> +	if (ret < 0)
> +		return ret;
> +
> +	if (dst) {
> +		dst->src = src;
> +		src->dst = dst;
> +	}
> +
> +	return 0;
>  }
>  EXPORT_SYMBOL_GPL(omapdss_device_connect);
>  
> @@ -127,6 +139,14 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
>  		return;
>  	}
>  
> +	if (dst) {
> +		if (WARN_ON(dst != src->dst))
> +			return;
> +
> +		dst->src = NULL;
> +		src->dst = NULL;
> +	}
> +
>  	if (src->driver)
>  		src->driver->disconnect(src);
>  	else
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index 4516086e85fa..c13feaf8b086 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -671,11 +671,6 @@ static void dpi_disconnect(struct omap_dss_device *dssdev,
>  {
>  	struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
>  
> -	WARN_ON(dst != dssdev->dst);
> -
> -	if (dst != dssdev->dst)
> -		return;
> -
>  	omapdss_output_unset_device(dssdev);
>  
>  	dss_mgr_disconnect(&dpi->output, dssdev);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index e4f496382617..4427389e0049 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -4990,11 +4990,6 @@ static void dsi_disconnect(struct omap_dss_device *dssdev,
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
> -	WARN_ON(dst != dssdev->dst);
> -
> -	if (dst != dssdev->dst)
> -		return;
> -
>  	omapdss_output_unset_device(dssdev);
>  
>  	dss_mgr_disconnect(&dsi->output, dssdev);
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index e0406f2a90e7..7e5474e87c11 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -478,11 +478,6 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
>  {
>  	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  
> -	WARN_ON(dst != dssdev->dst);
> -
> -	if (dst != dssdev->dst)
> -		return;
> -
>  	omapdss_output_unset_device(dssdev);
>  
>  	dss_mgr_disconnect(&hdmi->output, dssdev);
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index 45d2eacedb2a..86b18ccb8d24 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -481,11 +481,6 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
>  {
>  	struct omap_hdmi *hdmi = dssdev_to_hdmi(dssdev);
>  
> -	WARN_ON(dst != dssdev->dst);
> -
> -	if (dst != dssdev->dst)
> -		return;
> -
>  	omapdss_output_unset_device(dssdev);
>  
>  	dss_mgr_disconnect(&hdmi->output, dssdev);
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 58bd6948bcde..0033adf534d3 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -391,6 +391,9 @@ struct omap_dss_device {
>  
>  	struct module *owner;
>  
> +	struct omap_dss_device *src;
> +	struct omap_dss_device *dst;
> +
>  	struct list_head list;
>  	struct list_head panel_list;
>  
> @@ -409,8 +412,6 @@ struct omap_dss_device {
>  
>  	enum omap_display_caps caps;
>  
> -	struct omap_dss_device *src;
> -
>  	enum omap_dss_display_state state;
>  
>  	/* OMAP DSS output specific fields */
> @@ -426,9 +427,6 @@ struct omap_dss_device {
>  
>  	/* the port number in the DT node */
>  	int port_num;
> -
> -	/* dynamic fields */
> -	struct omap_dss_device *dst;
>  };
>  
>  struct omap_dss_driver {
> diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
> index e659c8e5c419..6abdb615a4c0 100644
> --- a/drivers/gpu/drm/omapdrm/dss/output.c
> +++ b/drivers/gpu/drm/omapdrm/dss/output.c
> @@ -47,9 +47,6 @@ int omapdss_output_set_device(struct omap_dss_device *out,
>  		goto err;
>  	}
>  
> -	out->dst = dssdev;
> -	dssdev->src = out;
> -
>  	mutex_unlock(&output_lock);
>  
>  	return 0;
> @@ -81,9 +78,6 @@ int omapdss_output_unset_device(struct omap_dss_device *out)
>  		goto err;
>  	}
>  
> -	out->dst->src = NULL;
> -	out->dst = NULL;
> -
>  	mutex_unlock(&output_lock);
>  
>  	return 0;
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index 49499a2aae46..77a8f7d86f7a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> @@ -298,11 +298,6 @@ static void sdi_disconnect(struct omap_dss_device *dssdev,
>  {
>  	struct sdi_device *sdi = dssdev_to_sdi(dssdev);
>  
> -	WARN_ON(dst != dssdev->dst);
> -
> -	if (dst != dssdev->dst)
> -		return;
> -
>  	omapdss_output_unset_device(dssdev);
>  
>  	dss_mgr_disconnect(&sdi->output, dssdev);
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index c2ea182f1074..8ea622d02b5c 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -740,11 +740,6 @@ static void venc_disconnect(struct omap_dss_device *dssdev,
>  {
>  	struct venc_device *venc = dssdev_to_venc(dssdev);
>  
> -	WARN_ON(dst != dssdev->dst);
> -
> -	if (dst != dssdev->dst)
> -		return;
> -
>  	omapdss_output_unset_device(dssdev);
>  
>  	dss_mgr_disconnect(&venc->output, dssdev);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20180610/c56729b7/attachment.sig>


More information about the dri-devel mailing list