diff mbox series

[RFC,5/9] spi: spi-imx: spi_imx_buf_rx_swap_u32(): replace open coded swahw32()

Message ID 20220502165210.1956397-6-mkl@pengutronix.de
State Accepted
Commit baaadffe8854ea14eed1a5f3c09f2136c3aa4427
Headers show
Series spi: spi-imx: cleanups and performance improvements | expand

Commit Message

Marc Kleine-Budde May 2, 2022, 4:52 p.m. UTC
This patch replaces an open coded swahw32().

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/spi/spi-imx.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index a63cb26f33fc..e817cf95eea6 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -289,17 +289,16 @@  static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi,
 static void spi_imx_buf_rx_swap_u32(struct spi_imx_data *spi_imx)
 {
 	unsigned int val = readl(spi_imx->base + MXC_CSPIRXDATA);
-#ifdef __LITTLE_ENDIAN
-	unsigned int bytes_per_word;
-#endif
 
 	if (spi_imx->rx_buf) {
 #ifdef __LITTLE_ENDIAN
+		unsigned int bytes_per_word;
+
 		bytes_per_word = spi_imx_bytes_per_word(spi_imx->bits_per_word);
 		if (bytes_per_word == 1)
 			val = swab32(val);
 		else if (bytes_per_word == 2)
-			val = (val << 16) | (val >> 16);
+			val = swahw32(val);
 #endif
 		*(u32 *)spi_imx->rx_buf = val;
 		spi_imx->rx_buf += sizeof(u32);
@@ -355,7 +354,7 @@  static void spi_imx_buf_tx_swap_u32(struct spi_imx_data *spi_imx)
 	if (bytes_per_word == 1)
 		val = swab32(val);
 	else if (bytes_per_word == 2)
-		val = (val << 16) | (val >> 16);
+		val = swahw32(val);
 #endif
 	writel(val, spi_imx->base + MXC_CSPITXDATA);
 }