diff mbox series

[2/3] drm/vc4: dpi: Switch to devm_drm_of_get_bridge

Message ID 20210910130941.1740182-3-maxime@cerno.tech (mailing list archive)
State New, archived
Headers show
Series drm/bridge: Create a function to abstract panels away | expand

Commit Message

Maxime Ripard Sept. 10, 2021, 1:09 p.m. UTC
The new devm_drm_of_get_bridge removes most of the boilerplate we
have to deal with. Let's switch to it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/gpu/drm/vc4/vc4_dpi.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Comments

Sam Ravnborg Sept. 12, 2021, 7:42 p.m. UTC | #1
On Fri, Sep 10, 2021 at 03:09:40PM +0200, Maxime Ripard wrote:
> The new devm_drm_of_get_bridge removes most of the boilerplate we
> have to deal with. Let's switch to it.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/vc4/vc4_dpi.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
> index a90f2545baee..c180eb60bee8 100644
> --- a/drivers/gpu/drm/vc4/vc4_dpi.c
> +++ b/drivers/gpu/drm/vc4/vc4_dpi.c
> @@ -229,26 +229,19 @@ static const struct of_device_id vc4_dpi_dt_match[] = {
>  static int vc4_dpi_init_bridge(struct vc4_dpi *dpi)
>  {
>  	struct device *dev = &dpi->pdev->dev;
> -	struct drm_panel *panel;
>  	struct drm_bridge *bridge;
> -	int ret;
>  
> -	ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
> -					  &panel, &bridge);
> -	if (ret) {
> +	bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0, 0);
> +	if (IS_ERR(bridge)) {
>  		/* If nothing was connected in the DT, that's not an
>  		 * error.
>  		 */
> -		if (ret == -ENODEV)
> +		if (PTR_ERR(bridge) == -ENODEV)
>  			return 0;
>  		else
> -			return ret;
> +			return PTR_ERR(bridge);
>  	}
>  
> -	if (panel)
> -		bridge = drm_panel_bridge_add_typed(panel,
> -						    DRM_MODE_CONNECTOR_DPI);
> -
>  	return drm_bridge_attach(dpi->encoder, bridge, NULL, 0);
>  }
>  
> -- 
> 2.31.1
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
index a90f2545baee..c180eb60bee8 100644
--- a/drivers/gpu/drm/vc4/vc4_dpi.c
+++ b/drivers/gpu/drm/vc4/vc4_dpi.c
@@ -229,26 +229,19 @@  static const struct of_device_id vc4_dpi_dt_match[] = {
 static int vc4_dpi_init_bridge(struct vc4_dpi *dpi)
 {
 	struct device *dev = &dpi->pdev->dev;
-	struct drm_panel *panel;
 	struct drm_bridge *bridge;
-	int ret;
 
-	ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
-					  &panel, &bridge);
-	if (ret) {
+	bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0, 0);
+	if (IS_ERR(bridge)) {
 		/* If nothing was connected in the DT, that's not an
 		 * error.
 		 */
-		if (ret == -ENODEV)
+		if (PTR_ERR(bridge) == -ENODEV)
 			return 0;
 		else
-			return ret;
+			return PTR_ERR(bridge);
 	}
 
-	if (panel)
-		bridge = drm_panel_bridge_add_typed(panel,
-						    DRM_MODE_CONNECTOR_DPI);
-
 	return drm_bridge_attach(dpi->encoder, bridge, NULL, 0);
 }