mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ASoC: use regmap_assign_bits() for conditional set/clear
@ 2026-09-24  8:34 Peng Fan (OSS)
  2026-09-24  9:47 ` Charles Keepax
  2026-09-24 23:27 ` Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Peng Fan (OSS) @ 2026-09-24  8:34 UTC (permalink / raw)
  To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Matthias Brugger,
	AngeloGioacchino Del Regno, Kuninori Morimoto
  Cc: linux-kernel, Peng Fan, linux-sound, patches, linux-arm-kernel,
	linux-mediatek

From: Peng Fan <peng.fan@nxp.com>

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.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 sound/soc/codecs/cs35l45.c                  |  6 ++----
 sound/soc/mediatek/mt8188/mt8188-dai-adda.c |  5 +----
 sound/soc/mediatek/mt8188/mt8188-dai-dmic.c | 10 ++--------
 3 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/sound/soc/codecs/cs35l45.c b/sound/soc/codecs/cs35l45.c
index 0ab76824f00f1..9eef7c8b1837e 100644
--- a/sound/soc/codecs/cs35l45.c
+++ b/sound/soc/codecs/cs35l45.c
@@ -224,10 +224,8 @@ static int cs35l45_sync_en_put(struct snd_kcontrol *kcontrol,
 		return 0;
 	}
 
-	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]);
 
 	cs35l45->sync_en = (bool)ucontrol->value.integer.value[0];
 
diff --git a/sound/soc/mediatek/mt8188/mt8188-dai-adda.c b/sound/soc/mediatek/mt8188/mt8188-dai-adda.c
index ac547fc864a6f..395f4ab972f81 100644
--- a/sound/soc/mediatek/mt8188/mt8188-dai-adda.c
+++ b/sound/soc/mediatek/mt8188/mt8188-dai-adda.c
@@ -123,10 +123,7 @@ static void mtk_adda_ul_mictype(struct mtk_base_afe *afe, bool dmic)
 	       UL_MODE_3P25M_CH2_CTL);
 
 	/* turn on dmic, ch1, ch2 */
