OSDN Git Service

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 41ba3c5..d77e21f 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 f193bbd..9a3ecc3 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 014554a..665af99 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 752b565..5b9ef09 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 a8660e5..b22c8f7 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 9875195..5d704cf 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 b7cd2ef..be6c0c8 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 e4a3b58..50b74e7 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 e89dd32..769cba6 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 d0451cf..629ea2d 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 9033e9d..82797df 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 8865459..298fedf 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 1daba7a..df3d810 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 576fd3d..599ef62 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