diff mbox series

drm/dp_mst: fix drm_dp_dpcd_read return value checks

Message ID 20220210154012.118472-1-contact@emersion.fr (mailing list archive)
State New, archived
Headers show
Series drm/dp_mst: fix drm_dp_dpcd_read return value checks | expand

Commit Message

Simon Ser Feb. 10, 2022, 3:40 p.m. UTC
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 <contact@emersion.fr>
Fixes: cb897542c6d2 ("drm/dp_mst: Fix W=1 warnings")
Cc: Lyude Paul <lyude@redhat.com>
Cc: Benjamin Gaignard <benjamin.gaignard@st.com>
---
 drivers/gpu/drm/dp/drm_dp_mst_topology.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)


base-commit: ded74cafeea9311c1eaf6fccce963de2516145f7

Comments

Jani Nikula Feb. 10, 2022, 4:33 p.m. UTC | #1
On Thu, 10 Feb 2022, Simon Ser <contact@emersion.fr> wrote:
> 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.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

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.

>
> Signed-off-by: Simon Ser <contact@emersion.fr>
> Fixes: cb897542c6d2 ("drm/dp_mst: Fix W=1 warnings")
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: Benjamin Gaignard <benjamin.gaignard@st.com>
> ---
>  drivers/gpu/drm/dp/drm_dp_mst_topology.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/dp/drm_dp_mst_topology.c b/drivers/gpu/drm/dp/drm_dp_mst_topology.c
> index 11300b53d24f..f5998b7cf602 100644
> --- a/drivers/gpu/drm/dp/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/dp/drm_dp_mst_topology.c
> @@ -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
diff mbox series

Patch

diff --git a/drivers/gpu/drm/dp/drm_dp_mst_topology.c b/drivers/gpu/drm/dp/drm_dp_mst_topology.c
index 11300b53d24f..f5998b7cf602 100644
--- a/drivers/gpu/drm/dp/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/dp/drm_dp_mst_topology.c
@@ -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;
 		}