Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: es8316: Replace NR_SUPPORTED_MCLK_LRCK_RATIOS with ARRAY_SIZE()

No need for a special define since we can use ARRAY_SIZE() directly,
and won't need to worry to keep it in sync.

Signed-off-by: Marian Postevca <posteuca@mutex.one>
Link: https://lore.kernel.org/r/20230829220116.1159-3-posteuca@mutex.one
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Marian Postevca and committed by
Mark Brown
a43c0dc1 2f06f231

+4 -5
+4 -5
sound/soc/codecs/es8316.c
··· 27 27 * MCLK/LRCK ratios, but we also add ratio 400, which is commonly used on 28 28 * Intel Cherry Trail platforms (19.2MHz MCLK, 48kHz LRCK). 29 29 */ 30 - #define NR_SUPPORTED_MCLK_LRCK_RATIOS ARRAY_SIZE(supported_mclk_lrck_ratios) 31 30 static const unsigned int supported_mclk_lrck_ratios[] = { 32 31 256, 384, 400, 500, 512, 768, 1024 33 32 }; ··· 39 40 struct snd_soc_jack *jack; 40 41 int irq; 41 42 unsigned int sysclk; 42 - unsigned int allowed_rates[NR_SUPPORTED_MCLK_LRCK_RATIOS]; 43 + unsigned int allowed_rates[ARRAY_SIZE(supported_mclk_lrck_ratios)]; 43 44 struct snd_pcm_hw_constraint_list sysclk_constraints; 44 45 bool jd_inverted; 45 46 }; ··· 381 382 /* Limit supported sample rates to ones that can be autodetected 382 383 * by the codec running in slave mode. 383 384 */ 384 - for (i = 0; i < NR_SUPPORTED_MCLK_LRCK_RATIOS; i++) { 385 + for (i = 0; i < ARRAY_SIZE(supported_mclk_lrck_ratios); i++) { 385 386 const unsigned int ratio = supported_mclk_lrck_ratios[i]; 386 387 387 388 if (freq % ratio == 0) ··· 471 472 int i; 472 473 473 474 /* Validate supported sample rates that are autodetected from MCLK */ 474 - for (i = 0; i < NR_SUPPORTED_MCLK_LRCK_RATIOS; i++) { 475 + for (i = 0; i < ARRAY_SIZE(supported_mclk_lrck_ratios); i++) { 475 476 const unsigned int ratio = supported_mclk_lrck_ratios[i]; 476 477 477 478 if (es8316->sysclk % ratio != 0) ··· 479 480 if (es8316->sysclk / ratio == params_rate(params)) 480 481 break; 481 482 } 482 - if (i == NR_SUPPORTED_MCLK_LRCK_RATIOS) 483 + if (i == ARRAY_SIZE(supported_mclk_lrck_ratios)) 483 484 return -EINVAL; 484 485 lrck_divider = es8316->sysclk / params_rate(params); 485 486 bclk_divider = lrck_divider / 4;