[Intel-gfx] [PATCH v1½ 03/13] drm/i915/dp: rename rate_to_index() to intel_dp_find_rate() and reuse
Pandiyan, Dhinakaran
dhinakaran.pandiyan at intel.com
Tue Feb 7 18:38:57 UTC 2017
On Thu, 2017-02-02 at 10:44 +0200, Jani Nikula wrote:
> On Wed, 01 Feb 2017, "Pandiyan, Dhinakaran" <dhinakaran.pandiyan at intel.com> wrote:
> > On Thu, 2017-01-26 at 21:44 +0200, Jani Nikula wrote:
> >> 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.
> >>
> >> Cc: Manasi Navare <manasi.d.navare at intel.com>
> >> Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
> >> Signed-off-by: Jani Nikula <jani.nikula at intel.com>
> >> ---
> >> drivers/gpu/drm/i915/intel_dp.c | 33 ++++++++++++++-------------------
> >> 1 file changed, 14 insertions(+), 19 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> >> index 1d66737a3a0f..f3068ff670a1 100644
> >> --- a/drivers/gpu/drm/i915/intel_dp.c
> >> +++ b/drivers/gpu/drm/i915/intel_dp.c
> >> @@ -266,6 +266,17 @@ static int intersect_rates(const int *source_rates, int source_len,
> >> return k;
> >> }
> >>
> >> +static int intel_dp_find_rate(const int *rates, int len, int rate)
> >
> > I wonder if the function name can be more intuitive. The argument is
> > rate and the function name indicates it also returns rate. I can't tell
> > what the function does by it's name. Feel free to ignore this comment as
> > I might be missing some context.
>
> Naming is hard. intel_dp_rate_index?
>
> BR,
> Jani.
>
>
That does sounds good.
Reviewed-by: Dhinakaran Pandiyan <dhinakaran.pandiyan at intel.com>
> >
> > -DK
> >
> >> +{
> >> + 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 +295,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_find_rate(common_rates, common_len, link_rate);
> >> }
> >>
> >> int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
> >> @@ -1542,17 +1548,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)
> >> {
> >> @@ -1568,8 +1563,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_find_rate(intel_dp->sink_rates,
> >> + intel_dp->num_sink_rates, rate);
> >>
> >> if (WARN_ON(i < 0))
> >> i = 0;
> >
>
More information about the Intel-gfx
mailing list