diff mbox series

[6/7] drm/msm/dp: Inline dp_link_parse_sink_count()

Message ID 20230829184735.2841739-7-swboyd@chromium.org (mailing list archive)
State New, archived
Headers show
Series drm/msm/dp: Simplify DPCD related code with helpers | expand

Commit Message

Stephen Boyd Aug. 29, 2023, 6:47 p.m. UTC
The function dp_link_parse_sink_count() is really just
drm_dp_read_sink_count(). It debug prints out the bit for content
protection (DP_SINK_CP_READY), but that is not useful beyond debug
because 'link->dp_link.sink_count' is overwritten to only contain the
sink_count in this same function. Just use drm_dp_read_sink_count() in
the one place this function is called to simplify.

Cc: Vinod Polimera <quic_vpolimer@quicinc.com>
Cc: Kuogee Hsieh <quic_khsieh@quicinc.com>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 drivers/gpu/drm/msm/dp/dp_link.c | 38 +++-----------------------------
 1 file changed, 3 insertions(+), 35 deletions(-)

Comments

Kuogee Hsieh Aug. 31, 2023, 8:29 p.m. UTC | #1
On 8/29/2023 11:47 AM, Stephen Boyd wrote:
> The function dp_link_parse_sink_count() is really just
> drm_dp_read_sink_count(). It debug prints out the bit for content
> protection (DP_SINK_CP_READY), but that is not useful beyond debug
> because 'link->dp_link.sink_count' is overwritten to only contain the
> sink_count in this same function. Just use drm_dp_read_sink_count() in
> the one place this function is called to simplify.
>
> Cc: Vinod Polimera <quic_vpolimer@quicinc.com>
> Cc: Kuogee Hsieh <quic_khsieh@quicinc.com>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Tested-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
Reviewed-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
> ---
>   drivers/gpu/drm/msm/dp/dp_link.c | 38 +++-----------------------------
>   1 file changed, 3 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/dp/dp_link.c b/drivers/gpu/drm/msm/dp/dp_link.c
> index 42427129acea..94a37914a47f 100644
> --- a/drivers/gpu/drm/msm/dp/dp_link.c
> +++ b/drivers/gpu/drm/msm/dp/dp_link.c
> @@ -712,49 +712,17 @@ static int dp_link_parse_request(struct dp_link_private *link)
>   	return ret;
>   }
>   
> -/**
> - * dp_link_parse_sink_count() - parses the sink count
> - * @dp_link: pointer to link module data
> - *
> - * Parses the DPCD to check if there is an update to the sink count
> - * (Byte 0x200), and whether all the sink devices connected have Content
> - * Protection enabled.
> - */
> -static int dp_link_parse_sink_count(struct dp_link *dp_link)
> -{
> -	ssize_t rlen;
> -	bool cp_ready;
> -
> -	struct dp_link_private *link = container_of(dp_link,
> -			struct dp_link_private, dp_link);
> -
> -	rlen = drm_dp_dpcd_readb(link->aux, DP_SINK_COUNT,
> -				 &link->dp_link.sink_count);
> -	if (rlen < 0) {
> -		DRM_ERROR("sink count read failed. rlen=%zd\n", rlen);
> -		return rlen;
> -	}
> -
> -	cp_ready = link->dp_link.sink_count & DP_SINK_CP_READY;
> -
> -	link->dp_link.sink_count =
> -		DP_GET_SINK_COUNT(link->dp_link.sink_count);
> -
> -	drm_dbg_dp(link->drm_dev, "sink_count = 0x%x, cp_ready = 0x%x\n",
> -				link->dp_link.sink_count, cp_ready);
> -	return 0;
> -}
> -
>   static int dp_link_parse_sink_status_field(struct dp_link_private *link)
>   {
> -	int len = 0;
> +	int len;
>   
>   	link->prev_sink_count = link->dp_link.sink_count;
> -	len = dp_link_parse_sink_count(&link->dp_link);
> +	len = drm_dp_read_sink_count(link->aux);
>   	if (len < 0) {
>   		DRM_ERROR("DP parse sink count failed\n");
>   		return len;
>   	}
> +	link->dp_link.sink_count = len;
>   
>   	len = drm_dp_dpcd_read_link_status(link->aux,
>   		link->link_status);
Dmitry Baryshkov Sept. 3, 2023, 10:39 p.m. UTC | #2
On 29/08/2023 21:47, Stephen Boyd wrote:
> The function dp_link_parse_sink_count() is really just
> drm_dp_read_sink_count(). It debug prints out the bit for content
> protection (DP_SINK_CP_READY), but that is not useful beyond debug
> because 'link->dp_link.sink_count' is overwritten to only contain the
> sink_count in this same function. Just use drm_dp_read_sink_count() in
> the one place this function is called to simplify.
> 
> Cc: Vinod Polimera <quic_vpolimer@quicinc.com>
> Cc: Kuogee Hsieh <quic_khsieh@quicinc.com>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> ---
>   drivers/gpu/drm/msm/dp/dp_link.c | 38 +++-----------------------------
>   1 file changed, 3 insertions(+), 35 deletions(-)

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/dp/dp_link.c b/drivers/gpu/drm/msm/dp/dp_link.c
index 42427129acea..94a37914a47f 100644
--- a/drivers/gpu/drm/msm/dp/dp_link.c
+++ b/drivers/gpu/drm/msm/dp/dp_link.c
@@ -712,49 +712,17 @@  static int dp_link_parse_request(struct dp_link_private *link)
 	return ret;
 }
 
-/**
- * dp_link_parse_sink_count() - parses the sink count
- * @dp_link: pointer to link module data
- *
- * Parses the DPCD to check if there is an update to the sink count
- * (Byte 0x200), and whether all the sink devices connected have Content
- * Protection enabled.
- */
-static int dp_link_parse_sink_count(struct dp_link *dp_link)
-{
-	ssize_t rlen;
-	bool cp_ready;
-
-	struct dp_link_private *link = container_of(dp_link,
-			struct dp_link_private, dp_link);
-
-	rlen = drm_dp_dpcd_readb(link->aux, DP_SINK_COUNT,
-				 &link->dp_link.sink_count);
-	if (rlen < 0) {
-		DRM_ERROR("sink count read failed. rlen=%zd\n", rlen);
-		return rlen;
-	}
-
-	cp_ready = link->dp_link.sink_count & DP_SINK_CP_READY;
-
-	link->dp_link.sink_count =
-		DP_GET_SINK_COUNT(link->dp_link.sink_count);
-
-	drm_dbg_dp(link->drm_dev, "sink_count = 0x%x, cp_ready = 0x%x\n",
-				link->dp_link.sink_count, cp_ready);
-	return 0;
-}
-
 static int dp_link_parse_sink_status_field(struct dp_link_private *link)
 {
-	int len = 0;
+	int len;
 
 	link->prev_sink_count = link->dp_link.sink_count;
-	len = dp_link_parse_sink_count(&link->dp_link);
+	len = drm_dp_read_sink_count(link->aux);
 	if (len < 0) {
 		DRM_ERROR("DP parse sink count failed\n");
 		return len;
 	}
+	link->dp_link.sink_count = len;
 
 	len = drm_dp_dpcd_read_link_status(link->aux,
 		link->link_status);