Now a panel_bridge is automatically created for every drm_panel and the
panel-bridge API is just a deprecated wrapper to access it.

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

And since of_drm_find_and_get_bridge() returns a refcounted bridge, take
care of putting the bridge reference.

Signed-off-by: Luca Ceresoli <[email protected]>
---
 drivers/gpu/drm/tve200/Kconfig      |  1 -
 drivers/gpu/drm/tve200/tve200_drm.h |  1 -
 drivers/gpu/drm/tve200/tve200_drv.c | 30 +++++++-----------------------
 3 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/tve200/Kconfig b/drivers/gpu/drm/tve200/Kconfig
index c0746ae8f703..afe243df4ebb 100644
--- a/drivers/gpu/drm/tve200/Kconfig
+++ b/drivers/gpu/drm/tve200/Kconfig
@@ -8,7 +8,6 @@ config DRM_TVE200
        select DRM_BRIDGE
        select DRM_CLIENT_SELECTION
        select DRM_PANEL
-       select DRM_PANEL_BRIDGE
        select DRM_KMS_HELPER
        select DRM_GEM_DMA_HELPER
        help
diff --git a/drivers/gpu/drm/tve200/tve200_drm.h 
b/drivers/gpu/drm/tve200/tve200_drm.h
index 631a9f5d9aa6..708f8020667a 100644
--- a/drivers/gpu/drm/tve200/tve200_drm.h
+++ b/drivers/gpu/drm/tve200/tve200_drm.h
@@ -103,7 +103,6 @@ struct tve200_drm_dev_private {
        struct drm_device *drm;
 
        struct drm_connector *connector;
-       struct drm_panel *panel;
        struct drm_bridge *bridge;
        struct drm_plane plane;
        struct drm_crtc crtc;
diff --git a/drivers/gpu/drm/tve200/tve200_drv.c 
b/drivers/gpu/drm/tve200/tve200_drv.c
index 63ca4a53fc4c..9874554e5065 100644
--- a/drivers/gpu/drm/tve200/tve200_drv.c
+++ b/drivers/gpu/drm/tve200/tve200_drv.c
@@ -65,7 +65,6 @@ static int tve200_modeset_init(struct drm_device *dev)
 {
        struct drm_mode_config *mode_config;
        struct tve200_drm_dev_private *priv = dev->dev_private;
-       struct drm_panel *panel;
        struct drm_bridge *bridge;
        int ret;
 
@@ -77,19 +76,10 @@ static int tve200_modeset_init(struct drm_device *dev)
        mode_config->min_height = 240;
        mode_config->max_height = 576;
 
-       ret = drm_of_find_panel_or_bridge(dev->dev->of_node,
-                                         0, 0, &panel, &bridge);
-       if (ret && ret != -ENODEV)
-               return ret;
-       if (panel) {
-               bridge = drm_panel_bridge_add_typed(panel,
-                                                   DRM_MODE_CONNECTOR_Unknown);
-               drm_panel_put(panel);
-               if (IS_ERR(bridge)) {
-                       ret = PTR_ERR(bridge);
-                       goto out_bridge;
-               }
-       } else {
+       bridge = of_drm_get_bridge_by_endpoint(dev->dev->of_node, 0, 0);
+       if (IS_ERR(bridge) && PTR_ERR(bridge) != -ENODEV)
+               return PTR_ERR(bridge);
+       if (IS_ERR(bridge) || !drm_bridge_is_panel(bridge)) {
                /*
                 * TODO: when we are using a different bridge than a panel
                 * (such as a dumb VGA connector) we need to devise a different
@@ -100,6 +90,8 @@ static int tve200_modeset_init(struct drm_device *dev)
                goto out_bridge;
        }
 
+       bridge->type = DRM_MODE_CONNECTOR_Unknown;
+
        ret = tve200_display_init(dev);
        if (ret) {
                dev_err(dev->dev, "failed to init display\n");
@@ -121,9 +113,6 @@ static int tve200_modeset_init(struct drm_device *dev)
                goto out_bridge;
        }
 
-       dev_info(dev->dev, "attached to panel %s\n",
-                dev_name(panel->dev));
-
        ret = drm_vblank_init(dev, 1);
        if (ret) {
                dev_err(dev->dev, "failed to init vblank\n");
@@ -136,8 +125,6 @@ static int tve200_modeset_init(struct drm_device *dev)
        goto finish;
 
 out_bridge:
-       if (panel)
-               drm_panel_bridge_remove(bridge);
        drm_mode_config_cleanup(dev);
 finish:
        return ret;
@@ -233,8 +220,6 @@ static int tve200_probe(struct platform_device *pdev)
        return 0;
 
 mode_config_cleanup:
-       if (priv->panel)
-               drm_panel_bridge_remove(priv->bridge);
        drm_mode_config_cleanup(drm);
 clk_disable:
        clk_disable_unprepare(priv->pclk);
@@ -248,10 +233,9 @@ static void tve200_remove(struct platform_device *pdev)
        struct drm_device *drm = platform_get_drvdata(pdev);
        struct tve200_drm_dev_private *priv = drm->dev_private;
 
+       drm_bridge_put(priv->bridge);
        drm_dev_unregister(drm);
        drm_atomic_helper_shutdown(drm);
-       if (priv->panel)
-               drm_panel_bridge_remove(priv->bridge);
        drm_mode_config_cleanup(drm);
        clk_disable_unprepare(priv->pclk);
        drm_dev_put(drm);

-- 
2.55.0

Reply via email to