Skip to content

Commit 9e51ac6

Browse files
zonquebroonie
authored andcommitted
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: Daniel Mack <daniel@zonque.org> Link: https://lore.kernel.org/r/20220624104712.1934484-7-daniel@zonque.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f0d9693 commit 9e51ac6

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

sound/soc/codecs/max98396.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,15 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
342342
{
343343
struct snd_soc_component *component = codec_dai->component;
344344
struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component);
345-
unsigned int format = 0;
345+
unsigned int format_mask, format = 0;
346346
unsigned int bclk_pol = 0;
347347
int ret, status;
348348
int reg;
349349
bool update = false;
350350

351+
format_mask = MAX98396_PCM_MODE_CFG_FORMAT_MASK |
352+
MAX98396_PCM_MODE_CFG_LRCLKEDGE;
353+
351354
dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt);
352355

353356
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
@@ -395,7 +398,7 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
395398
ret = regmap_read(max98396->regmap, MAX98396_R2041_PCM_MODE_CFG, &reg);
396399
if (ret < 0)
397400
return -EINVAL;
398-
if (format != (reg & MAX98396_PCM_BCLKEDGE_BSEL_MASK)) {
401+
if (format != (reg & format_mask)) {
399402
update = true;
400403
} else {
401404
ret = regmap_read(max98396->regmap,
@@ -412,8 +415,7 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
412415

413416
regmap_update_bits(max98396->regmap,
414417
MAX98396_R2041_PCM_MODE_CFG,
415-
MAX98396_PCM_BCLKEDGE_BSEL_MASK,
416-
format);
418+
format_mask, format);
417419

418420
regmap_update_bits(max98396->regmap,
419421
MAX98396_R2042_PCM_CLK_SETUP,

0 commit comments

Comments
 (0)