ASoC: wm8985: Refactor set_pll code to avoid gcc warnings
authorFabio Estevam <fabio.estevam@freescale.com>
Mon, 24 Dec 2012 17:55:37 +0000 (15:55 -0200)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 11 Nov 2017 13:34:43 +0000 (13:34 +0000)
commit 5f3d25c08dee44a40229f1f9e8934f3217478a67 upstream.

Refactor set_pll code to avoid the following warnings:

sound/soc/codecs/wm8985.c:852:50: warning: 'pll_div.k' may be used uninitialized in this function
sound/soc/codecs/wm8985.c:849:9: warning: 'pll_div.n' may be used uninitialized in this function
sound/soc/codecs/wm8985.c:848:23: warning: 'pll_div.div2' may be used uninitialized in this function

Do the same as in commit 86ce6c9a (ASoC: WM8804: Refactor set_pll code to avoid
GCC warnings).

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
sound/soc/codecs/wm8985.c

index bae510a..9d79cc7 100644 (file)
@@ -785,33 +785,30 @@ static int wm8985_set_pll(struct snd_soc_dai *dai, int pll_id,
        struct pll_div pll_div;
 
        codec = dai->codec;
        struct pll_div pll_div;
 
        codec = dai->codec;
-       if (freq_in && freq_out) {
+       if (!freq_in || !freq_out) {
+               /* disable the PLL */
+               snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1,
+                                   WM8985_PLLEN_MASK, 0);
+       } else {
                ret = pll_factors(&pll_div, freq_out * 4 * 2, freq_in);
                if (ret)
                        return ret;
                ret = pll_factors(&pll_div, freq_out * 4 * 2, freq_in);
                if (ret)
                        return ret;
-       }
 
 
-       /* disable the PLL before reprogramming it */
-       snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1,
-                           WM8985_PLLEN_MASK, 0);
-       
-       if (!freq_in || !freq_out)
-               return 0;
-
-       /* set PLLN and PRESCALE */
-       snd_soc_write(codec, WM8985_PLL_N,
-                     (pll_div.div2 << WM8985_PLL_PRESCALE_SHIFT)
-                     | pll_div.n);
-       /* set PLLK */
-       snd_soc_write(codec, WM8985_PLL_K_3, pll_div.k & 0x1ff);
-       snd_soc_write(codec, WM8985_PLL_K_2, (pll_div.k >> 9) & 0x1ff);
-       snd_soc_write(codec, WM8985_PLL_K_1, (pll_div.k >> 18));
-       /* set the source of the clock to be the PLL */
-       snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL,
-                           WM8985_CLKSEL_MASK, WM8985_CLKSEL);
-       /* enable the PLL */
-       snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1,
-                           WM8985_PLLEN_MASK, WM8985_PLLEN);
+               /* set PLLN and PRESCALE */
+               snd_soc_write(codec, WM8985_PLL_N,
+                             (pll_div.div2 << WM8985_PLL_PRESCALE_SHIFT)
+                             | pll_div.n);
+               /* set PLLK */
+               snd_soc_write(codec, WM8985_PLL_K_3, pll_div.k & 0x1ff);
+               snd_soc_write(codec, WM8985_PLL_K_2, (pll_div.k >> 9) & 0x1ff);
+               snd_soc_write(codec, WM8985_PLL_K_1, (pll_div.k >> 18));
+               /* set the source of the clock to be the PLL */
+               snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL,
+                                   WM8985_CLKSEL_MASK, WM8985_CLKSEL);
+               /* enable the PLL */
+               snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1,
+                                   WM8985_PLLEN_MASK, WM8985_PLLEN);
+       }
        return 0;
 }
 
        return 0;
 }