Commit b5c72b20 authored by Jani Nikula's avatar Jani Nikula

drm/i915/dp: return errors from rate_to_index()

We shouldn't silently use the first element if we can't find the rate
we're looking for. Make rate_to_index() more generally useful, and
fallback to the first element in the caller, with a big warning.

Cc: Manasi Navare <manasi.d.navare@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: default avatarManasi Navare <manasi.d.navare@intel.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/8a6e83b7bf35da0cbbc703ae157944107ff145be.1490712890.git.jani.nikula@intel.com
parent 31941024
...@@ -1544,9 +1544,9 @@ static int rate_to_index(const int *rates, int len, int rate) ...@@ -1544,9 +1544,9 @@ static int rate_to_index(const int *rates, int len, int rate)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
if (rate == rates[i]) if (rate == rates[i])
break;
return i; return i;
return -1;
} }
int int
...@@ -1564,8 +1564,13 @@ intel_dp_max_link_rate(struct intel_dp *intel_dp) ...@@ -1564,8 +1564,13 @@ intel_dp_max_link_rate(struct intel_dp *intel_dp)
int intel_dp_rate_select(struct intel_dp *intel_dp, int rate) int intel_dp_rate_select(struct intel_dp *intel_dp, int rate)
{ {
return rate_to_index(intel_dp->sink_rates, intel_dp->num_sink_rates, int i = rate_to_index(intel_dp->sink_rates, intel_dp->num_sink_rates,
rate); rate);
if (WARN_ON(i < 0))
i = 0;
return i;
} }
void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock, void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment