Skip to contentSkip to conversation

drm/mediatek: Add return value check when reading DPCD

PATCH New Liankun Yang 1 participant 1 message Jan 3, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 drm/mediatek: Add return value check when reading DPCD

Returns the number of bytes transferred (1) on success. Check the return value to confirm that AUX communication is successful.

Fixes f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")

---
Changes in V4:
- Fix IF judgement condition.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Changes in V3:
- Using drm_dp_read_sink_count() to improve patch. Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Changes in V2:
- Modify Fixes in Commit Message.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

---
 drivers/gpu/drm/mediatek/mtk_dp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +2 -3
index 36713c176cfc..b8e4e9a6eb78 100644
@@ -2100,7 +2100,6 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
 	struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge);
 	enum drm_connector_status ret = connector_status_disconnected;
 	bool enabled = mtk_dp->enabled;
-	u8 sink_count = 0;
 
 	if (!mtk_dp->train_info.cable_plugged_in)
 		return ret;
@@ -2115,8 +2114,8 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
 	 * function, we just need to check the HPD connection to check
 	 * whether we connect to a sink device.
 	 */
-	drm_dp_dpcd_readb(&mtk_dp->aux, DP_SINK_COUNT, &sink_count);
-	if (DP_GET_SINK_COUNT(sink_count))
+
+	if (drm_dp_read_sink_count(&mtk_dp->aux) > 0)
 		ret = connector_status_connected;
 
 	if (!enabled)
Signature · 1 line
2.45.2