Commit ef3355d2 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown

ASoC: uda134x: Use regmap_update_bits() were appropriate

Instead of doing the read-modify-update cycle by hand when updating a
register use regmap_update_bits().

This also means we can now remove uda134x_read_reg_cache() and
uda134x_write() since they are unused.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent f33c340a
......@@ -60,31 +60,6 @@ static const struct reg_default uda134x_reg_defaults[] = {
{ UDA134X_DATA1, 0x00 },
};
/*
* The codec has no support for reading its registers except for peak level...
*/
static inline unsigned int uda134x_read_reg_cache(struct snd_soc_codec *codec,
unsigned int reg)
{
struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
unsigned int val;
int ret;
ret = regmap_read(uda134x->regmap, reg, &val);
if (ret)
return -1;
return val;
}
static void uda134x_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int val)
{
struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
regmap_write(uda134x->regmap, reg, val);
}
/*
* Write to the uda134x registers
*
......@@ -137,27 +112,28 @@ static int uda134x_regmap_write(void *context, unsigned int reg,
static inline void uda134x_reset(struct snd_soc_codec *codec)
{
u8 reset_reg = uda134x_read_reg_cache(codec, UDA134X_STATUS0);
uda134x_write(codec, UDA134X_STATUS0, reset_reg | (1<<6));
struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
unsigned int mask = 1<<6;
regmap_update_bits(uda134x->regmap, UDA134X_STATUS0, mask, mask);
msleep(1);
uda134x_write(codec, UDA134X_STATUS0, reset_reg & ~(1<<6));
regmap_update_bits(uda134x->regmap, UDA134X_STATUS0, mask, 0);
}
static int uda134x_mute(struct snd_soc_dai *dai, int mute)
{
struct snd_soc_codec *codec = dai->codec;
u8 mute_reg = uda134x_read_reg_cache(codec, UDA134X_DATA010);
struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(dai->codec);
unsigned int mask = 1<<2;
unsigned int val;
pr_debug("%s mute: %d\n", __func__, mute);
if (mute)
mute_reg |= (1<<2);
val = mask;
else
mute_reg &= ~(1<<2);
uda134x_write(codec, UDA134X_DATA010, mute_reg);
val = 0;
return 0;
return regmap_update_bits(uda134x->regmap, UDA134X_DATA010, mask, val);
}
static int uda134x_startup(struct snd_pcm_substream *substream,
......@@ -209,7 +185,7 @@ static int uda134x_hw_params(struct snd_pcm_substream *substream,
{
struct snd_soc_codec *codec = dai->codec;
struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
u8 hw_params;
unsigned int hw_params = 0;
if (substream == uda134x->slave_substream) {
pr_debug("%s ignoring hw_params for slave substream\n",
......@@ -217,10 +193,6 @@ static int uda134x_hw_params(struct snd_pcm_substream *substream,
return 0;
}
hw_params = uda134x_read_reg_cache(codec, UDA134X_STATUS0);
hw_params &= STATUS0_SYSCLK_MASK;
hw_params &= STATUS0_DAIFMT_MASK;
pr_debug("%s sysclk: %d, rate:%d\n", __func__,
uda134x->sysclk, params_rate(params));
......@@ -271,9 +243,8 @@ static int uda134x_hw_params(struct snd_pcm_substream *substream,
return -EINVAL;
}
uda134x_write(codec, UDA134X_STATUS0, hw_params);
return 0;
return regmap_update_bits(uda134x->regmap, UDA134X_STATUS0,
STATUS0_SYSCLK_MASK | STATUS0_DAIFMT_MASK, hw_params);
}
static int uda134x_set_dai_sysclk(struct snd_soc_dai *codec_dai,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment