From: Jani Nikula Date: Tue, 28 Mar 2017 14:59:03 +0000 (+0300) Subject: drm/i915/dp: rename rate_to_index() to intel_dp_rate_index() and reuse X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=8001b7541aa7a2f0adc4941bdebf44ea969e7ed5;p=openwrt%2Fstaging%2Fblogic.git drm/i915/dp: rename rate_to_index() to intel_dp_rate_index() and reuse Rename the function, move it at the top, and reuse in intel_dp_link_rate_index(). If there was a reason in the past to use reverse search order here, there isn't now. The names may be slightly confusing now, but intel_dp_link_rate_index() will go away in follow-up patches. v2: Use name intel_dp_rate_index (Dhinakaran) Cc: Manasi Navare Cc: Ville Syrjälä Reviewed-by: Manasi Navare Signed-off-by: Jani Nikula Link: http://patchwork.freedesktop.org/patch/msgid/c7b6197aaa12e368a0d024dc142fa574fd0443a7.1490712890.git.jani.nikula@intel.com --- diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 0e200a37b75b..9fc066dda4e0 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -266,6 +266,18 @@ static int intersect_rates(const int *source_rates, int source_len, return k; } +/* return index of rate in rates array, or -1 if not found */ +static int intel_dp_rate_index(const int *rates, int len, int rate) +{ + int i; + + for (i = 0; i < len; i++) + if (rate == rates[i]) + return i; + + return -1; +} + static int intel_dp_common_rates(struct intel_dp *intel_dp, int *common_rates) { @@ -284,15 +296,10 @@ static int intel_dp_link_rate_index(struct intel_dp *intel_dp, int *common_rates, int link_rate) { int common_len; - int index; common_len = intel_dp_common_rates(intel_dp, common_rates); - for (index = 0; index < common_len; index++) { - if (link_rate == common_rates[common_len - index - 1]) - return common_len - index - 1; - } - return -1; + return intel_dp_rate_index(common_rates, common_len, link_rate); } int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp, @@ -1538,17 +1545,6 @@ bool intel_dp_read_desc(struct intel_dp *intel_dp) return true; } -static int rate_to_index(const int *rates, int len, int rate) -{ - int i; - - for (i = 0; i < len; i++) - if (rate == rates[i]) - return i; - - return -1; -} - int intel_dp_max_link_rate(struct intel_dp *intel_dp) { @@ -1564,8 +1560,8 @@ intel_dp_max_link_rate(struct intel_dp *intel_dp) int intel_dp_rate_select(struct intel_dp *intel_dp, int rate) { - int i = rate_to_index(intel_dp->sink_rates, intel_dp->num_sink_rates, - rate); + int i = intel_dp_rate_index(intel_dp->sink_rates, + intel_dp->num_sink_rates, rate); if (WARN_ON(i < 0)) i = 0;