[alsa-devel] [PATCH 6/6] ASoC: Intel: boards: use strcmp with constant literals

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Fri Oct 6 16:28:50 CEST 2017


On 10/6/17 6:50 AM, Andy Shevchenko wrote:
> On Fri, 2017-10-06 at 10:55 +0200, Takashi Iwai wrote:
>> On Thu, 05 Oct 2017 20:52:43 +0200,
>> Pierre-Louis Bossart wrote:
>>>
>>> we used strncmp in all audio machine drivers, this is not needed
>>> when comparing against constant literals.
>>> General replace of strncmp(a, b, strlen(b)) to strcmp(a,b)
>>>
>>> Suggested-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
>>> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.inte
>>> l.com>
>>> ---
>>>   sound/soc/intel/boards/bxt_da7219_max98357a.c   | 3 +--
>>>   sound/soc/intel/boards/bytcht_es8316.c          | 3 +--
>>>   sound/soc/intel/boards/bytcr_rt5640.c           | 6 ++----
>>>   sound/soc/intel/boards/bytcr_rt5651.c           | 3 +--
>>>   sound/soc/intel/boards/cht_bsw_max98090_ti.c    | 3 +--
>>>   sound/soc/intel/boards/cht_bsw_rt5645.c         | 6 ++----
>>>   sound/soc/intel/boards/cht_bsw_rt5672.c         | 3 +--
>>>   sound/soc/intel/boards/skl_nau88l25_max98357a.c | 3 +--
>>>   sound/soc/intel/boards/skl_nau88l25_ssm4567.c   | 3 +--
>>>   9 files changed, 11 insertions(+), 22 deletions(-)
>>
>> While we're at it: since all these do mostly same: wouldn't it make
>> more sense to create a helper to scan over the rtd_list?
>>
>> static inline snd_soc_intel_get_codec_dai(struct snd_soc_card *card,
>> 					  const char *dai_name)
>> {
>> 	struct snd_soc_pcm_runtime *rtd;
>>
>> 	list_for_each_entry(rtd, &card->rtd_list, list) {
>> 		if (!strcmp(rtd->codec_dai->name, dai_name))
>> 			return rtd->codec_dai;
>> 	}
>> 	
>> 	return NULL;
>> }
> 
> I like this!
> 
>> Some drivers require to check two names, but it can call this function
>> twice.
> 
> It looks like not hot path, so, 2 passes instead of one might be not a
> big deal.

Yes, that'd be a good way to simplify further. I'll resend the series, 
thanks for the suggestion Takashi.



More information about the Alsa-devel mailing list