drm/dp_mst: fix drm_dp_dpcd_read return value checks
Subsystems (2)
PATCH 1/1 drm/dp_mst: fix drm_dp_dpcd_read return value checks
drm_dp_dpcd_read returns the number of bytes read. The previous code would print garbage on DPCD error, and would exit with on error on success.
Signed-off-by Simon Ser <[email protected]>
Fixes cb897542c6d2 ("drm/dp_mst: Fix W=1 warnings")
Cc Lyude Paul <[email protected]>
Cc Benjamin Gaignard <[email protected]>
--- drivers/gpu/drm/dp/drm_dp_mst_topology.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/dp/drm_dp_mst_topology.c +4 -4
@@ -4912,21 +4912,21 @@ void drm_dp_mst_dump_topology(struct seq_file *m,int ret; ret =drm_dp_dpcd_read (mgr->aux,DP_DPCD_REV , buf,DP_RECEIVER_CAP_SIZE ); -if (ret) { +if (ret !=DP_RECEIVER_CAP_SIZE ) {seq_printf (m,"dpcd read failed\n" ); goto out; }seq_printf (m,"dpcd: %*ph\n" ,DP_RECEIVER_CAP_SIZE , buf); ret =drm_dp_dpcd_read (mgr->aux,DP_FAUX_CAP , buf,2 ); -if (ret) { +if (ret !=2 ) {seq_printf (m,"faux/mst read failed\n" ); goto out; }seq_printf (m,"faux/mst: %*ph\n" ,2 , buf); ret =drm_dp_dpcd_read (mgr->aux,DP_MSTM_CTRL , buf,1 ); -if (ret) { +if (ret !=1 ) {seq_printf (m,"mst ctrl read failed\n" ); goto out; }
@@ -4934,7 +4934,7 @@ void drm_dp_mst_dump_topology(struct seq_file *m,/* dump the standard OUI branch header */ ret =drm_dp_dpcd_read (mgr->aux,DP_BRANCH_OUI , buf,DP_BRANCH_OUI_HEADER_SIZE ); -if (ret) { +if (ret !=DP_BRANCH_OUI_HEADER_SIZE ) {seq_printf (m,"branch oui read failed\n" ); goto out; }
base-commit: ded74cafeea9311c1eaf6fccce963de2516145f7
Signature · 1 line
2.35.1
Quoted 3 lines · Simon Ser
drm_dp_dpcd_readreturns the number of bytes read. The previous code would print garbage on DPCD error, and would exit with on error on success.
Reviewed-by Jani Nikula <[email protected]>
I do wish we'd just made dpcd access return 0 when the number of bytes transferred matches the request, and an error otherwise.
BR,
Jani.
Quoted 49 lines
Signed-off-by Simon Ser <[email protected]>Fixes cb897542c6d2 ("drm/dp_mst: Fix W=1 warnings")Cc Lyude Paul <[email protected]>Cc Benjamin Gaignard <[email protected]>--- drivers/gpu/drm/dp/drm_dp_mst_topology.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/dp/drm_dp_mst_topology.c +4
-4@@ -4912,21 +4912,21 @@ void drm_dp_mst_dump_topology(struct seq_file *m,int ret; ret =drm_dp_dpcd_read (mgr->aux,DP_DPCD_REV , buf,DP_RECEIVER_CAP_SIZE ); -if (ret) { +if (ret !=DP_RECEIVER_CAP_SIZE ) {seq_printf (m,"dpcd read failed\n" ); goto out; }seq_printf (m,"dpcd: %*ph\n" ,DP_RECEIVER_CAP_SIZE , buf); ret =drm_dp_dpcd_read (mgr->aux,DP_FAUX_CAP , buf,2 ); -if (ret) { +if (ret !=2 ) {seq_printf (m,"faux/mst read failed\n" ); goto out; }seq_printf (m,"faux/mst: %*ph\n" ,2 , buf); ret =drm_dp_dpcd_read (mgr->aux,DP_MSTM_CTRL , buf,1 ); -if (ret) { +if (ret !=1 ) {seq_printf (m,"mst ctrl read failed\n" ); goto out; }@@ -4934,7 +4934,7 @@ void drm_dp_mst_dump_topology(struct seq_file *m,/* dump the standard OUI branch header */ ret =drm_dp_dpcd_read (mgr->aux,DP_BRANCH_OUI , buf,DP_BRANCH_OUI_HEADER_SIZE ); -if (ret) { +if (ret !=DP_BRANCH_OUI_HEADER_SIZE ) {seq_printf (m,"branch oui read failed\n" ); goto out; }base-commit:
ded74cafeea9311c1eaf6fccce963de2516145f7
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center