Browse Source

drm/omap: dss: Move debug message and checks to connection handlers

The connectors, encoders and display duplicate the same debug messages
and connection checks in their omap_dss_device connect and disconnect
handlers. Move the code to the connect and disconnect wrappers.

To simplify the code the connect function returns -EBUSY unconditionally
if the device is already connected. This doesn't cause any change in
practice: the connect handler of displays is never called on a connected
device as it is only invoked during omapdrm initialization.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Laurent Pinchart 7 years ago
parent
commit
1f507968c3

+ 0 - 10
drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c

@@ -48,11 +48,6 @@ static int tvc_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	dev_dbg(ddata->dev, "connect\n");
-
-	if (omapdss_device_is_connected(dssdev))
-		return 0;
-
 	in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(ddata->dev, "failed to find video source\n");
 		dev_err(ddata->dev, "failed to find video source\n");
@@ -74,11 +69,6 @@ static void tvc_disconnect(struct omap_dss_device *dssdev)
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	dev_dbg(ddata->dev, "disconnect\n");
-
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	omapdss_device_disconnect(in, dssdev);
 	omapdss_device_disconnect(in, dssdev);
 
 
 	omap_dss_put_device(in);
 	omap_dss_put_device(in);

+ 0 - 6
drivers/gpu/drm/omapdrm/displays/connector-dvi.c

@@ -63,9 +63,6 @@ static int dvic_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	if (omapdss_device_is_connected(dssdev))
-		return 0;
-
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		dev_err(dssdev->dev, "failed to find video source\n");
@@ -87,9 +84,6 @@ static void dvic_disconnect(struct omap_dss_device *dssdev)
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	omapdss_device_disconnect(in, dssdev);
 	omapdss_device_disconnect(in, dssdev);
 
 
 	omap_dss_put_device(in);
 	omap_dss_put_device(in);

+ 0 - 10
drivers/gpu/drm/omapdrm/displays/connector-hdmi.c

@@ -58,11 +58,6 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	dev_dbg(ddata->dev, "connect\n");
-
-	if (omapdss_device_is_connected(dssdev))
-		return 0;
-
 	in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(ddata->dev, "failed to find video source\n");
 		dev_err(ddata->dev, "failed to find video source\n");
@@ -84,11 +79,6 @@ static void hdmic_disconnect(struct omap_dss_device *dssdev)
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	dev_dbg(ddata->dev, "disconnect\n");
-
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	omapdss_device_disconnect(in, dssdev);
 	omapdss_device_disconnect(in, dssdev);
 
 
 	omap_dss_put_device(in);
 	omap_dss_put_device(in);

+ 0 - 11
drivers/gpu/drm/omapdrm/displays/encoder-opa362.c

