Re: [PATCH 23/24] ASoC: codecs: cs48l32: Use guard() for mutex locks
From: Charles Keepax
Date: Fri Jun 26 2026 - 08:19:23 EST
On Fri, Jun 26, 2026 at 01:13:28PM +0700, phucduc.bui@xxxxxxxxx wrote:
> From: bui duc phuc <phucduc.bui@xxxxxxxxx>
>
> Clean up the code using guard() for mutex locks.
> Merely code refactoring, and no behavior change.
>
> Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
> ---
> - snd_soc_component_update_bits(component, base + CS48L32_ASP_CONTROL1,
> - CS48L32_ASP_RATE_MASK, target_asp_rate);
> -
> - if (change_rate_domain) {
> - cs48l32_spin_sysclk(cs48l32_codec);
> - mutex_unlock(&cs48l32_codec->rate_lock);
> + scoped_guard(mutex, &cs48l32_codec->rate_lock) {
> + cs48l32_spin_sysclk(cs48l32_codec);
> + snd_soc_component_update_bits(component,
> + base + CS48L32_ASP_CONTROL1,
> + CS48L32_ASP_RATE_MASK,
> + target_asp_rate);
> + cs48l32_spin_sysclk(cs48l32_codec);
> + }
> + } else {
> + snd_soc_component_update_bits(component, base + CS48L32_ASP_CONTROL1,
> + CS48L32_ASP_RATE_MASK, target_asp_rate);
We can just drop this second write, update_bits won't do a
write if the bits don't change and we know they won't from the
read earlier. The original code was a bit odd, but might as well
clean it up whilst we are shuffling this all around.
Thanks,
Charles