Skip to content

Commit 1bdc716

Browse files
qianfengrongbroonie
authored andcommitted
spi: npcm-fiu: use min_t() to improve code
Use min_t() to reduce the code in npcm_fiu_read() and improve its readability. Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com> Link: https://patch.msgid.link/20250815082118.586422-3-rongqianfeng@vivo.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent a750050 commit 1bdc716

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/spi/spi-npcm-fiu.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/vmalloc.h>
1414
#include <linux/regmap.h>
1515
#include <linux/of.h>
16+
#include <linux/minmax.h>
1617
#include <linux/spi/spi-mem.h>
1718
#include <linux/mfd/syscon.h>
1819

@@ -498,10 +499,7 @@ static int npcm_fiu_read(struct spi_mem *mem, const struct spi_mem_op *op)
498499

499500
do {
500501
addr = ((u32)op->addr.val + i);
501-
if (currlen < 16)
502-
readlen = currlen;
503-
else
504-
readlen = 16;
502+
readlen = min_t(int, currlen, 16);
505503

506504
buf_ptr = data + i;
507505
ret = npcm_fiu_uma_read(mem, op, addr, true, buf_ptr,

0 commit comments

Comments
 (0)