@@ -39,11 +39,6 @@ static int opa362_connect(struct omap_dss_device *dssdev,
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	dev_dbg(dssdev->dev, "connect\n");
-
-	if (omapdss_device_is_connected(dssdev))
-		return -EBUSY;
-
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		dev_err(dssdev->dev, "failed to find video source\n");
@@ -69,12 +64,6 @@ static void opa362_disconnect(struct omap_dss_device *dssdev,
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	dev_dbg(dssdev->dev, "disconnect\n");
-
-	WARN_ON(!omapdss_device_is_connected(dssdev));
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	WARN_ON(dst != dssdev->dst);
 	WARN_ON(dst != dssdev->dst);
 	if (dst != dssdev->dst)
 	if (dst != dssdev->dst)
 		return;
 		return;

+ 0 - 7
drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c

@@ -35,9 +35,6 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	if (omapdss_device_is_connected(dssdev))
-		return -EBUSY;
-
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		dev_err(dssdev->dev, "failed to find video source\n");
@@ -63,10 +60,6 @@ static void tfp410_disconnect(struct omap_dss_device *dssdev,
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	WARN_ON(!omapdss_device_is_connected(dssdev));
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	WARN_ON(dst != dssdev->dst);
 	WARN_ON(dst != dssdev->dst);
 	if (dst != dssdev->dst)
 	if (dst != dssdev->dst)
 		return;
 		return;

+ 0 - 6
drivers/gpu/drm/omapdrm/displays/panel-dpi.c

@@ -41,9 +41,6 @@ static int panel_dpi_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	if (omapdss_device_is_connected(dssdev))
-		return 0;
-
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		dev_err(dssdev->dev, "failed to find video source\n");
@@ -65,9 +62,6 @@ static void panel_dpi_disconnect(struct omap_dss_device *dssdev)
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	omapdss_device_disconnect(in, dssdev);
 	omapdss_device_disconnect(in, dssdev);
 
 
 	omap_dss_put_device(in);
 	omap_dss_put_device(in);

+ 0 - 6
drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c

@@ -763,9 +763,6 @@ static int dsicm_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	if (omapdss_device_is_connected(dssdev))
-		return 0;
-
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		dev_err(dssdev->dev, "failed to find video source\n");
@@ -807,9 +804,6 @@ static void dsicm_disconnect(struct omap_dss_device *dssdev)
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	in->ops->dsi.release_vc(in, ddata->channel);
 	in->ops->dsi.release_vc(in, ddata->channel);
 	omapdss_device_disconnect(in, dssdev);
 	omapdss_device_disconnect(in, dssdev);
 
 

+ 0 - 6
drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c

@@ -122,9 +122,6 @@ static int lb035q02_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	if (omapdss_device_is_connected(dssdev))
-		return 0;
-
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		dev_err(dssdev->dev, "failed to find video source\n");
@@ -148,9 +145,6 @@ static void lb035q02_disconnect(struct omap_dss_device *dssdev)
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	omapdss_device_disconnect(in, dssdev);
 	omapdss_device_disconnect(in, dssdev);
 
 
 	omap_dss_put_device(in);
 	omap_dss_put_device(in);

+ 0 - 6
drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c

@@ -118,9 +118,6 @@ static int nec_8048_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	if (omapdss_device_is_connected(dssdev))
-		return 0;
-
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		dev_err(dssdev->dev, "failed to find video source\n");
@@ -142,9 +139,6 @@ static void nec_8048_disconnect(struct omap_dss_device *dssdev)
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	omapdss_device_disconnect(in, dssdev);
 	omapdss_device_disconnect(in, dssdev);
 
 
 	omap_dss_put_device(in);
 	omap_dss_put_device(in);

+ 0 - 6
drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c

@@ -64,9 +64,6 @@ static int sharp_ls_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	if (omapdss_device_is_connected(dssdev))
-		return 0;
-
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		dev_err(dssdev->dev, "failed to find video source\n");
@@ -88,9 +85,6 @@ static void sharp_ls_disconnect(struct omap_dss_device *dssdev)
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	omapdss_device_disconnect(in, dssdev);
 	omapdss_device_disconnect(in, dssdev);
 
 
 	omap_dss_put_device(in);
 	omap_dss_put_device(in);

+ 0 - 6
drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c

@@ -513,9 +513,6 @@ static int acx565akm_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	if (omapdss_device_is_connected(dssdev))
-		return 0;
-
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		dev_err(dssdev->dev, "failed to find video source\n");
@@ -537,9 +534,6 @@ static void acx565akm_disconnect(struct omap_dss_device *dssdev)
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	omapdss_device_disconnect(in, dssdev);
 	omapdss_device_disconnect(in, dssdev);
 
 
 	omap_dss_put_device(in);
 	omap_dss_put_device(in);

+ 0 - 6
drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c

@@ -172,9 +172,6 @@ static int td028ttec1_panel_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	if (omapdss_device_is_connected(dssdev))
-		return 0;
-
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		dev_err(dssdev->dev, "failed to find video source\n");
@@ -196,9 +193,6 @@ static void td028ttec1_panel_disconnect(struct omap_dss_device *dssdev)
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	omapdss_device_disconnect(in, dssdev);
 	omapdss_device_disconnect(in, dssdev);
 
 
 	omap_dss_put_device(in);
 	omap_dss_put_device(in);

+ 0 - 6
drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c

@@ -343,9 +343,6 @@ static int tpo_td043_connect(struct omap_dss_device *dssdev)
 	struct omap_dss_device *in;
 	struct omap_dss_device *in;
 	int r;
 	int r;
 
 
-	if (omapdss_device_is_connected(dssdev))
-		return 0;
-
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
 	if (IS_ERR(in)) {
 	if (IS_ERR(in)) {
 		dev_err(dssdev->dev, "failed to find video source\n");
 		dev_err(dssdev->dev, "failed to find video source\n");
@@ -367,9 +364,6 @@ static void tpo_td043_disconnect(struct omap_dss_device *dssdev)
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *in = ddata->in;
 	struct omap_dss_device *in = ddata->in;
 
 
-	if (!omapdss_device_is_connected(dssdev))
-		return;
-
 	omapdss_device_disconnect(in, dssdev);
 	omapdss_device_disconnect(in, dssdev);
 
 
 	omap_dss_put_device(in);
 	omap_dss_put_device(in);

+ 12 - 0
drivers/gpu/drm/omapdrm/dss/base.c

@@ -105,6 +105,11 @@ struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
 int omapdss_device_connect(struct omap_dss_device *src,
 int omapdss_device_connect(struct omap_dss_device *src,
 			   struct omap_dss_device *dst)
 			   struct omap_dss_device *dst)
 {
 {
+	dev_dbg(src->dev, "connect\n");
+
+	if (omapdss_device_is_connected(src))
+		return -EBUSY;
+
 	if (src->driver)
 	if (src->driver)
 		return src->driver->connect(src);
 		return src->driver->connect(src);
 	else
 	else
@@ -115,6 +120,13 @@ EXPORT_SYMBOL_GPL(omapdss_device_connect);
 void omapdss_device_disconnect(struct omap_dss_device *src,
 void omapdss_device_disconnect(struct omap_dss_device *src,
 			       struct omap_dss_device *dst)
 			       struct omap_dss_device *dst)
 {
 {
+	dev_dbg(src->dev, "disconnect\n");
+
+	if (!src->id && !omapdss_device_is_connected(src)) {
+		WARN_ON(!src->driver);
+		return;
+	}
+
 	if (src->driver)
 	if (src->driver)
 		src->driver->disconnect(src);
 		src->driver->disconnect(src);
 	else
 	else