diff mbox series

[2/7] drm/msm/dp: Use drm_dp_read_sink_count() helper

Message ID 20230829184735.2841739-3-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
Use the common function drm_dp_read_sink_count() instead of open-coding
it. This shrinks the kernel text a tiny bit.

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_panel.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

Comments

Kuogee Hsieh Aug. 31, 2023, 8:27 p.m. UTC | #1
On 8/29/2023 11:47 AM, Stephen Boyd wrote:
> Use the common function drm_dp_read_sink_count() instead of open-coding
> it. This shrinks the kernel text a tiny bit.
>
> 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_panel.c | 19 +++++++------------
>   1 file changed, 7 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/dp/dp_panel.c b/drivers/gpu/drm/msm/dp/dp_panel.c
> index 09d4f6c38ef8..a0523b18b9e9 100644
> --- a/drivers/gpu/drm/msm/dp/dp_panel.c
> +++ b/drivers/gpu/drm/msm/dp/dp_panel.c
> @@ -147,8 +147,8 @@ static int dp_panel_update_modes(struct drm_connector *connector,
>   int dp_panel_read_sink_caps(struct dp_panel *dp_panel,
>   	struct drm_connector *connector)
>   {
> -	int rc = 0, bw_code;
> -	int rlen, count;
> +	int rc, bw_code;
> +	int count;
>   	struct dp_panel_private *panel;
>   
>   	if (!dp_panel || !connector) {
> @@ -174,16 +174,11 @@ int dp_panel_read_sink_caps(struct dp_panel *dp_panel,
>   	}
>   
>   	if (dp_panel->dfp_present) {
> -		rlen = drm_dp_dpcd_read(panel->aux, DP_SINK_COUNT,
> -				&count, 1);
> -		if (rlen == 1) {
> -			count = DP_GET_SINK_COUNT(count);
> -			if (!count) {
> -				DRM_ERROR("no downstream ports connected\n");
> -				panel->link->sink_count = 0;
> -				rc = -ENOTCONN;
> -				goto end;
> -			}
> +		count = drm_dp_read_sink_count(panel->aux);
> +		if (!count) {
> +			DRM_ERROR("no downstream ports connected\n");
> +			panel->link->sink_count = 0;
> +			return -ENOTCONN;
>   		}
>   	}
>
Dmitry Baryshkov Sept. 3, 2023, 10:37 p.m. UTC | #2
On 29/08/2023 21:47, Stephen Boyd wrote:
> Use the common function drm_dp_read_sink_count() instead of open-coding
> it. This shrinks the kernel text a tiny bit.
> 
> 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_panel.c | 19 +++++++------------
>   1 file changed, 7 insertions(+), 12 deletions(-)

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

Patch

diff --git a/drivers/gpu/drm/msm/dp/dp_panel.c b/drivers/gpu/drm/msm/dp/dp_panel.c
index 09d4f6c38ef8..a0523b18b9e9 100644
--- a/drivers/gpu/drm/msm/dp/dp_panel.c
+++ b/drivers/gpu/drm/msm/dp/dp_panel.c
@@ -147,8 +147,8 @@  static int dp_panel_update_modes(struct drm_connector *connector,
 int dp_panel_read_sink_caps(struct dp_panel *dp_panel,
 	struct drm_connector *connector)
 {
-	int rc = 0, bw_code;
-	int rlen, count;
+	int rc, bw_code;
+	int count;
 	struct dp_panel_private *panel;
 
 	if (!dp_panel || !connector) {
@@ -174,16 +174,11 @@  int dp_panel_read_sink_caps(struct dp_panel *dp_panel,
 	}
 
 	if (dp_panel->dfp_present) {
-		rlen = drm_dp_dpcd_read(panel->aux, DP_SINK_COUNT,
-				&count, 1);
-		if (rlen == 1) {
-			count = DP_GET_SINK_COUNT(count);
-			if (!count) {
-				DRM_ERROR("no downstream ports connected\n");
-				panel->link->sink_count = 0;
-				rc = -ENOTCONN;
-				goto end;
-			}
+		count = drm_dp_read_sink_count(panel->aux);
+		if (!count) {
+			DRM_ERROR("no downstream ports connected\n");
+			panel->link->sink_count = 0;
+			return -ENOTCONN;
 		}
 	}