diff mbox series

[7/7] ASoC: cs42l43: Use fls to calculate the pre-divider for the PLL

Message ID 20240124165558.1876407-7-ckeepax@opensource.cirrus.com
State Superseded
Headers show
Series [1/7] ASoC: cs42l43: Tidy up header includes | expand

Commit Message

Charles Keepax Jan. 24, 2024, 4:55 p.m. UTC
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l43.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Andy Shevchenko Jan. 24, 2024, 10:47 p.m. UTC | #1
On Wed, Jan 24, 2024 at 6:56 PM Charles Keepax
<ckeepax@opensource.cirrus.com> wrote:

Commit message?

> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>

...

> +       div = fls(freq) -
> +             fls(cs42l43_pll_configs[ARRAY_SIZE(cs42l43_pll_configs) - 1].freq);
> +       freq /= 1 << div;

  freq >>= div;
diff mbox series

Patch

diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c
index 05ca20d4fd622..ef154aa76d576 100644
--- a/sound/soc/codecs/cs42l43.c
+++ b/sound/soc/codecs/cs42l43.c
@@ -1336,10 +1336,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 /= 1 << div;
 
 	if (div <= CS42L43_PLL_REFCLK_DIV_MASK) {
 		int i;