Skip to content

Commit a750050

Browse files
qianfengrongbroonie
authored andcommitted
spi: spi-fsl-lpspi: use min_t() to improve code
Use min_t() to reduce the code in fsl_lpspi_setup_transfer() and improve its readability. Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com> Link: https://patch.msgid.link/20250815082118.586422-2-rongqianfeng@vivo.com Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent c17b750 commit a750050

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/spi/spi-fsl-lpspi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/spi/spi.h>
2626
#include <linux/spi/spi_bitbang.h>
2727
#include <linux/types.h>
28+
#include <linux/minmax.h>
2829

2930
#define DRIVER_NAME "fsl_lpspi"
3031

@@ -475,10 +476,9 @@ static int fsl_lpspi_setup_transfer(struct spi_controller *controller,
475476
fsl_lpspi->tx = fsl_lpspi_buf_tx_u32;
476477
}
477478

478-
if (t->len <= fsl_lpspi->txfifosize)
479-
fsl_lpspi->watermark = t->len;
480-
else
481-
fsl_lpspi->watermark = fsl_lpspi->txfifosize;
479+
fsl_lpspi->watermark = min_t(typeof(fsl_lpspi->watermark),
480+
fsl_lpspi->txfifosize,
481+
t->len);
482482

483483
if (fsl_lpspi_can_dma(controller, spi, t))
484484
fsl_lpspi->usedma = true;

0 commit comments

Comments
 (0)