Skip to contentSkip to conversation

spi: mtk-snfi: use min() in mtk_snand_read_page_cache()

PATCH Superseded Ninad Naik 2 participants 2 messages Oct 22

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ninad Naik

author
#0 lore raw

PATCH 1/1 spi: mtk-snfi: use min() in mtk_snand_read_page_cache()

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.

---
 drivers/spi/spi-mtk-snfi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-mtk-snfi.c +1 -1
index 6e96e50fedad..bbb65a21a684 100644
@@ -1017,7 +1017,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);
+				       min(cap_len, req_left));
 		} else if (rd_offset < snf->buf_len) {
 			u32 cap_len = snf->buf_len - rd_offset;
 
Signature · 1 line
2.56.0
#1 lore raw
Quoted 15 lines · On Thu, 22 Oct 2026 15:50:20 +0530 Ninad Naik <[email protected]> wrote:

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.

---
 drivers/spi/spi-mtk-snfi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-mtk-snfi.c +0 -0
index 6e96e50fedad..bbb65a21a684 100644

drivers/spi/spi-mtk-snfi.c static int mtk_snand_read_page_cache(struct mtk_snand *snf, · line 1020

Quoted 5 lines
drivers/spi/spi-mtk-snfi.c +1 -1
@@ -1017,7 +1017,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);
+				       min(cap_len, req_left));

If you are going to do that then join the lines.

David

Quoted 3 lines
drivers/spi/spi-mtk-snfi.c +0 -0
 		} else if (rd_offset < snf->buf_len) {
 			u32 cap_len = snf->buf_len - rd_offset;