ASoC: wm8993: Refactor set_pll code to avoid GCC warnings
authorFabio Estevam <fabio.estevam@freescale.com>
Wed, 12 Dec 2012 03:24:40 +0000 (01:24 -0200)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 24 Dec 2012 15:55:40 +0000 (15:55 +0000)
Refactor set_pll code to avoid the following warnings:

sound/soc/codecs/wm8983.c:873:40: warning: 'pll_div.k' may be used uninitialized in this function [-Wuninitialized]
sound/soc/codecs/wm8983.c:870:9: warning: 'pll_div.n' may be used uninitialized in this function [-Wuninitialized]
sound/soc/codecs/wm8983.c:869:23: warning: 'pll_div.div2' may be used uninitialized in this function [-Wuninitialized]

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>
sound/soc/codecs/wm8983.c

index 9fe1e041da498cec9bc335959c92d569ca0102b9..c9c707b8698f36f160e63f94e9a91e5bad989103 100644 (file)
@@ -851,30 +851,33 @@ static int wm8983_set_pll(struct snd_soc_dai *dai, int pll_id,
        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, WM8983_POWER_MANAGEMENT_1,
+                                   WM8983_PLLEN_MASK, 0);
+               return 0;
+       } else {
                ret = pll_factors(&pll_div, freq_out * 4 * 2, freq_in);
                if (ret)
                        return ret;
-       }
-
-       /* disable the PLL before re-programming it */
-       snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1,
-                           WM8983_PLLEN_MASK, 0);
 
-       if (!freq_in || !freq_out)
-               return 0;
+               /* disable the PLL before re-programming it */
+               snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1,
+                                   WM8983_PLLEN_MASK, 0);
+
+               /* set PLLN and PRESCALE */
+               snd_soc_write(codec, WM8983_PLL_N,
+                       (pll_div.div2 << WM8983_PLL_PRESCALE_SHIFT)
+                       | pll_div.n);
+               /* set PLLK */
+               snd_soc_write(codec, WM8983_PLL_K_3, pll_div.k & 0x1ff);
+               snd_soc_write(codec, WM8983_PLL_K_2, (pll_div.k >> 9) & 0x1ff);
+               snd_soc_write(codec, WM8983_PLL_K_1, (pll_div.k >> 18));
+               /* enable the PLL */
+               snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1,
+                                       WM8983_PLLEN_MASK, WM8983_PLLEN);
+       }
 
-       /* set PLLN and PRESCALE */
-       snd_soc_write(codec, WM8983_PLL_N,
-                     (pll_div.div2 << WM8983_PLL_PRESCALE_SHIFT)
-                     | pll_div.n);
-       /* set PLLK */
-       snd_soc_write(codec, WM8983_PLL_K_3, pll_div.k & 0x1ff);
-       snd_soc_write(codec, WM8983_PLL_K_2, (pll_div.k >> 9) & 0x1ff);
-       snd_soc_write(codec, WM8983_PLL_K_1, (pll_div.k >> 18));
-       /* enable the PLL */
-       snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1,
-                           WM8983_PLLEN_MASK, WM8983_PLLEN);
        return 0;
 }