Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Qianfeng Rong and committed by
Mark Brown
a7500503 c17b750b

+4 -4
+4 -4
drivers/spi/spi-fsl-lpspi.c
··· 25 25 #include <linux/spi/spi.h> 26 26 #include <linux/spi/spi_bitbang.h> 27 27 #include <linux/types.h> 28 + #include <linux/minmax.h> 28 29 29 30 #define DRIVER_NAME "fsl_lpspi" 30 31 ··· 476 475 fsl_lpspi->tx = fsl_lpspi_buf_tx_u32; 477 476 } 478 477 479 - if (t->len <= fsl_lpspi->txfifosize) 480 - fsl_lpspi->watermark = t->len; 481 - else 482 - fsl_lpspi->watermark = fsl_lpspi->txfifosize; 478 + fsl_lpspi->watermark = min_t(typeof(fsl_lpspi->watermark), 479 + fsl_lpspi->txfifosize, 480 + t->len); 483 481 484 482 if (fsl_lpspi_can_dma(controller, spi, t)) 485 483 fsl_lpspi->usedma = true;