提交 a8fc415c 编写于 作者: P Peter Ujfalusi 提交者: Mark Brown

ASoC: twl4030: Separate write condition checking from I/O function

Simplifies the code a bit and prepares it to the removal of local caching.
Signed-off-by: NPeter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: NMark Brown <broonie@linaro.org>
上级 258549c0
...@@ -181,50 +181,56 @@ static inline void twl4030_write_reg_cache(struct snd_soc_codec *codec, ...@@ -181,50 +181,56 @@ static inline void twl4030_write_reg_cache(struct snd_soc_codec *codec,
cache[reg] = value; cache[reg] = value;
} }
/* static bool twl4030_can_write_to_chip(struct snd_soc_codec *codec,
* write to the twl4030 register space unsigned int reg)
*/
static int twl4030_write(struct snd_soc_codec *codec,
unsigned int reg, unsigned int value)
{ {
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
int write_to_reg = 0; bool write_to_reg = false;
twl4030_write_reg_cache(codec, reg, value);
/* Decide if the given register can be written */ /* Decide if the given register can be written */
switch (reg) { switch (reg) {
case TWL4030_REG_EAR_CTL: case TWL4030_REG_EAR_CTL:
if (twl4030->earpiece_enabled) if (twl4030->earpiece_enabled)
write_to_reg = 1; write_to_reg = true;
break; break;
case TWL4030_REG_PREDL_CTL: case TWL4030_REG_PREDL_CTL:
if (twl4030->predrivel_enabled) if (twl4030->predrivel_enabled)
write_to_reg = 1; write_to_reg = true;
break; break;
case TWL4030_REG_PREDR_CTL: case TWL4030_REG_PREDR_CTL:
if (twl4030->predriver_enabled) if (twl4030->predriver_enabled)
write_to_reg = 1; write_to_reg = true;
break; break;
case TWL4030_REG_PRECKL_CTL: case TWL4030_REG_PRECKL_CTL:
if (twl4030->carkitl_enabled) if (twl4030->carkitl_enabled)
write_to_reg = 1; write_to_reg = true;
break; break;
case TWL4030_REG_PRECKR_CTL: case TWL4030_REG_PRECKR_CTL:
if (twl4030->carkitr_enabled) if (twl4030->carkitr_enabled)
write_to_reg = 1; write_to_reg = true;
break; break;
case TWL4030_REG_HS_GAIN_SET: case TWL4030_REG_HS_GAIN_SET:
if (twl4030->hsl_enabled || twl4030->hsr_enabled) if (twl4030->hsl_enabled || twl4030->hsr_enabled)
write_to_reg = 1; write_to_reg = true;
break; break;
default: default:
/* All other register can be written */ /* All other register can be written */
write_to_reg = 1; write_to_reg = true;
break; break;
} }
if (write_to_reg)
return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, return write_to_reg;
value, reg); }
/*
* write to the twl4030 register space
*/
static int twl4030_write(struct snd_soc_codec *codec,
unsigned int reg, unsigned int value)
{
twl4030_write_reg_cache(codec, reg, value);
if (twl4030_can_write_to_chip(codec, reg))
return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value, reg);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册