From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: David Rhodes <david.rhodes@cirrus.com>,
Richard Fitzgerald <rf@opensource.cirrus.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
linux-sound@vger.kernel.org, patches@opensource.cirrus.com,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: [PATCH] ASoC: use regmap_assign_bits() for conditional set/clear
Date: Thu, 24 Sep 2026 16:34:12 +0800 [thread overview]
Message-ID: <20260924083420.461715-1-peng.fan@oss.nxp.com> (raw)
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
next reply other threads:[~2026-09-24 8:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 8:34 Peng Fan (OSS) [this message]
2026-09-24 9:47 ` [PATCH] ASoC: use regmap_assign_bits() for conditional set/clear Charles Keepax
2026-09-24 12:04 ` Mark Brown
2026-09-24 12:10 ` Charles Keepax
2026-09-24 23:27 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260924083420.461715-1-peng.fan@oss.nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=david.rhodes@cirrus.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-sound@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=patches@opensource.cirrus.com \
--cc=peng.fan@nxp.com \
--cc=perex@perex.cz \
--cc=rf@opensource.cirrus.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox