Now a panel_bridge is automatically created for every drm_panel, so this
call to drm_panel_bridge_add_typed() would lead to creating a second
bridge for the same panel.

Update and simplify the code by just getting a reference to the
already-existing bridge.

As of_drm_get_bridge_by_endpoint() returns a refcounted bridge, take care
of putting the bridge reference by using bridge->next_bridge.

Signed-off-by: Luca Ceresoli <[email protected]>
---
 drivers/gpu/drm/bridge/Kconfig    |  2 --
 drivers/gpu/drm/bridge/tc358768.c | 25 ++++++-------------------
 2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index eb16f858459d..f897058462c8 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -408,8 +408,6 @@ config DRM_TOSHIBA_TC358768
        depends on OF
        select DRM_KMS_HELPER
        select REGMAP_I2C
-       select DRM_PANEL
-       select DRM_PANEL_BRIDGE
        select DRM_MIPI_DSI
        select VIDEOMODE_HELPERS
        help
diff --git a/drivers/gpu/drm/bridge/tc358768.c 
b/drivers/gpu/drm/bridge/tc358768.c
index d1fc6af37cc5..cc989ab5cf25 100644
--- a/drivers/gpu/drm/bridge/tc358768.c
+++ b/drivers/gpu/drm/bridge/tc358768.c
@@ -22,7 +22,6 @@
 #include <drm/drm_drv.h>
 #include <drm/drm_mipi_dsi.h>
 #include <drm/drm_of.h>
-#include <drm/drm_panel.h>
 #include <video/mipi_display.h>
 #include <video/videomode.h>
 
@@ -137,7 +136,6 @@ static const char * const tc358768_supplies[] = {
 
 struct tc358768_dsi_output {
        struct mipi_dsi_device *dev;
-       struct drm_panel *panel;
        struct drm_bridge *bridge;
 };
 
@@ -443,7 +441,6 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host 
*host,
 {
        struct tc358768_priv *priv = dsi_host_to_tc358768(host);
        struct drm_bridge *bridge;
-       struct drm_panel *panel;
        struct device_node *ep;
        int ret;
 
@@ -471,24 +468,15 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host 
*host,
                return -ENOTSUPP;
        }
 
-       ret = drm_of_find_panel_or_bridge(host->dev->of_node, 1, 0, &panel,
-                                         &bridge);
-       if (ret)
-               return ret;
+       bridge = of_drm_get_bridge_by_endpoint(host->dev->of_node, 1, 0);
+       if (IS_ERR(bridge))
+               return PTR_ERR(bridge);
 
-       if (panel) {
-               bridge = drm_panel_bridge_add_typed(panel,
-                                                   DRM_MODE_CONNECTOR_DSI);
-               drm_panel_put(panel);
-               if (IS_ERR(bridge))
-                       return PTR_ERR(bridge);
-
-               bridge->pre_enable_prev_first = true;
-       }
+       bridge->type = DRM_MODE_CONNECTOR_DSI;
+       bridge->pre_enable_prev_first = true;
 
        priv->output.dev = dev;
        priv->output.bridge = bridge;
-       priv->output.panel = panel;
 
        priv->dsi_lanes = dev->lanes;
        priv->dsi_bpp = mipi_dsi_pixel_format_to_bpp(dev->format);
@@ -518,8 +506,7 @@ static int tc358768_dsi_host_detach(struct mipi_dsi_host 
*host,
        struct tc358768_priv *priv = dsi_host_to_tc358768(host);
 
        drm_bridge_remove(&priv->bridge);
-       if (priv->output.panel)
-               drm_panel_bridge_remove(priv->output.bridge);
+       drm_bridge_put(priv->output.bridge);
 
        return 0;
 }

-- 
2.55.0

Reply via email to