Re: [PATCH 23/24] ASoC: codecs: cs48l32: Use guard() for mutex locks

Bui Duc Phuc <[email protected]>
Newsgroups dev.linux.lists.asahi,dev.linux.lists.chrome-platform,org.kernel.vger.linux-kernel,org.kernel.vger.linux-sound
Message-ID <CAABR9nHdqPQE9U1jA0J8RwUpgpcnFXXvx+bTPEwAWBzLn6=ahQ@mail.gmail.com>
On Fri, Jun 26, 2026 at 7:15 PM Charles Keepax
<[email protected]> wrote:
>
> 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.
>

Hi Charles,

I understand.
I'll remove that else block in v2.

Best regards,
Phuc
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.