Re: [PATCH] ASoC: use regmap_assign_bits() for conditional set/clear

From: Charles Keepax

Date: Thu Sep 24 2026 - 08:20:04 EST


On Thu, Sep 24, 2026 at 01:04:16PM +0100, Mark Brown wrote:
> On Thu, Sep 24, 2026 at 10:47:02AM +0100, Charles Keepax wrote:
> > On Thu, Sep 24, 2026 at 04:34:12PM +0800, Peng Fan (OSS) wrote:
>
> > > Replace if/else blocks using regmap_set_bits()/regmap_clear_bits() with
> > > the simpler regmap_assign_bits() calls in the cs35l45 codec and the
> > > mediatek mt8188 ADDA and DMIC DAI drivers.
>
> > > - if ((bool)ucontrol->value.integer.value[0])
> > > - regmap_set_bits(cs35l45->regmap, CS35L45_BLOCK_ENABLES2, CS35L45_SYNC_EN_MASK);
> > > - else
> > > - regmap_clear_bits(cs35l45->regmap, CS35L45_BLOCK_ENABLES2, CS35L45_SYNC_EN_MASK);
>
> > > + regmap_assign_bits(cs35l45->regmap, CS35L45_BLOCK_ENABLES2, CS35L45_SYNC_EN_MASK,
> > > + (bool)ucontrol->value.integer.value[0]);
>
> > This doesn't work value will be bit(0) but SYNC_EN is bit(8).
>
> No, it's _assign_bits() not _update_bits() so it'll set the bits
> specified in the third argument if the fourth argument is true.
>
> > Also would be better to split this patch into two, one for the
> > mediatek stuff, one for the cirrus stuff.
>
> Yes.

oops yeah, thanks for the correction.

Thanks,
Charles