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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx>
---
 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 00fa360163a3..71a8269b797a 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 23d5b8f9c3b4..aab47a31f01b 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -670,11 +670,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 288678890d25..95b5590f70a9 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 afb0438901f7..3e79865d4b6c 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 b3709df7bbfe..a34b1f97c085 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -389,6 +389,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;
 
@@ -407,8 +410,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 */
@@ -424,9 +425,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@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux