summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/cs42l43.c
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.cirrus.com>2024-01-25 10:31:17 +0000
committerMark Brown <broonie@kernel.org>2024-01-26 14:47:00 +0000
commit31c6e53a4da5fe626b99e1ebf777d751994e3281 (patch)
treee341a98913482b0cc72a4469a7b7435cff20bf4b /sound/soc/codecs/cs42l43.c
parentfe04d1632cb4130fb47d18fe70ac292562a3b9c3 (diff)
downloadlinux-stable-31c6e53a4da5fe626b99e1ebf777d751994e3281.tar.gz
linux-stable-31c6e53a4da5fe626b99e1ebf777d751994e3281.tar.bz2
linux-stable-31c6e53a4da5fe626b99e1ebf777d751994e3281.zip
ASoC: cs42l43: Use fls to calculate the pre-divider for the PLL
Use fls to calculate the pre-divider and input frequency for the PLL, this is marginally faster than the previous loop. Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://msgid.link/r/20240125103117.2622095-7-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/cs42l43.c')
-rw-r--r--sound/soc/codecs/cs42l43.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c
index 23e9557494af..2c402086924d 100644
--- a/sound/soc/codecs/cs42l43.c
+++ b/sound/soc/codecs/cs42l43.c
@@ -1338,10 +1338,9 @@ static int cs42l43_enable_pll(struct cs42l43_codec *priv)
dev_dbg(priv->dev, "Enabling PLL at %uHz\n", freq);
- while (freq > cs42l43_pll_configs[ARRAY_SIZE(cs42l43_pll_configs) - 1].freq) {
- div++;
- freq /= 2;
- }
+ div = fls(freq) -
+ fls(cs42l43_pll_configs[ARRAY_SIZE(cs42l43_pll_configs) - 1].freq);
+ freq >>= div;
if (div <= CS42L43_PLL_REFCLK_DIV_MASK) {
int i;