diff mbox series

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

Message ID 20240306161439.1385643-4-stuarth@opensource.cirrus.com (mailing list archive)
State New, archived
Headers show
Series [1/5] ASoC: wm8962: Enable oscillator if selecting WM8962_FLL_OSC | expand

Commit Message

Stuart Henderson March 6, 2024, 4:14 p.m. UTC
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@opensource.cirrus.com>
---
 sound/soc/codecs/wm8962.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Comments

Mark Brown March 6, 2024, 4:46 p.m. UTC | #1
On Wed, Mar 06, 2024 at 04:14:38PM +0000, Stuart Henderson wrote:

> Previously wm8962_set_fll was using fll_id to configure the source.

Which was a problem because...?

> 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.

If the change is problematic why make it at all?
diff mbox series

Patch

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;