[PATCH v3 25/27] ASoC: codecs: rt712: Use guard() for mutex locks
Bui Duc Phuc
phucduc.bui at gmail.com
Fri Jul 10 17:08:28 PDT 2026
Hi Mark,
One more note on this:
> It seems this goto block was added recently, and I missed it after rebasing.
> Sorry for the inconvenience.
> However, looking at the goto path, it seems we might need to unwind the
> states more completely. What do you think about rewriting it like this?
>
> ------------------
> regcache_cache_only(rt712->regmap, false);
> ret = regcache_sync(rt712->regmap);
> if (ret) {
> regcache_cache_only(rt712->regmap, true);
> regcache_mark_dirty(rt712->regmap);
> return ret;
> }
>
> regcache_cache_only(rt712->mbq_regmap, false);
> ret = regcache_sync(rt712->mbq_regmap);
> if (ret) {
> regcache_cache_only(rt712->regmap, true);
> regcache_cache_only(rt712->mbq_regmap, true);
> regcache_mark_dirty(rt712->mbq_regmap);
> return ret;
> }
>
> return 0;
> --------------------
>
Since regmap was already synced successfully, marking it dirty again
would be redundant and could cause the next regcache_sync() to
needlessly rewrite cached registers that are already known to be in sync.
Also, in my understanding, any register write that happens afterwards
while cache_only=true should automatically set cache_dirty=true again
(see _regmap_write(), _regmap_raw_write_impl(),
regmap_noinc_readwrite(), and _regmap_multi_reg_write() in regmap.c),
so there may be no need to defensively mark it dirty here in case of
a later write. Reads aren't a concern here, since a read never
changes any state - it's only writes that can make the cache diverge
from the hardware while cache_only is set.
Please correct me if I'm missing something here.
Best regards,
Phuc
More information about the Linux-mediatek
mailing list