[PATCH 068/108] drm/i915/dp_link_caps: Factor out a helper to look up a config table rate

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

Factor out a helper looking up a supported link rate from a config
table, used by a follow-up change.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
.../gpu/drm/i915/display/intel_dp_link_caps.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

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 81c36e3326bb9..d5456c24714f4 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -139,6 +139,14 @@ struct intel_dp_link_caps {
struct intel_dp_link_config max_limits;
};

+static int lookup_rate(const struct intel_dp_link_caps_config_table *table, int index)
+{
+ if (WARN_ON(index < 0 || index >= table->num_rates))
+ return 162000;
+
+ return table->rates[index];
+}
+
/* Get length of common rates array potentially limited by max_rate. */
static int intel_dp_link_caps_common_len_rate_limit(struct intel_dp_link_caps *link_caps,
int max_rate)
@@ -162,14 +170,7 @@ static int intel_dp_link_caps_common_len_rate_limit(struct intel_dp_link_caps *l
*/
int intel_dp_link_caps_common_rate(struct intel_dp_link_caps *link_caps, int index)
{
- struct intel_dp *intel_dp = link_caps->dp;
- struct intel_display *display = to_intel_display(intel_dp);
-
- if (drm_WARN_ON(display->drm,
- index < 0 || index >= link_caps->config_table.num_rates))
- return 162000;
-
- return link_caps->config_table.rates[index];
+ return lookup_rate(&link_caps->config_table, index);
}

/**
--
2.49.1