[PATCH 3/4] ASoC: TWL4030: Only update the needed bits in *set_dai_sysclk

2009-10-19 Thread Peter Ujfalusi
Do not rewrite the whole register, but only update the needed
bits in set_dai_sysclk functions.

Signed-off-by: Peter Ujfalusi peter.ujfal...@nokia.com
---
 sound/soc/codecs/twl4030.c |   22 --
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 4df7c6c..559e9b2 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -1785,19 +1785,21 @@ static int twl4030_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
 {
struct snd_soc_codec *codec = codec_dai-codec;
struct twl4030_priv *twl4030 = codec-private_data;
-   u8 infreq;
+   u8 apll_ctrl;
 
+   apll_ctrl = twl4030_read_reg_cache(codec, TWL4030_REG_APLL_CTL);
+   apll_ctrl = ~TWL4030_APLL_INFREQ;
switch (freq) {
case 1920:
-   infreq = TWL4030_APLL_INFREQ_19200KHZ;
+   apll_ctrl |= TWL4030_APLL_INFREQ_19200KHZ;
twl4030-sysclk = 19200;
break;
case 2600:
-   infreq = TWL4030_APLL_INFREQ_26000KHZ;
+   apll_ctrl |= TWL4030_APLL_INFREQ_26000KHZ;
twl4030-sysclk = 26000;
break;
case 3840:
-   infreq = TWL4030_APLL_INFREQ_38400KHZ;
+   apll_ctrl |= TWL4030_APLL_INFREQ_38400KHZ;
twl4030-sysclk = 38400;
break;
default:
@@ -1806,8 +1808,7 @@ static int twl4030_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return -EINVAL;
}
 
-   infreq |= TWL4030_APLL_EN;
-   twl4030_write(codec, TWL4030_REG_APLL_CTL, infreq);
+   twl4030_write(codec, TWL4030_REG_APLL_CTL, apll_ctrl);
 
return 0;
 }
@@ -1989,11 +1990,13 @@ static int twl4030_voice_set_dai_sysclk(struct 
snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
 {
struct snd_soc_codec *codec = codec_dai-codec;
-   u8 infreq;
+   u8 apll_ctrl;
 
+   apll_ctrl = twl4030_read_reg_cache(codec, TWL4030_REG_APLL_CTL);
+   apll_ctrl = ~TWL4030_APLL_INFREQ;
switch (freq) {
case 2600:
-   infreq = TWL4030_APLL_INFREQ_26000KHZ;
+   apll_ctrl |= TWL4030_APLL_INFREQ_26000KHZ;
break;
default:
printk(KERN_ERR TWL4030 voice set sysclk: unknown rate %d\n,
@@ -2001,8 +2004,7 @@ static int twl4030_voice_set_dai_sysclk(struct 
snd_soc_dai *codec_dai,
return -EINVAL;
}
 
-   infreq |= TWL4030_APLL_EN;
-   twl4030_write(codec, TWL4030_REG_APLL_CTL, infreq);
+   twl4030_write(codec, TWL4030_REG_APLL_CTL, apll_ctrl);
 
return 0;
 }
-- 
1.6.5.1

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] ASoC: TWL4030: Only update the needed bits in *set_dai_sysclk

2009-10-19 Thread Mark Brown
On Mon, Oct 19, 2009 at 03:42:19PM +0300, Peter Ujfalusi wrote:

 + apll_ctrl = twl4030_read_reg_cache(codec, TWL4030_REG_APLL_CTL);
 + apll_ctrl = ~TWL4030_APLL_INFREQ;
   switch (freq) {

I'll apply this - it's idiomatic for the current driver - but you might
want to look at snd_soc_update_bits() which does a read/modify/write
cycle for you.
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] ASoC: TWL4030: Only update the needed bits in *set_dai_sysclk

2009-10-19 Thread Peter Ujfalusi
On Monday 19 October 2009 15:55:08 ext Mark Brown wrote:
 On Mon, Oct 19, 2009 at 03:42:19PM +0300, Peter Ujfalusi wrote:
  +   apll_ctrl = twl4030_read_reg_cache(codec, TWL4030_REG_APLL_CTL);
  +   apll_ctrl = ~TWL4030_APLL_INFREQ;
  switch (freq) {
 
 I'll apply this - it's idiomatic for the current driver - but you might
 want to look at snd_soc_update_bits() which does a read/modify/write
 cycle for you.
 

Yeah, it is a good idea.
I'll address this when I go through the soc codec driver in my planned revisit 
and cleanup round quite soon.

Thanks,
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html