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>
This commit is contained in:
parent
d881ee5a87
commit
99aae70551
|
@ -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,
|
static int reg_raw_update_once(struct hdac_device *codec, unsigned int reg,
|
||||||
unsigned int mask, unsigned int val)
|
unsigned int mask, unsigned int val)
|
||||||
{
|
{
|
||||||
unsigned int orig;
|
int err = 0;
|
||||||
int err;
|
|
||||||
|
|
||||||
if (!codec->regmap)
|
if (!codec->regmap)
|
||||||
return reg_raw_update(codec, reg, mask, val);
|
return reg_raw_update(codec, reg, mask, val);
|
||||||
|
|
||||||
mutex_lock(&codec->regmap_lock);
|
mutex_lock(&codec->regmap_lock);
|
||||||
regcache_cache_only(codec->regmap, true);
|
/* Discard any updates to already initialised registers. */
|
||||||
err = regmap_read(codec->regmap, reg, &orig);
|
if (!regcache_reg_cached(codec->regmap, reg))
|
||||||
regcache_cache_only(codec->regmap, false);
|
|
||||||
if (err < 0)
|
|
||||||
err = regmap_update_bits(codec->regmap, reg, mask, val);
|
err = regmap_update_bits(codec->regmap, reg, mask, val);
|
||||||
mutex_unlock(&codec->regmap_lock);
|
mutex_unlock(&codec->regmap_lock);
|
||||||
return err;
|
return err;
|
||||||
|
|
Loading…
Reference in New Issue