[PATCH 032/108] drm/i915/dp: Simplify querying of forced link parameters

Imre Deak
2026-04-28T12:53:41Z

Simplify querying the forced link rate and lane count by
performing the zero checks inside the helpers, allowing callers
to use the returned values directly.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
drivers/gpu/drm/i915/display/intel_dp.c | 8 ++++----
drivers/gpu/drm/i915/display/intel_dp_link_caps.c | 9 ++++++++-
2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 0aab37dcce97a..52d843b05c38c 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -361,7 +361,7 @@ int intel_dp_max_lane_count(struct intel_dp *intel_dp)

intel_dp_link_caps_get_forced_params(link_caps, &forced_params);

- if (intel_dp->link.force_lane_count)
+ if (forced_params.lane_count)
lane_count = forced_params.lane_count;
else
lane_count = intel_dp->link.max_lane_count;
@@ -383,7 +383,7 @@ static int intel_dp_min_lane_count(struct intel_dp *intel_dp)

intel_dp_link_caps_get_forced_params(intel_dp->link.caps, &forced_params);

- if (intel_dp->link.force_lane_count)
+ if (forced_params.lane_count)
return forced_params.lane_count;

return 1;
@@ -1668,7 +1668,7 @@ intel_dp_max_link_rate(struct intel_dp *intel_dp)

intel_dp_link_caps_get_forced_params(link_caps, &forced_params);

- if (intel_dp->link.force_rate)
+ if (forced_params.rate)
return forced_params.rate;

return intel_dp->link.max_rate;
@@ -1681,7 +1681,7 @@ intel_dp_min_link_rate(struct intel_dp *intel_dp)

intel_dp_link_caps_get_forced_params(intel_dp->link.caps, &forced_params);

- if (intel_dp->link.force_rate)
+ if (forced_params.rate)
return forced_params.rate;

return intel_dp_common_rate(intel_dp, 0);
diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
index 0a2db7d65e20d..1892fc0ff46ef 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -43,13 +43,20 @@ int intel_dp_max_common_rate(struct intel_dp *intel_dp)

static int forced_lane_count(struct intel_dp *intel_dp)
{
+ if (!intel_dp->link.force_lane_count)
+ return 0;
+
return clamp(intel_dp->link.force_lane_count, 1, intel_dp_max_common_lane_count(intel_dp));
}

static int forced_link_rate(struct intel_dp *intel_dp)
{
- int len = intel_dp_common_len_rate_limit(intel_dp, intel_dp->link.force_rate);
+ int len;

+ if (!intel_dp->link.force_rate)
+ return 0;
+
+ len = intel_dp_common_len_rate_limit(intel_dp, intel_dp->link.force_rate);
if (len == 0)
return intel_dp_common_rate(intel_dp, 0);

--
2.49.1