Skip to content

Commit 99aae70

Browse files
committed
ALSA: hda: Use regcache_reg_cached() rather than open coding
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 <tiwai@suse.de> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230717-regmap-cache-check-v1-3-73ef688afae3@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d881ee5 commit 99aae70

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

sound/hda/hdac_regmap.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,17 +556,14 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw);
556556
static int reg_raw_update_once(struct hdac_device *codec, unsigned int reg,
557557
unsigned int mask, unsigned int val)
558558
{
559-
unsigned int orig;
560-
int err;
559+
int err = 0;
561560

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

565564
mutex_lock(&codec->regmap_lock);
566-
regcache_cache_only(codec->regmap, true);
567-
err = regmap_read(codec->regmap, reg, &orig);
568-
regcache_cache_only(codec->regmap, false);
569-
if (err < 0)
565+
/* Discard any updates to already initialised registers. */
566+
if (!regcache_reg_cached(codec->regmap, reg))
570567
err = regmap_update_bits(codec->regmap, reg, mask, val);
571568
mutex_unlock(&codec->regmap_lock);
572569
return err;

0 commit comments

Comments
 (0)