drm/omap: dss: Move debug message and checks to connection handlers
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 28 Feb 2018 15:30:30 +0000 (17:30 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 3 Sep 2018 13:13:26 +0000 (16:13 +0300)
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>
14 files changed:
drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
drivers/gpu/drm/omapdrm/displays/connector-dvi.c
drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
drivers/gpu/drm/omapdrm/displays/panel-dpi.c
drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
drivers/gpu/drm/omapdrm/dss/base.c

index 41ba3c5dbe7db9aabc0c9cab4d8c7aad7e69040e..d77e21fc26ad16c203a43c1a48813509edf6ba2a 100644 (file)
@@ -48,11 +48,6 @@ static int tvc_connect(struct omap_dss_device *dssdev)
        struct omap_dss_device *in;
        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);
        if (IS_ERR(in)) {
                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 omap_dss_device *in = ddata->in;
 
-       dev_dbg(ddata->dev, "disconnect\n");
-
-       if (!omapdss_device_is_connected(dssdev))
-               return;
-
        omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
index f193bbda550c4e6099bf7d1aaeeac9e7de8a0fd5..9a3ecc3ed5b2f57f7f0a711243a9e9ebf2bba5df 100644 (file)
@@ -63,9 +63,6 @@ static int dvic_connect(struct omap_dss_device *dssdev)
        struct omap_dss_device *in;
        int r;
 
-       if (omapdss_device_is_connected(dssdev))
-               return 0;
-
        in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
        if (IS_ERR(in)) {
                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 omap_dss_device *in = ddata->in;
 
-       if (!omapdss_device_is_connected(dssdev))
-               return;
-
        omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
index 014554afbb0d15569010701b4b29f37438bc3253..665af9932317572e06b5ed112cbc0eb8c391c389 100644 (file)
@@ -58,11 +58,6 @@ static int hdmic_connect(struct omap_dss_device *dssdev)
        struct omap_dss_device *in;
        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);
        if (IS_ERR(in)) {
                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 omap_dss_device *in = ddata->in;
 
-       dev_dbg(ddata->dev, "disconnect\n");
-
-       if (!omapdss_device_is_connected(dssdev))
-               return;
-
        omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
index 752b565987c1ec83fc92f311623b7e5586b944e2..5b9ef09e6b2d757d80974eb7e9be214ffd3a75f1 100644 (file)
@@ -39,11 +39,6 @@ static int opa362_connect(struct omap_dss_device *dssdev,
        struct omap_dss_device *in;
        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);
        if (IS_ERR(in)) {
                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 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);
        if (dst != dssdev->dst)
                return;
index a8660e5e5ffc679f775fbe34147b2b6562b36838..b22c8f71c0e573e3b5d71a473e837f9f68a93dbc 100644 (file)
@@ -35,9 +35,6 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
        struct omap_dss_device *in;
        int r;
 
-       if (omapdss_device_is_connected(dssdev))
-               return -EBUSY;
-
        in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
        if (IS_ERR(in)) {
                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 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);
        if (dst != dssdev->dst)
                return;
index 9875195013367ad4d09f641c2be8906690e2856c..5d704cf0809fd5a28e61aa5c93aac86b74a04e19 100644 (file)
@@ -41,9 +41,6 @@ static int panel_dpi_connect(struct omap_dss_device *dssdev)
        struct omap_dss_device *in;
        int r;
 
-       if (omapdss_device_is_connected(dssdev))
-               return 0;
-
        in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
        if (IS_ERR(in)) {
                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 omap_dss_device *in = ddata->in;
 
-       if (!omapdss_device_is_connected(dssdev))
-               return;
-
        omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
index b7cd2ef17fbb7449c650f46fbdce1e9033e1e9d7..be6c0c811e66df3e9637349e5465eb641049f86c 100644 (file)
@@ -763,9 +763,6 @@ static int dsicm_connect(struct omap_dss_device *dssdev)
        struct omap_dss_device *in;
        int r;
 
-       if (omapdss_device_is_connected(dssdev))
-               return 0;
-
        in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
        if (IS_ERR(in)) {
                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 omap_dss_device *in = ddata->in;
 
-       if (!omapdss_device_is_connected(dssdev))
-               return;
-
        in->ops->dsi.release_vc(in, ddata->channel);
        omapdss_device_disconnect(in, dssdev);
 
index e4a3b5828bf904e80a87caf1bfe5d143f39c5a50..50b74e7351e91534023acf3fa6b26291862b2543 100644 (file)
@@ -122,9 +122,6 @@ static int lb035q02_connect(struct omap_dss_device *dssdev)
        struct omap_dss_device *in;
        int r;
 
-       if (omapdss_device_is_connected(dssdev))
-               return 0;
-
        in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
        if (IS_ERR(in)) {
                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 omap_dss_device *in = ddata->in;
 
-       if (!omapdss_device_is_connected(dssdev))
-               return;
-
        omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
index e89dd32a2a602d12e096a3a38b05bd8f7fd60ec9..769cba6c99ef7bbea76d978aee5c09d20abe5534 100644 (file)
@@ -118,9 +118,6 @@ static int nec_8048_connect(struct omap_dss_device *dssdev)
        struct omap_dss_device *in;
        int r;
 
-       if (omapdss_device_is_connected(dssdev))
-               return 0;
-
        in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
        if (IS_ERR(in)) {
                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 omap_dss_device *in = ddata->in;
 
-       if (!omapdss_device_is_connected(dssdev))
-               return;
-
        omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
index d0451cfab7f88ad0098e9659e58291cf325199a1..629ea2d935751921990b0f77522ed8caccc79d00 100644 (file)
@@ -64,9 +64,6 @@ static int sharp_ls_connect(struct omap_dss_device *dssdev)
        struct omap_dss_device *in;
        int r;
 
-       if (omapdss_device_is_connected(dssdev))
-               return 0;
-
        in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
        if (IS_ERR(in)) {
                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 omap_dss_device *in = ddata->in;
 
-       if (!omapdss_device_is_connected(dssdev))
-               return;
-
        omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
index 9033e9d25b7f96324c0fe64e419669e0f52da59a..82797df80e66bfecb3dc622da69c046eadff2614 100644 (file)
@@ -513,9 +513,6 @@ static int acx565akm_connect(struct omap_dss_device *dssdev)
        struct omap_dss_device *in;
        int r;
 
-       if (omapdss_device_is_connected(dssdev))
-               return 0;
-
        in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
        if (IS_ERR(in)) {
                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 omap_dss_device *in = ddata->in;
 
-       if (!omapdss_device_is_connected(dssdev))
-               return;
-
        omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
index 8865459b6c90169922b9ec7610854583d214588b..298fedf96efe89015566e18e5e4367dc28e73e27 100644 (file)
@@ -172,9 +172,6 @@ static int td028ttec1_panel_connect(struct omap_dss_device *dssdev)
        struct omap_dss_device *in;
        int r;
 
-       if (omapdss_device_is_connected(dssdev))
-               return 0;
-
        in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
        if (IS_ERR(in)) {
                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 omap_dss_device *in = ddata->in;
 
-       if (!omapdss_device_is_connected(dssdev))
-               return;
-
        omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
index 1daba7a60a9c0652564498a7cbfec3148f31d962..df3d8103823da942a391ad76d5d45073579d5e65 100644 (file)
@@ -343,9 +343,6 @@ static int tpo_td043_connect(struct omap_dss_device *dssdev)
        struct omap_dss_device *in;
        int r;
 
-       if (omapdss_device_is_connected(dssdev))
-               return 0;
-
        in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
        if (IS_ERR(in)) {
                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 omap_dss_device *in = ddata->in;
 
-       if (!omapdss_device_is_connected(dssdev))
-               return;
-
        omapdss_device_disconnect(in, dssdev);
 
        omap_dss_put_device(in);
index 576fd3d1325949d5450e2ea05c83ac237dc1c2ab..599ef628736b5afef2bcdb945046d0e30130941d 100644 (file)
@@ -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,
                           struct omap_dss_device *dst)
 {
+       dev_dbg(src->dev, "connect\n");
+
+       if (omapdss_device_is_connected(src))
+               return -EBUSY;
+
        if (src->driver)
                return src->driver->connect(src);
        else
@@ -115,6 +120,13 @@ EXPORT_SYMBOL_GPL(omapdss_device_connect);
 void omapdss_device_disconnect(struct omap_dss_device *src,
                               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)
                src->driver->disconnect(src);
        else