Re: [PATCH 23/24] ASoC: codecs: cs48l32: Use guard() for mutex locks
Charles Keepax <[email protected]> Fri, 26 Jun 2026 13:15:13 +0100
| Newsgroups | dev.linux.lists.chrome-platform,dev.linux.lists.asahi,org.kernel.vger.linux-kernel,org.kernel.vger.linux-sound |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Jun 26, 2026 at 01:13:28PM +0700, [email protected] wrote: > From: bui duc phuc <[email protected]> > > Clean up the code using guard() for mutex locks. > Merely code refactoring, and no behavior change. > > Signed-off-by: bui duc phuc <[email protected]> > --- > - 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