Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5644a5e authored by Chen-Yu Tsai's avatar Chen-Yu Tsai Committed by Maxime Ripard
Browse files

drm/sun4i: Clear encoder->bridge if a bridge is not found



The KMS helpers (drm_atomic_helper_check_modeset/mode_fixup) pass
encoder->bridge directly to drm_bridge_mode_fixup, which expects a
valid pointer, or NULL (in which case it just returns).

Clear encoder->bridge if a bridge is not found, instead of keeping
the ERR_PTR value.

Since other drm_bridge functions also follow this pattern of checking
for a non-NULL pointer, we can drop the ifs around the calls and just
pass the pointer directly.

Fixes: 894f5a9f ("drm/sun4i: Add bridge support")
Signed-off-by: default avatarChen-Yu Tsai <wens@csie.org>
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
parent 4b309502
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ static void sun4i_rgb_encoder_enable(struct drm_encoder *encoder)
		drm_panel_enable(tcon->panel);
	}

	if (!IS_ERR(encoder->bridge))
	/* encoder->bridge can be NULL; drm_bridge_enable checks for it */
	drm_bridge_enable(encoder->bridge);

	sun4i_tcon_channel_enable(tcon, 0);
@@ -172,7 +172,7 @@ static void sun4i_rgb_encoder_disable(struct drm_encoder *encoder)

	sun4i_tcon_channel_disable(tcon, 0);

	if (!IS_ERR(encoder->bridge))
	/* encoder->bridge can be NULL; drm_bridge_disable checks for it */
	drm_bridge_disable(encoder->bridge);

	if (!IS_ERR(tcon->panel)) {
@@ -278,6 +278,8 @@ int sun4i_rgb_init(struct drm_device *drm)
			dev_err(drm->dev, "Couldn't attach our bridge\n");
			goto err_cleanup_connector;
		}
	} else {
		encoder->bridge = NULL;
	}

	return 0;