[PATCH v2] spi: mtk-snfi: use min() in mtk_snand_read_page_cache()
From: Ninad Naik
Date: Mon Oct 26 2026 - 07:38:42 EST
Replace the ternary case with min() to pick the smaller of cap_len and
req_left.
No functional change intended. Compile tested only.
Found using Coccinelle.
Signed-off-by: Ninad Naik <ninadnaik07@xxxxxxxxx>
---
Changes in v2:
- Join the memcpy() arguments onto one line as min() is shorter.
drivers/spi/spi-mtk-snfi.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-snfi.c
index 6e96e50fedad..7eb7b40db11d 100644
--- a/drivers/spi/spi-mtk-snfi.c
+++ b/drivers/spi/spi-mtk-snfi.c
@@ -1016,8 +1016,7 @@ static int mtk_snand_read_page_cache(struct mtk_snand *snf,
if (req_left)
memcpy(op->data.buf.in + snf->nfi_cfg.page_size,
- buf_fdm,
- cap_len < req_left ? cap_len : req_left);
+ buf_fdm, min(cap_len, req_left));
} else if (rd_offset < snf->buf_len) {
u32 cap_len = snf->buf_len - rd_offset;
--
2.56.0