[PATCH 055/108] drm/i915/dp_link_caps: Pass link_caps to static functions

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

Pass the link_caps pointer to static functions in intel_dp_link_caps.c,
as it holds the state with the relevant information.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
.../gpu/drm/i915/display/intel_dp_link_caps.c | 41 +++++++++----------
1 file changed, 20 insertions(+), 21 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 6d0ce343e7b04..1f6e391838894 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -161,10 +161,8 @@ int intel_dp_link_caps_max_common_lane_count(struct intel_dp_link_caps *link_cap
return link_caps->max_lane_count;
}

-static int forced_lane_count(struct intel_dp *intel_dp)
+static int forced_lane_count(struct intel_dp_link_caps *link_caps)
{
- struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
-
if (!link_caps->forced_params.lane_count)
return 0;

@@ -172,9 +170,9 @@ static int forced_lane_count(struct intel_dp *intel_dp)
1, intel_dp_link_caps_max_common_lane_count(link_caps));
}

-static int forced_link_rate(struct intel_dp *intel_dp)
+static int forced_link_rate(struct intel_dp_link_caps *link_caps)
{
- struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
+ struct intel_dp *intel_dp = link_caps->dp;
int len;

if (!link_caps->forced_params.rate)
@@ -190,14 +188,14 @@ static int forced_link_rate(struct intel_dp *intel_dp)
void intel_dp_link_caps_get_forced_params(struct intel_dp_link_caps *link_caps,
struct intel_dp_link_config *forced_params)
{
- forced_params->rate = forced_link_rate(link_caps->dp);
- forced_params->lane_count = forced_lane_count(link_caps->dp);
+ forced_params->rate = forced_link_rate(link_caps);
+ forced_params->lane_count = forced_lane_count(link_caps);
}

-static int intel_dp_link_config_rate(struct intel_dp *intel_dp,
+static int intel_dp_link_config_rate(struct intel_dp_link_caps *link_caps,
const struct intel_dp_link_config_entry *lc)
{
- return intel_dp_common_rate(intel_dp, lc->link_rate_idx);
+ return intel_dp_common_rate(link_caps->dp, lc->link_rate_idx);
}

static int intel_dp_link_config_lane_count(const struct intel_dp_link_config_entry *lc)
@@ -210,9 +208,7 @@ to_intel_dp_link_config(struct intel_dp_link_caps *link_caps,
const struct intel_dp_link_config_entry *lc,
struct intel_dp_link_config *config)
{
- struct intel_dp *intel_dp = link_caps->dp;
-
- config->rate = intel_dp_link_config_rate(intel_dp, lc);
+ config->rate = intel_dp_link_config_rate(link_caps, lc);
config->lane_count = intel_dp_link_config_lane_count(lc);
}

@@ -354,26 +350,28 @@ void intel_dp_link_caps_reset_max_limits(struct intel_dp_link_caps *link_caps)
reset_max_link_limits_no_update(link_caps);
}

-static int intel_dp_link_config_bw(struct intel_dp *intel_dp,
+static int intel_dp_link_config_bw(struct intel_dp_link_caps *link_caps,
const struct intel_dp_link_config_entry *lc)
{
- return drm_dp_max_dprx_data_rate(intel_dp_link_config_rate(intel_dp, lc),
+ return drm_dp_max_dprx_data_rate(intel_dp_link_config_rate(link_caps, lc),
intel_dp_link_config_lane_count(lc));
}

static int link_config_cmp_by_bw(const void *a, const void *b, const void *p)
{
struct intel_dp *intel_dp = (struct intel_dp *)p; /* remove const */
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
+
const struct intel_dp_link_config_entry *lc_a = a;
const struct intel_dp_link_config_entry *lc_b = b;
- int bw_a = intel_dp_link_config_bw(intel_dp, lc_a);
- int bw_b = intel_dp_link_config_bw(intel_dp, lc_b);
+ int bw_a = intel_dp_link_config_bw(link_caps, lc_a);
+ int bw_b = intel_dp_link_config_bw(link_caps, lc_b);

if (bw_a != bw_b)
return bw_a - bw_b;

- return intel_dp_link_config_rate(intel_dp, lc_a) -
- intel_dp_link_config_rate(intel_dp, lc_b);
+ return intel_dp_link_config_rate(link_caps, lc_a) -
+ intel_dp_link_config_rate(link_caps, lc_b);
}

static bool current_common_caps_match(struct intel_dp_link_caps *link_caps,
@@ -483,7 +481,7 @@ void intel_dp_link_config_get(struct intel_dp *intel_dp, int idx, int *link_rate

lc = &link_caps->configs[idx];

- *link_rate = intel_dp_link_config_rate(intel_dp, lc);
+ *link_rate = intel_dp_link_config_rate(link_caps, lc);
*lane_count = intel_dp_link_config_lane_count(lc);
}

@@ -564,8 +562,9 @@ static int i915_dp_force_link_rate_show(struct seq_file *m, void *data)
return 0;
}

-static int parse_link_rate(struct intel_dp *intel_dp, const char __user *ubuf, size_t len)
+static int parse_link_rate(struct intel_dp_link_caps *link_caps, const char __user *ubuf, size_t len)
{
+ struct intel_dp *intel_dp = link_caps->dp;
char *kbuf;
const char *p;
int rate;
@@ -608,7 +607,7 @@ static ssize_t i915_dp_force_link_rate_write(struct file *file,
int rate;
int err;

- rate = parse_link_rate(intel_dp, ubuf, len);
+ rate = parse_link_rate(link_caps, ubuf, len);
if (rate < 0)
return rate;

--
2.49.1