[PATCH v3 23/61] drm/omap: dss: Move src and dst check and set to connection handlers

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Aug 6 00:27:03 UTC 2018


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>
---
 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 5724bdf53a42..c058f889700d 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 d65fed251b13..b0e75af56485 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 bdd9d39215a4..218cf73d1455 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 599ef628736b..22d3818208d7 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 11d94b310d1a..bb7dcd88026f 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 3cc91e973f01..8e3dce1ddfb0 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 b21499e124c1..e782be2c36bc 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -301,11 +301,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 4cae03f24e1b..17668da8ac5a 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



More information about the dri-devel mailing list