[PATCH 4/5] ASoC: wm8962: Fix wm8962_set_fll to use source instead of fll_id

From: Stuart Henderson
Date: Wed Mar 06 2024 - 11:15:51 EST


Previously wm8962_set_fll was using fll_id to configure the source.
This change is problematic, but it looks like there's limited
users of this driver, and luckily they all seem to be intending to
use WM8962_FLL_MCLK as the source which happens to have the same
value as WM8962_FLL.

Signed-off-by: Stuart Henderson <stuarth@xxxxxxxxxxxxxxxxxxxxx>
---
sound/soc/codecs/wm8962.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 2256cc0a37eb..24bd818c3345 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -2890,6 +2890,14 @@ static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int s
int ret;
int fll1 = 0;

+ switch (fll_id) {
+ case WM8962_FLL:
+ break;
+ default:
+ dev_err(component->dev, "Unknown FLL ID %d\n", fll_id);
+ return -EINVAL;
+ }
+
/* Any change? */
if (source == wm8962->fll_src && Fref == wm8962->fll_fref &&
Fout == wm8962->fll_fout)
@@ -2916,13 +2924,13 @@ static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int s
/* Parameters good, disable so we can reprogram */
snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0);

- switch (fll_id) {
+ switch (source) {
case WM8962_FLL_MCLK:
case WM8962_FLL_BCLK:
- fll1 |= (fll_id - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
+ fll1 |= (source - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
break;
case WM8962_FLL_OSC:
- fll1 |= (fll_id - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
+ fll1 |= (source - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
snd_soc_component_update_bits(component, WM8962_PLL2,
WM8962_OSC_ENA, WM8962_OSC_ENA);
break;
--
2.39.2