From: Jani Nikula <jani.nikula@intel.com>
To: "Pandiyan, Dhinakaran" <dhinakaran.pandiyan@intel.com>
Cc: "intel-gfx@lists.freedesktop.org" <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH v1½ 03/13] drm/i915/dp: rename rate_to_index() to intel_dp_find_rate() and reuse
Date: Thu, 02 Feb 2017 10:44:34 +0200 [thread overview]
Message-ID: <87vastyob1.fsf@intel.com> (raw)
In-Reply-To: <1485986647.31742.13.camel@dk-H97M-D3H>
On Wed, 01 Feb 2017, "Pandiyan, Dhinakaran" <dhinakaran.pandiyan@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@intel.com>
>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> Signed-off-by: Jani Nikula <jani.nikula@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.
>
> -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;
>
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-02-02 8:45 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-26 19:44 [PATCH v1½ 00/13] drm/i915/dp: link rate and lane count refactoring Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 01/13] drm/i915/dp: use known correct array size in rate_to_index Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 02/13] drm/i915/dp: return errors from rate_to_index() Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 03/13] drm/i915/dp: rename rate_to_index() to intel_dp_find_rate() and reuse Jani Nikula
2017-02-01 21:46 ` Pandiyan, Dhinakaran
2017-02-02 8:44 ` Jani Nikula [this message]
2017-02-07 18:38 ` Pandiyan, Dhinakaran
2017-01-26 19:44 ` [PATCH v1½ 04/13] drm/i915/dp: cache source rates at init Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 05/13] drm/i915/dp: generate and cache sink rate array for all DP, not just eDP 1.4 Jani Nikula
2017-01-27 17:28 ` Ville Syrjälä
2017-01-27 19:52 ` Jani Nikula
2017-01-27 20:00 ` Ville Syrjälä
2017-01-28 10:16 ` [PATCH v2] " Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 06/13] drm/i915/dp: use the sink rates array for max sink rates Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 07/13] drm/i915/dp: cache common rates with " Jani Nikula
2017-02-01 22:08 ` Pandiyan, Dhinakaran
2017-02-02 8:38 ` Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 08/13] drm/i915/dp: do not limit rate seek when not needed Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 09/13] drm/i915/dp: don't call the link parameters sink parameters Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 10/13] drm/i915/dp: add functions for max common link rate and lane count Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 11/13] drm/i915/mst: use max link not sink " Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 12/13] drm/i915/dp: localize link rate index variable more Jani Nikula
2017-02-02 2:54 ` Manasi Navare
2017-02-02 8:42 ` Jani Nikula
2017-02-02 17:29 ` Manasi Navare
2017-02-03 14:11 ` Jani Nikula
2017-01-26 19:44 ` [PATCH v1½ 13/13] drm/i915/dp: use readb and writeb calls for single byte DPCD access Jani Nikula
2017-02-01 19:04 ` [PATCH v1½ 00/13] drm/i915/dp: link rate and lane count refactoring Pandiyan, Dhinakaran
2017-02-01 19:40 ` Manasi Navare
2017-02-02 19:01 ` Manasi Navare
2017-02-03 14:16 ` Jani Nikula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vastyob1.fsf@intel.com \
--to=jani.nikula@intel.com \
--cc=dhinakaran.pandiyan@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.