Re: [PATCH 15/24] ASoC: codecs: cs42l43: Use guard() and PM runtime scope helpers

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 <CAABR9nG9jDfK_wqS4Akfz5GL6HvZ-RkpPuYx4Q=vMn5jH_0foA@mail.gmail.com>
> > ---
> > -     if (!jack)
> > -             goto done;
> > +     if (!jack) {
> > +             regmap_update_bits(cs42l43->regmap, CS42L43_HS_BIAS_SENSE_AND_CLAMP_AUTOCONTROL,
> > +                                CS42L43_JACKDET_MODE_MASK |
> > +                                CS42L43_S0_AUTO_ADCMUTE_DISABLE_MASK |
> > +                                CS42L43_HSBIAS_SENSE_TRIP_MASK, autocontrol);
> > +             regmap_update_bits(cs42l43->regmap, CS42L43_PDNCNTL,
> > +                                CS42L43_RING_SENSE_EN_MASK, pdncntl);
> > +             dev_dbg(priv->dev, "Successfully configured accessory detect\n");
> > +
> > +             return 0;
>
> I really don't like this duplicating of code blocks, it takes us
> to a situation we always need to remember to update both blocks
> in sync which feels like it makes reviewing future patches very
> error prone.
>

Hi Charles,

I understand your concern about duplicating the code.

My reasoning is that duplicating this block once lets us eliminate 12
`goto` labels,
which I think makes the overall flow easier to follow. To me, that's a
reasonable trade-off.

If you have a cleaner approach that avoids both the duplicated block
and the 12 `goto` labels,
I'd be happy to adopt it.

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.