[PATCH spi-next 03/11] spi: spi-fsl-lpspi: fsl_lpspi_set_cmd(): use FIELD_PREP to encode Transmit Command register
From: Marc Kleine-Budde
Date: Mon Mar 16 2026 - 04:40:44 EST
Instead of open coding mask and shift operations and to increase
readability use FIELD_GET() to decode the Transmit Command register.
Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
---
drivers/spi/spi-fsl-lpspi.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index 4c550f740d85..e75b9acaa9e5 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -82,10 +82,14 @@
#define RSR_RXEMPTY BIT(1)
#define TCR_CPOL BIT(31)
#define TCR_CPHA BIT(30)
+#define TCR_MODE GENMASK(31, 30)
+#define TCR_PRESCALE GENMASK(29, 27)
+#define TCR_PCS GENMASK(25, 24)
#define TCR_CONT BIT(21)
#define TCR_CONTC BIT(20)
#define TCR_RXMSK BIT(19)
#define TCR_TXMSK BIT(18)
+#define TCR_FRAMESZ GENMASK(11, 0)
#define SR_CLEAR_MASK GENMASK(13, 8)
@@ -290,11 +294,11 @@ static void fsl_lpspi_set_cmd(struct fsl_lpspi_data *fsl_lpspi,
{
u32 temp = 0;
- temp |= fsl_lpspi->config.bpw - 1;
- temp |= (fsl_lpspi->config.mode & 0x3) << 30;
- temp |= (fsl_lpspi->config.chip_select & 0x3) << 24;
+ temp |= FIELD_PREP(TCR_FRAMESZ, fsl_lpspi->config.bpw - 1);
+ temp |= FIELD_PREP(TCR_MODE, fsl_lpspi->config.mode);
+ temp |= FIELD_PREP(TCR_PCS, fsl_lpspi->config.chip_select);
if (!fsl_lpspi->is_target) {
- temp |= fsl_lpspi->config.prescale << 27;
+ temp |= FIELD_PREP(TCR_PRESCALE, fsl_lpspi->config.prescale);
/*
* Set TCR_CONT will keep SS asserted after current transfer.
* For the first transfer, clear TCR_CONTC to assert SS.
--
2.51.0