* [PATCH] ASoC: mchp-spdifrx: Replace manual bitfield manipulations with macros and typo correction
@ 2026-04-20 20:32 Joao Marinho joao.bcc@usp.br
2026-04-26 21:51 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Joao Marinho joao.bcc@usp.br @ 2026-04-20 20:32 UTC (permalink / raw)
To: claudiu.beznea, andrei.simion, lgirdwood, broonie, perex, tiwai,
nicolas.ferre, alexandre.belloni
Cc: João, Micael Vinicius, linux-sound, linux-arm-kernel
From: João <joao.bcc@usp.br>
Replace manual bitfield manipulations with FIELD_GET() and
FIELD_PREP() in order to improve code readability, security
and manageability. Also correcting GENAMSK typo for GENMASK.
Signed-off-by: João Marinho <joao.bcc@usp.br>
Co-developed-by: Micael Vinicius <micael0208@usp.br>
Signed-off-by: Micael Vinicius <micael0208@usp.br>
---
sound/soc/atmel/mchp-spdifrx.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/sound/soc/atmel/mchp-spdifrx.c b/sound/soc/atmel/mchp-spdifrx.c
index 521bee499..2c47aabdc 100644
--- a/sound/soc/atmel/mchp-spdifrx.c
+++ b/sound/soc/atmel/mchp-spdifrx.c
@@ -6,6 +6,7 @@
//
// Author: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
+#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/module.h>
@@ -41,6 +42,13 @@
#define SPDIFRX_VERSION 0xFC /* Version Register */
+
+/* 32-bit word byte masks */
+#define SPDIFRX_BYTE_0_MASK GENMASK(7, 0)
+#define SPDIFRX_BYTE_1_MASK GENMASK(15, 8)
+#define SPDIFRX_BYTE_2_MASK GENMASK(23, 16)
+#define SPDIFRX_BYTE_3_MASK GENMASK(31, 24)
+
/*
* ---- Control Register (Write-only) ----
*/
@@ -55,7 +63,7 @@
#define SPDIFRX_MR_RXEN_ENABLE (1 << 0) /* SPDIF Receiver Enabled */
/* Validity Bit Mode */
-#define SPDIFRX_MR_VBMODE_MASK GENAMSK(1, 1)
+#define SPDIFRX_MR_VBMODE_MASK GENMASK(1, 1)
#define SPDIFRX_MR_VBMODE_ALWAYS_LOAD \
(0 << 1) /* Load sample regardless of validity bit value */
#define SPDIFRX_MR_VBMODE_DISCARD_IF_VB1 \
@@ -74,7 +82,7 @@
/* Sample Data Width */
#define SPDIFRX_MR_DATAWIDTH_MASK GENMASK(5, 4)
#define SPDIFRX_MR_DATAWIDTH(width) \
- (((6 - (width) / 4) << 4) & SPDIFRX_MR_DATAWIDTH_MASK)
+ FIELD_PREP(SPDIFRX_MR_DATAWIDTH_MASK, 6 - ((width) / 4))
/* Packed Data Mode in Receive Holding Register */
#define SPDIFRX_MR_PACK_MASK GENMASK(7, 7)
@@ -118,15 +126,14 @@
#define SPDIFRX_RSR_LOWF BIT(2)
#define SPDIFRX_RSR_NOSIGNAL BIT(3)
#define SPDIFRX_RSR_IFS_MASK GENMASK(27, 16)
-#define SPDIFRX_RSR_IFS(reg) \
- (((reg) & SPDIFRX_RSR_IFS_MASK) >> 16)
+#define SPDIFRX_RSR_IFS(reg) FIELD_GET(SPDIFRX_RSR_IFS_MASK, reg)
/*
* ---- Version Register (Read-only) ----
*/
#define SPDIFRX_VERSION_MASK GENMASK(11, 0)
#define SPDIFRX_VERSION_MFN_MASK GENMASK(18, 16)
-#define SPDIFRX_VERSION_MFN(reg) (((reg) & SPDIFRX_VERSION_MFN_MASK) >> 16)
+#define SPDIFRX_VERSION_MFN(reg) FIELD_GET(SPDIFRX_VERSION_MFN_MASK, reg)
static bool mchp_spdifrx_readable_reg(struct device *dev, unsigned int reg)
{
@@ -317,10 +324,10 @@ static void mchp_spdifrx_channel_status_read(struct mchp_spdifrx_dev *dev,
for (i = 0; i < ARRAY_SIZE(ctrl->ch_stat[channel].data) / 4; i++) {
regmap_read(dev->regmap, SPDIFRX_CHSR(channel, i), &val);
- *ch_stat++ = val & 0xFF;
- *ch_stat++ = (val >> 8) & 0xFF;
- *ch_stat++ = (val >> 16) & 0xFF;
- *ch_stat++ = (val >> 24) & 0xFF;
+ *ch_stat++ = FIELD_GET(SPDIFRX_BYTE_0_MASK, val);
+ *ch_stat++ = FIELD_GET(SPDIFRX_BYTE_1_MASK, val);
+ *ch_stat++ = FIELD_GET(SPDIFRX_BYTE_2_MASK, val);
+ *ch_stat++ = FIELD_GET(SPDIFRX_BYTE_3_MASK, val);
}
}
@@ -334,10 +341,10 @@ static void mchp_spdifrx_channel_user_data_read(struct mchp_spdifrx_dev *dev,
for (i = 0; i < ARRAY_SIZE(ctrl->user_data[channel].data) / 4; i++) {
regmap_read(dev->regmap, SPDIFRX_CHUD(channel, i), &val);
- *user_data++ = val & 0xFF;
- *user_data++ = (val >> 8) & 0xFF;
- *user_data++ = (val >> 16) & 0xFF;
- *user_data++ = (val >> 24) & 0xFF;
+ *user_data++ = FIELD_GET(SPDIFRX_BYTE_0_MASK, val);
+ *user_data++ = FIELD_GET(SPDIFRX_BYTE_1_MASK, val);
+ *user_data++ = FIELD_GET(SPDIFRX_BYTE_2_MASK, val);
+ *user_data++ = FIELD_GET(SPDIFRX_BYTE_3_MASK, val);
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ASoC: mchp-spdifrx: Replace manual bitfield manipulations with macros and typo correction
2026-04-20 20:32 [PATCH] ASoC: mchp-spdifrx: Replace manual bitfield manipulations with macros and typo correction Joao Marinho joao.bcc@usp.br
@ 2026-04-26 21:51 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-04-26 21:51 UTC (permalink / raw)
To: claudiu.beznea, andrei.simion, lgirdwood, perex, tiwai,
nicolas.ferre, alexandre.belloni, Joao Marinho joao.bcc@usp.br
Cc: Micael Vinicius, linux-sound, linux-arm-kernel
On Mon, 20 Apr 2026 17:32:03 -0300, Joao Marinho joao.bcc@usp.br wrote:
> ASoC: mchp-spdifrx: Replace manual bitfield manipulations with macros and typo correction
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2
Thanks!
[1/1] ASoC: mchp-spdifrx: Replace manual bitfield manipulations with macros and typo correction
https://git.kernel.org/broonie/asoc/c/0241d6192a11
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] 2+ messages in thread
end of thread, other threads:[~2026-04-26 23:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20 20:32 [PATCH] ASoC: mchp-spdifrx: Replace manual bitfield manipulations with macros and typo correction Joao Marinho joao.bcc@usp.br
2026-04-26 21:51 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox