]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/bridge: Centralize error message when bridge attach fails
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tue, 23 Mar 2021 21:50:08 +0000 (23:50 +0200)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Wed, 28 Jul 2021 13:33:12 +0000 (16:33 +0300)
Being informed of a failure to attach a bridge is useful, and many
drivers prints an error message in that case. Move the message to
drm_bridge_attach() to avoid code duplication.

Suggested-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jyri Sarha <jyri.sarha@iki.fi>
26 files changed:
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
drivers/gpu/drm/bridge/analogix/anx7625.c
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
drivers/gpu/drm/drm_bridge.c
drivers/gpu/drm/exynos/exynos_dp.c
drivers/gpu/drm/exynos/exynos_hdmi.c
drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
drivers/gpu/drm/imx/dcss/dcss-kms.c
drivers/gpu/drm/imx/imx-ldb.c
drivers/gpu/drm/imx/parallel-display.c
drivers/gpu/drm/ingenic/ingenic-drm-drv.c
drivers/gpu/drm/kmb/kmb_dsi.c
drivers/gpu/drm/mcde/mcde_dsi.c
drivers/gpu/drm/mediatek/mtk_dpi.c
drivers/gpu/drm/mediatek/mtk_hdmi.c
drivers/gpu/drm/omapdrm/omap_drv.c
drivers/gpu/drm/rockchip/rockchip_lvds.c
drivers/gpu/drm/rockchip/rockchip_rgb.c
drivers/gpu/drm/sti/sti_dvo.c
drivers/gpu/drm/sun4i/sun4i_lvds.c
drivers/gpu/drm/sun4i/sun4i_rgb.c
drivers/gpu/drm/tegra/rgb.c
drivers/gpu/drm/tidss/tidss_kms.c
drivers/gpu/drm/tilcdc/tilcdc_external.c
drivers/gpu/drm/vc4/vc4_dsi.c

index 550814ca2139a5d0f29cbaf43091c050660ecac6..b7d2e4449cfaa44caaf0b2f274d879bbfde32a22 100644 (file)
@@ -1583,7 +1583,6 @@ static int analogix_dp_create_bridge(struct drm_device *drm_dev,
                                     struct analogix_dp_device *dp)
 {
        struct drm_bridge *bridge;
-       int ret;
 
        bridge = devm_kzalloc(drm_dev->dev, sizeof(*bridge), GFP_KERNEL);
        if (!bridge) {
@@ -1596,13 +1595,7 @@ static int analogix_dp_create_bridge(struct drm_device *drm_dev,
        bridge->driver_private = dp;
        bridge->funcs = &analogix_dp_bridge_funcs;
 
-       ret = drm_bridge_attach(dp->encoder, bridge, NULL, 0);
-       if (ret) {
-               DRM_ERROR("failed to attach drm bridge\n");
-               return -EINVAL;
-       }
-
-       return 0;
+       return drm_bridge_attach(dp->encoder, bridge, NULL, 0);
 }
 
 static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)
index a3d82377066bb49b249ae5854e9bffc054e8235e..ef29197fed50168a0bfb4240573d60ce4c571706 100644 (file)
@@ -1359,11 +1359,8 @@ static int anx7625_bridge_attach(struct drm_bridge *bridge,
                err = drm_bridge_attach(bridge->encoder,
                                        ctx->pdata.panel_bridge,
                                        &ctx->bridge, flags);
-               if (err) {
-                       DRM_DEV_ERROR(dev,
-                                     "Fail to attach panel bridge: %d\n", err);
+               if (err)
                        return err;
-               }
        }
 
        ctx->bridge_attached = 1;
index e7c7c9b9c646faad2cd7831eeba8ce43a6edbd03..77af492480694729ab08f3c204fdeb82578c0c32 100644 (file)
@@ -3474,7 +3474,6 @@ struct dw_hdmi *dw_hdmi_bind(struct platform_device *pdev,
        ret = drm_bridge_attach(encoder, &hdmi->bridge, NULL, 0);
        if (ret) {
                dw_hdmi_remove(hdmi);
-               DRM_ERROR("Failed to initialize bridge with drm\n");
                return ERR_PTR(ret);
        }
 
index 6b268f9445b36aea903d13fdd8c76822d50c66dc..7900da1d4325833df084c776251499b1fa3124d5 100644 (file)
@@ -1229,15 +1229,7 @@ EXPORT_SYMBOL_GPL(dw_mipi_dsi_remove);
  */
 int dw_mipi_dsi_bind(struct dw_mipi_dsi *dsi, struct drm_encoder *encoder)
 {
-       int ret;
-
-       ret = drm_bridge_attach(encoder, &dsi->bridge, NULL, 0);
-       if (ret) {
-               DRM_ERROR("Failed to initialize bridge with drm\n");
-               return ret;
-       }
-
-       return ret;
+       return drm_bridge_attach(encoder, &dsi->bridge, NULL, 0);
 }
 EXPORT_SYMBOL_GPL(dw_mipi_dsi_bind);
 
index 044acd07c15387a612946d821bec9701478b7196..11ec2846addbeec2e4719e402c53dc059e501f22 100644 (file)
@@ -28,6 +28,7 @@
 #include <drm/drm_atomic_state_helper.h>
 #include <drm/drm_bridge.h>
 #include <drm/drm_encoder.h>
+#include <drm/drm_print.h>
 
 #include "drm_crtc_internal.h"
 
@@ -225,6 +226,15 @@ err_reset_bridge:
        bridge->dev = NULL;
        bridge->encoder = NULL;
        list_del(&bridge->chain_node);
+
+#ifdef CONFIG_OF
+       DRM_ERROR("failed to attach bridge %pOF to encoder %s: %d\n",
+                 bridge->of_node, encoder->name, ret);
+#else
+       DRM_ERROR("failed to attach bridge to encoder %s: %d\n",
+                 encoder->name, ret);
+#endif
+
        return ret;
 }
 EXPORT_SYMBOL(drm_bridge_attach);
index 9ac51b6ab34b1dfa302efdc7c94af344fb49f759..27664f663c5a8224aa11e5725bc4cb7afcf10c7f 100644 (file)
@@ -109,11 +109,8 @@ static int exynos_dp_bridge_attach(struct analogix_dp_plat_data *plat_data,
        if (dp->ptn_bridge) {
                ret = drm_bridge_attach(&dp->encoder, dp->ptn_bridge, bridge,
                                        0);
-               if (ret) {
-                       DRM_DEV_ERROR(dp->dev,
-                                     "Failed to attach bridge to drm\n");
+               if (ret)
                        return ret;
-               }
        }
 
        return 0;
index f893731d6021136ceb1ed069ef378320f51a09ff..c769dec576de54f13c8a7f37127579fc5b990e8c 100644 (file)
@@ -970,11 +970,8 @@ static int hdmi_create_connector(struct drm_encoder *encoder)
        drm_connector_helper_add(connector, &hdmi_connector_helper_funcs);
        drm_connector_attach_encoder(connector, encoder);
 
-       if (hdata->bridge) {
+       if (hdata->bridge)
                ret = drm_bridge_attach(encoder, hdata->bridge, NULL, 0);
-               if (ret)
-                       DRM_DEV_ERROR(hdata->dev, "Failed to attach bridge\n");
-       }
 
        cec_fill_conn_info_from_drm(&conn_info, connector);
 
index 9b565a057340b40c38a743c418c33caf55eb116d..952cfdb1961d02c245484cde69d5a1eb78eb0868 100644 (file)
@@ -769,16 +769,9 @@ static int dsi_bridge_init(struct drm_device *dev, struct dw_dsi *dsi)
 {
        struct drm_encoder *encoder = &dsi->encoder;
        struct drm_bridge *bridge = dsi->bridge;
-       int ret;
 
        /* associate the bridge to dsi encoder */
-       ret = drm_bridge_attach(encoder, bridge, NULL, 0);
-       if (ret) {
-               DRM_ERROR("failed to attach external bridge\n");
-               return ret;
-       }
-
-       return 0;
+       return drm_bridge_attach(encoder, bridge, NULL, 0);
 }
 
 static int dsi_bind(struct device *dev, struct device *master, void *data)
index 917834b1c80eb6a2d161ac04282de61e87500551..9b84df34a6a12bbe8cd2f5b76948525749f90324 100644 (file)
@@ -93,11 +93,8 @@ static int dcss_kms_bridge_connector_init(struct dcss_kms_dev *kms)
 
        ret = drm_bridge_attach(encoder, bridge, NULL,
                                DRM_BRIDGE_ATTACH_NO_CONNECTOR);
-       if (ret < 0) {
-               dev_err(ddev->dev, "Unable to attach bridge %pOF\n",
-                       bridge->of_node);
+       if (ret < 0)
                return ret;
-       }
 
        kms->connector = drm_bridge_connector_init(ddev, encoder);
        if (IS_ERR(kms->connector)) {
index 53132ddf9587b6381e42b33ed60ab5d759c676e4..e5078d03020d90e84b2ca6acbc877ae52234d4ac 100644 (file)
@@ -465,10 +465,8 @@ static int imx_ldb_register(struct drm_device *drm,
 
        if (imx_ldb_ch->bridge) {
                ret = drm_bridge_attach(encoder, imx_ldb_ch->bridge, NULL, 0);
-               if (ret) {
-                       DRM_ERROR("Failed to initialize bridge with drm\n");
+               if (ret)
                        return ret;
-               }
        } else {
                /*
                 * We want to add the connector whenever there is no bridge
index e0412e694fd9bfa1f133af44e7e4fd8c78fbfe53..a8aba0141ce712db31dcedef39fb287e7afb37c2 100644 (file)
@@ -294,11 +294,8 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
 
        if (imxpd->next_bridge) {
                ret = drm_bridge_attach(encoder, imxpd->next_bridge, bridge, 0);
-               if (ret < 0) {
-                       dev_err(imxpd->dev, "failed to attach bridge: %d\n",
-                               ret);
+               if (ret < 0)
                        return ret;
-               }
        } else {
                drm_connector_helper_add(connector,
                                         &imx_pd_connector_helper_funcs);
index 857ed070b21bfc6ba5bd48e09d870d6bc55b0169..d261f7a03b18dbb8ff41ea91937eaa7f9c110b02 100644 (file)
@@ -1081,10 +1081,8 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)
                drm_encoder_helper_add(encoder, &ingenic_drm_encoder_helper_funcs);
 
                ret = drm_bridge_attach(encoder, bridge, NULL, 0);
-               if (ret) {
-                       dev_err(dev, "Unable to attach bridge\n");
+               if (ret)
                        return ret;
-               }
        }
 
        drm_for_each_encoder(encoder, drm) {
index 231041b269f5395f2e79389522d030b25a307699..1793cd31b1178b457143a6386cfc4dfff85379f8 100644 (file)
@@ -1441,7 +1441,6 @@ int kmb_dsi_encoder_init(struct drm_device *dev, struct kmb_dsi *kmb_dsi)
        ret = drm_bridge_attach(encoder, adv_bridge, NULL,
                                DRM_BRIDGE_ATTACH_NO_CONNECTOR);
        if (ret) {
-               DRM_ERROR("failed to attach bridge to MIPI\n");
                drm_encoder_cleanup(encoder);
                return ret;
        }
index 34a00d7e9c380ef45cc5e185cd25966469983d21..f3644667e24fdf4a7debb8d5a8cee721936116d1 100644 (file)
@@ -1052,7 +1052,6 @@ static int mcde_dsi_bridge_attach(struct drm_bridge *bridge,
 {
        struct mcde_dsi *d = bridge_to_mcde_dsi(bridge);
        struct drm_device *drm = bridge->dev;
-       int ret;
 
        if (!drm_core_check_feature(drm, DRIVER_ATOMIC)) {
                dev_err(d->dev, "we need atomic updates\n");
@@ -1060,13 +1059,7 @@ static int mcde_dsi_bridge_attach(struct drm_bridge *bridge,
        }
 
        /* Attach the DSI bridge to the output (panel etc) bridge */
-       ret = drm_bridge_attach(bridge->encoder, d->bridge_out, bridge, flags);
-       if (ret) {
-               dev_err(d->dev, "failed to attach the DSI bridge\n");
-               return ret;
-       }
-
-       return 0;
+       return drm_bridge_attach(bridge->encoder, d->bridge_out, bridge, flags);
 }
 
 static const struct drm_bridge_funcs mcde_dsi_bridge_funcs = {
index bced555648b01385566733f5ee68313d2bd7f9bd..96d35770c8447aff7c590a254e7616d31750ba30 100644 (file)
@@ -714,10 +714,8 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)
 
        ret = drm_bridge_attach(&dpi->encoder, &dpi->bridge, NULL,
                                DRM_BRIDGE_ATTACH_NO_CONNECTOR);
-       if (ret) {
-               dev_err(dev, "Failed to attach bridge: %d\n", ret);
+       if (ret)
                goto err_cleanup;
-       }
 
        dpi->connector = drm_bridge_connector_init(drm_dev, &dpi->encoder);
        if (IS_ERR(dpi->connector)) {
index c1651a83700d2f74003e423fc3c8ca1c84469643..5838c44cbf6f0dd221a9896c68beefc03ce48359 100644 (file)
@@ -1293,11 +1293,8 @@ static int mtk_hdmi_bridge_attach(struct drm_bridge *bridge,
        if (hdmi->next_bridge) {
                ret = drm_bridge_attach(bridge->encoder, hdmi->next_bridge,
                                        bridge, flags);
-               if (ret) {
-                       dev_err(hdmi->dev,
-                               "Failed to attach external bridge: %d\n", ret);
+               if (ret)
                        return ret;
-               }
        }
 
        mtk_cec_set_hpd_event(hdmi->cec_dev, mtk_hdmi_hpd_event, hdmi->dev);
index 8632139e0f01a0b0196549420d1e52cb3a63d131..f86e20578143044522df481a962a4dc24ab027e3 100644 (file)
@@ -290,12 +290,8 @@ static int omap_modeset_init(struct drm_device *dev)
                        ret = drm_bridge_attach(pipe->encoder,
                                                pipe->output->bridge, NULL,
                                                DRM_BRIDGE_ATTACH_NO_CONNECTOR);
-                       if (ret < 0) {
-                               dev_err(priv->dev,
-                                       "unable to attach bridge %pOF\n",
-                                       pipe->output->bridge->of_node);
+                       if (ret < 0)
                                return ret;
-                       }
                }
 
                id = omap_display_id(pipe->output);
index 489d63c05c0d9d5e7b02f643a247bf030f196be3..551653940e396ccd65b00aa2b225f1e2286e9ddb 100644 (file)
@@ -636,11 +636,8 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
                }
        } else {
                ret = drm_bridge_attach(encoder, lvds->bridge, NULL, 0);
-               if (ret) {
-                       DRM_DEV_ERROR(drm_dev->dev,
-                                     "failed to attach bridge: %d\n", ret);
+               if (ret)
                        goto err_free_encoder;
-               }
        }
 
        pm_runtime_enable(dev);
index c079714477d8a5b482e1807a98c0922363b09c26..d691d9bef8e7dc1512a1c474113a54ce3ef23bc6 100644 (file)
@@ -143,11 +143,8 @@ struct rockchip_rgb *rockchip_rgb_init(struct device *dev,
        rgb->bridge = bridge;
 
        ret = drm_bridge_attach(encoder, rgb->bridge, NULL, 0);
-       if (ret) {
-               DRM_DEV_ERROR(drm_dev->dev,
-                             "failed to attach bridge: %d\n", ret);
+       if (ret)
                goto err_free_encoder;
-       }
 
        return rgb;
 
index ddb4184f07264c76b5b5e3e8d1db7232242691b1..b6ee8a82e656ca2dcc63ae255d4dd3a964ab5b69 100644 (file)
@@ -463,10 +463,8 @@ static int sti_dvo_bind(struct device *dev, struct device *master, void *data)
        drm_bridge_add(bridge);
 
        err = drm_bridge_attach(encoder, bridge, NULL, 0);
-       if (err) {
-               DRM_ERROR("Failed to attach bridge\n");
+       if (err)
                return err;
-       }
 
        dvo->bridge = bridge;
        connector->encoder = encoder;
index ac570437172e2190e9c6c1960db5d5e309e463f6..6716e895ae8a4ba65bec68694de51d851d38e994 100644 (file)
@@ -142,10 +142,8 @@ int sun4i_lvds_init(struct drm_device *drm, struct sun4i_tcon *tcon)
 
        if (bridge) {
                ret = drm_bridge_attach(encoder, bridge, NULL, 0);
-               if (ret) {
-                       dev_err(drm->dev, "Couldn't attach our bridge\n");
+               if (ret)
                        goto err_cleanup_connector;
-               }
        }
 
        return 0;
index e172426eb7e9eb58407a99f7be1f2104d81aff7b..dfb6acc42f02efc40f36914e2925510cd8056d0b 100644 (file)
@@ -234,10 +234,8 @@ int sun4i_rgb_init(struct drm_device *drm, struct sun4i_tcon *tcon)
 
        if (rgb->bridge) {
                ret = drm_bridge_attach(encoder, rgb->bridge, NULL, 0);
-               if (ret) {
-                       dev_err(drm->dev, "Couldn't attach our bridge\n");
+               if (ret)
                        goto err_cleanup_connector;
-               }
        }
 
        return 0;
index 4142a56ca764485dc13bfbe3134cba96d66f8432..606c78a2b988f1756048baae69734962250e52b2 100644 (file)
@@ -275,11 +275,8 @@ int tegra_dc_rgb_init(struct drm_device *drm, struct tegra_dc *dc)
        if (output->bridge) {
                err = drm_bridge_attach(&output->encoder, output->bridge,
                                        NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
-               if (err) {
-                       dev_err(output->dev, "failed to attach bridge: %d\n",
-                               err);
+               if (err)
                        return err;
-               }
 
                connector = drm_bridge_connector_init(drm, &output->encoder);
                if (IS_ERR(connector)) {
index 95f8e0f78e324ad2f042fd8d1696629ce049f4f8..666e527a0acf10c1e2589bcb6beb5f2421d394d3 100644 (file)
@@ -227,10 +227,8 @@ static int tidss_dispc_modeset_init(struct tidss_device *tidss)
                }
 
                ret = drm_bridge_attach(enc, pipes[i].bridge, NULL, 0);
-               if (ret) {
-                       dev_err(tidss->dev, "bridge attach failed: %d\n", ret);
+               if (ret)
                        return ret;
-               }
        }
 
        /* create overlay planes of the leftover planes */
index b177525588c14ac6c96562e4f6b40ac5975e6143..7594cf6e186eb214c2451a96812433172b88d842 100644 (file)
@@ -93,10 +93,8 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
        priv->external_encoder->possible_crtcs = BIT(0);
 
        ret = drm_bridge_attach(priv->external_encoder, bridge, NULL, 0);
-       if (ret) {
-               dev_err(ddev->dev, "drm_bridge_attach() failed %d\n", ret);
+       if (ret)
                return ret;
-       }
 
        tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_default);
 
index a55256ed0955841c620159af2611475e4ec780bd..a185027911ce5ac06430efc06c96aec3b36717b8 100644 (file)
@@ -1646,10 +1646,8 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
        drm_encoder_helper_add(dsi->encoder, &vc4_dsi_encoder_helper_funcs);
 
        ret = drm_bridge_attach(dsi->encoder, dsi->bridge, NULL, 0);
-       if (ret) {
-               dev_err(dev, "bridge attach failed: %d\n", ret);
+       if (ret)
                return ret;
-       }
        /* Disable the atomic helper calls into the bridge.  We
         * manually call the bridge pre_enable / enable / etc. calls
         * from our driver, since we need to sequence them within the