-	if (dmic)
-		regmap_set_bits(afe->regmap, reg, val);
-	else
-		regmap_clear_bits(afe->regmap, reg, val);
+	regmap_assign_bits(afe->regmap, reg, val, dmic);
 }
 
 static int mtk_adda_ul_event(struct snd_soc_dapm_widget *w,
diff --git a/sound/soc/mediatek/mt8188/mt8188-dai-dmic.c b/sound/soc/mediatek/mt8188/mt8188-dai-dmic.c
index a9515d7fb70ac..7ac847a5925ca 100644
--- a/sound/soc/mediatek/mt8188/mt8188-dai-dmic.c
+++ b/sound/soc/mediatek/mt8188/mt8188-dai-dmic.c
@@ -143,10 +143,7 @@ static void mtk_dai_dmic_hw_gain_bypass(struct mtk_base_afe *afe,
 		return;
 	}
 
-	if (bypass)
-		regmap_set_bits(afe->regmap, reg->bypass, msk);
-	else
-		regmap_clear_bits(afe->regmap, reg->bypass, msk);
+	regmap_assign_bits(afe->regmap, reg->bypass, msk, bypass);
 }
 
 static void mtk_dai_dmic_hw_gain_on(struct mtk_base_afe *afe, unsigned int id,
@@ -157,10 +154,7 @@ static void mtk_dai_dmic_hw_gain_on(struct mtk_base_afe *afe, unsigned int id,
 	if (!reg)
 		return;
 
-	if (on)
-		regmap_set_bits(afe->regmap, reg->con0, DMIC_GAIN_CON0_GAIN_ON);
-	else
-		regmap_clear_bits(afe->regmap, reg->con0, DMIC_GAIN_CON0_GAIN_ON);
+	regmap_assign_bits(afe->regmap, reg->con0, DMIC_GAIN_CON0_GAIN_ON, on);
 }
 
 static const struct reg_sequence mtk_dai_dmic_iir_coeff_reg_defaults[] = {
-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: use regmap_assign_bits() for conditional set/clear
  2026-09-24  8:34 [PATCH] ASoC: use regmap_assign_bits() for conditional set/clear Peng Fan (OSS)
@ 2026-09-24  9:47 ` Charles Keepax
  2026-09-24 12:04   ` Mark Brown
  2026-09-24 23:27 ` Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: Charles Keepax @ 2026-09-24  9:47 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Matthias Brugger,
	AngeloGioacchino Del Regno, Kuninori Morimoto, linux-kernel,
	Peng Fan, linux-sound, patches, linux-arm-kernel, linux-mediatek

On Thu, Sep 24, 2026 at 04:34:12PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> 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.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  sound/soc/codecs/cs35l45.c                  |  6 ++----
>  sound/soc/mediatek/mt8188/mt8188-dai-adda.c |  5 +----
>  sound/soc/mediatek/mt8188/mt8188-dai-dmic.c | 10 ++--------
>  3 files changed, 5 insertions(+), 16 deletions(-)
> 
> diff --git a/sound/soc/codecs/cs35l45.c b/sound/soc/codecs/cs35l45.c
> index 0ab76824f00f1..9eef7c8b1837e 100644
> --- a/sound/soc/codecs/cs35l45.c
> +++ b/sound/soc/codecs/cs35l45.c
> @@ -224,10 +224,8 @@ static int cs35l45_sync_en_put(struct snd_kcontrol *kcontrol,
>  		return 0;
>  	}
>  
> -	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).

Also would be better to split this patch into two, one for the
mediatek stuff, one for the cirrus stuff.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: use regmap_assign_bits() for conditional set/clear
  2026-09-24  9:47 ` Charles Keepax
@ 2026-09-24 12:04   ` Mark Brown
  2026-09-24 12:10     ` Charles Keepax
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2026-09-24 12:04 UTC (permalink / raw)
  To: Charles Keepax
  Cc: Peng Fan (OSS),
	David Rhodes, Richard Fitzgerald, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, Matthias Brugger, AngeloGioacchino Del Regno,
	Kuninori Morimoto, linux-kernel, Peng Fan, linux-sound, patches,
	linux-arm-kernel, linux-mediatek

[-- Attachment #1: Type: text/plain, Size: 1016 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: use regmap_assign_bits() for conditional set/clear
  2026-09-24 12:04   ` Mark Brown
@ 2026-09-24 12:10     ` Charles Keepax
  0 siblings, 0 replies; 5+ messages in thread
From: Charles Keepax @ 2026-09-24 12:10 UTC (permalink / raw)
  To: Mark Brown
  Cc: Peng Fan (OSS),
	David Rhodes, Richard Fitzgerald, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, Matthias Brugger, AngeloGioacchino Del Regno,
	Kuninori Morimoto, linux-kernel, Peng Fan, linux-sound, patches,
	linux-arm-kernel, linux-mediatek

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: use regmap_assign_bits() for conditional set/clear
  2026-09-24  8:34 [PATCH] ASoC: use regmap_assign_bits() for conditional set/clear Peng Fan (OSS)
  2026-09-24  9:47 ` Charles Keepax
@ 2026-09-24 23:27 ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-09-24 23:27 UTC (permalink / raw)
  To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, Matthias Brugger, AngeloGioacchino Del Regno,
	Kuninori Morimoto, Peng Fan (OSS)
  Cc: linux-kernel, Peng Fan, linux-sound, patches, linux-arm-kernel,
	linux-mediatek

On Thu, 24 Sep 2026 16:34:12 +0800, Peng Fan (OSS) wrote:
> ASoC: use regmap_assign_bits() for conditional set/clear

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4

Thanks!

[1/1] ASoC: use regmap_assign_bits() for conditional set/clear
      https://git.kernel.org/broonie/sound/c/286ece639c37

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-25 17:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24  8:34 [PATCH] ASoC: use regmap_assign_bits() for conditional set/clear Peng Fan (OSS)
2026-09-24  9:47 ` Charles Keepax
2026-09-24 12:04   ` Mark Brown
2026-09-24 12:10     ` Charles Keepax
2026-09-24 23:27 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®