[Intel-gfx] [PATCH] drm/i915/aux: clean up aux name initialization

Jani Nikula jani.nikula at intel.com
Thu Apr 13 12:42:27 UTC 2023


On Thu, 13 Apr 2023, Gustavo Sousa <gustavo.sousa at 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 at 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


More information about the Intel-gfx mailing list