All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Gustavo Sousa <gustavo.sousa@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915/aux: clean up aux name initialization
Date: Thu, 13 Apr 2023 15:42:27 +0300	[thread overview]
Message-ID: <875ya0ar7w.fsf@intel.com> (raw)
In-Reply-To: <168138851791.4412.18050063545378346839@gjsousa-mobl2>

On Thu, 13 Apr 2023, Gustavo Sousa <gustavo.sousa@intel.com> wrote:
> Quoting Jani Nikula (2023-04-13 09:11:13)
>> Split intel_dp_aux_name() to a separate function to declutter
>> intel_dp_aux_init(), and only have the if ladder to pick the one
>> character instead of duplicating the whole kasprintf() call.
>> 
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>  drivers/gpu/drm/i915/display/intel_dp_aux.c | 32 ++++++++++++---------
>>  1 file changed, 18 insertions(+), 14 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux.c b/drivers/gpu/drm/i915/display/intel_dp_aux.c
>> index 705915d50565..2fee5b79c0b7 100644
>> --- a/drivers/gpu/drm/i915/display/intel_dp_aux.c
>> +++ b/drivers/gpu/drm/i915/display/intel_dp_aux.c
>> @@ -718,12 +718,27 @@ void intel_dp_aux_fini(struct intel_dp *intel_dp)
>>         kfree(intel_dp->aux.name);
>>  }
>>  
>> -void intel_dp_aux_init(struct intel_dp *intel_dp)
>> +static const char *intel_dp_aux_name(struct intel_dp *intel_dp)
>>  {
>> -  struct drm_i915_private *dev_priv = dp_to_i915(intel_dp);
>> +  struct drm_i915_private *i915 = dp_to_i915(intel_dp);
>>         struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
>>         struct intel_encoder *encoder = &dig_port->base;
>>         enum aux_ch aux_ch = dig_port->aux_ch;
>> +  char aux_char;
>> +
>> +  if (DISPLAY_VER(i915) >= 13 && aux_ch >= AUX_CH_D_XELPD)
>> +          aux_char = aux_ch_name(aux_ch - AUX_CH_D_XELPD + AUX_CH_D);
>> +  else if (DISPLAY_VER(i915) >= 12 && aux_ch >= AUX_CH_USBC1)
>> +          aux_char = aux_ch - AUX_CH_USBC1 + '1';
>> +  else
>> +          aux_char = aux_ch_name(aux_ch);
>> +
>> +  return kasprintf(GFP_KERNEL, "AUX %c/%s", aux_char, encoder->base.name);
>
> Is the drop of " USBC" in the format string for the second case in the ladder
> intentional?

No. Either I goofed it up originally or during a rebase. :/

Thanks for spotting it,
Jani.

>
>> +}
>> +
>> +void intel_dp_aux_init(struct intel_dp *intel_dp)
>> +{
>> +  struct drm_i915_private *dev_priv = dp_to_i915(intel_dp);
>>  
>>         if (DISPLAY_VER(dev_priv) >= 14) {
>>                 intel_dp->aux_ch_ctl_reg = xelpdp_aux_ctl_reg;
>> @@ -760,18 +775,7 @@ void intel_dp_aux_init(struct intel_dp *intel_dp)
>>         drm_dp_aux_init(&intel_dp->aux);
>>  
>>         /* Failure to allocate our preferred name is not critical */
>> -  if (DISPLAY_VER(dev_priv) >= 13 && aux_ch >= AUX_CH_D_XELPD)
>> -          intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX %c/%s",
>> -                                         aux_ch_name(aux_ch - AUX_CH_D_XELPD + AUX_CH_D),
>> -                                         encoder->base.name);
>> -  else if (DISPLAY_VER(dev_priv) >= 12 && aux_ch >= AUX_CH_USBC1)
>> -          intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX USBC%c/%s",
>> -                                         aux_ch - AUX_CH_USBC1 + '1',
>> -                                         encoder->base.name);
>> -  else
>> -          intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX %c/%s",
>> -                                         aux_ch_name(aux_ch),
>> -                                         encoder->base.name);
>> +  intel_dp->aux.name = intel_dp_aux_name(intel_dp);
>>  
>>         intel_dp->aux.transfer = intel_dp_aux_transfer;
>>         cpu_latency_qos_add_request(&intel_dp->pm_qos, PM_QOS_DEFAULT_VALUE);
>> -- 
>> 2.39.2
>>

-- 
Jani Nikula, Intel Open Source Graphics Center

  reply	other threads:[~2023-04-13 12:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13 12:11 [Intel-gfx] [PATCH] drm/i915/aux: clean up aux name initialization Jani Nikula
2023-04-13 12:21 ` Gustavo Sousa
2023-04-13 12:42   ` Jani Nikula [this message]
2023-04-13 17:10 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
2023-04-13 21:26 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

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=875ya0ar7w.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=gustavo.sousa@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.