Commit c529fd62 authored by Daniel Mack's avatar Daniel Mack Committed by Mark Brown

ASoC: max98396: Fix register access for PCM format settings

max98396_dai_set_fmt() modifes register 2041 and touches bits in the mask
0x3a. Make sure to use the right mask for that operation.
Signed-off-by: default avatarDaniel Mack <daniel@zonque.org>
Link: https://lore.kernel.org/r/20220624104712.1934484-7-daniel@zonque.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent a8c1dc9e
...@@ -349,12 +349,15 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -349,12 +349,15 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{ {
struct snd_soc_component *component = codec_dai->component; struct snd_soc_component *component = codec_dai->component;
struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component); struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component);
unsigned int format = 0; unsigned int format_mask, format = 0;
unsigned int bclk_pol = 0; unsigned int bclk_pol = 0;
int ret, status; int ret, status;
int reg; int reg;
bool update = false; bool update = false;
format_mask = MAX98396_PCM_MODE_CFG_FORMAT_MASK |
MAX98396_PCM_MODE_CFG_LRCLKEDGE;
dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt); dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt);
switch (fmt & SND_SOC_DAIFMT_INV_MASK) { switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
...@@ -405,7 +408,7 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -405,7 +408,7 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
ret = regmap_read(max98396->regmap, MAX98396_R2041_PCM_MODE_CFG, &reg); ret = regmap_read(max98396->regmap, MAX98396_R2041_PCM_MODE_CFG, &reg);
if (ret < 0) if (ret < 0)
return -EINVAL; return -EINVAL;
if (format != (reg & MAX98396_PCM_BCLKEDGE_BSEL_MASK)) { if (format != (reg & format_mask)) {
update = true; update = true;
} else { } else {
ret = regmap_read(max98396->regmap, ret = regmap_read(max98396->regmap,
...@@ -422,8 +425,7 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -422,8 +425,7 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
regmap_update_bits(max98396->regmap, regmap_update_bits(max98396->regmap,
MAX98396_R2041_PCM_MODE_CFG, MAX98396_R2041_PCM_MODE_CFG,
MAX98396_PCM_BCLKEDGE_BSEL_MASK, format_mask, format);
format);
regmap_update_bits(max98396->regmap, regmap_update_bits(max98396->regmap,
MAX98396_R2042_PCM_CLK_SETUP, MAX98396_R2042_PCM_CLK_SETUP,
......
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