Skip to content

Commit

Permalink
ALSA: hda: Use regcache_reg_cached() rather than open coding
Browse files Browse the repository at this point in the history
The HDA driver intentionally drops repeated writes to registers in some
circumstances, beyond the suppression of noop writes that regmap does in
regmap_update_bits(). It does this by checking if the register is cached
before doing a regmap_update_bits(), now we have an API for querying this
directly use it directly rather than trying a read in cache only mode
making the code a little clearer.

Reviewed-by: Takashi Iwai <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
broonie committed Jul 18, 2023
1 parent d881ee5 commit 99aae70
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions sound/hda/hdac_regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,17 +556,14 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw);
static int reg_raw_update_once(struct hdac_device *codec, unsigned int reg,
unsigned int mask, unsigned int val)
{
unsigned int orig;
int err;
int err = 0;

if (!codec->regmap)
return reg_raw_update(codec, reg, mask, val);

mutex_lock(&codec->regmap_lock);
regcache_cache_only(codec->regmap, true);
err = regmap_read(codec->regmap, reg, &orig);
regcache_cache_only(codec->regmap, false);
if (err < 0)
/* Discard any updates to already initialised registers. */
if (!regcache_reg_cached(codec->regmap, reg))
err = regmap_update_bits(codec->regmap, reg, mask, val);
mutex_unlock(&codec->regmap_lock);
return err;
Expand Down

0 comments on commit 99aae70

Please sign in to comment.