* [PATCH 1/2] ASoC: wm8985: Refactor set_pll code to avoid gcc warnings
@ 2012-12-24 17:55 Fabio Estevam
2012-12-24 17:55 ` [PATCH 2/2] ASoC: Fix 'may be used uninitialized' warnings Fabio Estevam
2012-12-27 16:49 ` [PATCH 1/2] ASoC: wm8985: Refactor set_pll code to avoid gcc warnings Mark Brown
0 siblings, 2 replies; 4+ messages in thread
From: Fabio Estevam @ 2012-12-24 17:55 UTC (permalink / raw)
To: broonie; +Cc: Fabio Estevam, alsa-devel
From: Fabio Estevam <fabio.estevam@freescale.com>
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>
---
sound/soc/codecs/wm8985.c | 43 ++++++++++++++++++++-----------------------
1 file changed, 20 insertions(+), 23 deletions(-)
diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c
index ab37826..dd6ce3b 100644
--- a/sound/soc/codecs/wm8985.c
+++ b/sound/soc/codecs/wm8985.c
@@ -830,33 +830,30 @@ static int wm8985_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, WM8985_POWER_MANAGEMENT_1,
+ WM8985_PLLEN_MASK, 0);
+ } else {
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;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ASoC: Fix 'may be used uninitialized' warnings
2012-12-24 17:55 [PATCH 1/2] ASoC: wm8985: Refactor set_pll code to avoid gcc warnings Fabio Estevam
@ 2012-12-24 17:55 ` Fabio Estevam
2012-12-27 16:42 ` Mark Brown
2012-12-27 16:49 ` [PATCH 1/2] ASoC: wm8985: Refactor set_pll code to avoid gcc warnings Mark Brown
1 sibling, 1 reply; 4+ messages in thread
From: Fabio Estevam @ 2012-12-24 17:55 UTC (permalink / raw)
To: broonie; +Cc: Fabio Estevam, alsa-devel
From: Fabio Estevam <fabio.estevam@freescale.com>
Fix the following build warnings:
sound/soc/codecs/wm_hubs.c: In function 'hp_event':
sound/soc/codecs/wm_hubs.c:321:11: warning: 'reg_r' may be used uninitialized in this function [-Wuninitialized]
sound/soc/codecs/wm_hubs.c:251:13: note: 'reg_r' was declared here
sound/soc/codecs/wm_hubs.c:322:11: warning: 'reg_l' may be used uninitialized in this function [-Wuninitialized]
sound/soc/codecs/wm_hubs.c:251:6: note: 'reg_l' was declared here
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
sound/soc/codecs/wm_hubs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c
index 867ae97..a2ea687 100644
--- a/sound/soc/codecs/wm_hubs.c
+++ b/sound/soc/codecs/wm_hubs.c
@@ -248,7 +248,7 @@ static void enable_dc_servo(struct snd_soc_codec *codec)
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
struct wm_hubs_dcs_cache *cache;
s8 offset;
- u16 reg_l, reg_r, dcs_cfg, dcs_reg;
+ u16 reg_l = 0, reg_r = 0, dcs_cfg, dcs_reg;
switch (hubs->dcs_readback_mode) {
case 2:
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] ASoC: Fix 'may be used uninitialized' warnings
2012-12-24 17:55 ` [PATCH 2/2] ASoC: Fix 'may be used uninitialized' warnings Fabio Estevam
@ 2012-12-27 16:42 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-12-27 16:42 UTC (permalink / raw)
To: Fabio Estevam; +Cc: Fabio Estevam, alsa-devel
[-- Attachment #1.1: Type: text/plain, Size: 475 bytes --]
On Mon, Dec 24, 2012 at 03:55:38PM -0200, Fabio Estevam wrote:
> - u16 reg_l, reg_r, dcs_cfg, dcs_reg;
> + u16 reg_l = 0, reg_r = 0, dcs_cfg, dcs_reg;
No, this is a terrible idea. Apart from the coding style thing all
you're doing here is just ensuring that a value is set in the variable
without any analysis saying that this is a sensible value to set or that
the compiler hasn't spotted a genuine issue.
There's also the possibility that the compiler is just buggy...
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ASoC: wm8985: Refactor set_pll code to avoid gcc warnings
2012-12-24 17:55 [PATCH 1/2] ASoC: wm8985: Refactor set_pll code to avoid gcc warnings Fabio Estevam
2012-12-24 17:55 ` [PATCH 2/2] ASoC: Fix 'may be used uninitialized' warnings Fabio Estevam
@ 2012-12-27 16:49 ` Mark Brown
1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-12-27 16:49 UTC (permalink / raw)
To: Fabio Estevam; +Cc: Fabio Estevam, alsa-devel
[-- Attachment #1.1: Type: text/plain, Size: 296 bytes --]
On Mon, Dec 24, 2012 at 03:55:37PM -0200, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> Refactor set_pll code to avoid the following warnings:
Applied, thanks. Though if you could report the flow analysis bug
against GCC that'd probably be more useful...
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-12-27 16:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-24 17:55 [PATCH 1/2] ASoC: wm8985: Refactor set_pll code to avoid gcc warnings Fabio Estevam
2012-12-24 17:55 ` [PATCH 2/2] ASoC: Fix 'may be used uninitialized' warnings Fabio Estevam
2012-12-27 16:42 ` Mark Brown
2012-12-27 16:49 ` [PATCH 1/2] ASoC: wm8985: Refactor set_pll code to avoid gcc warnings Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).