[PATCH 24/44] drivers/nvmem: use min() instead of min_t()
From: david . laight . linux
Date: Wed Nov 19 2025 - 17:42:38 EST
From: David Laight <david.laight.linux@xxxxxxxxx>
min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'.
Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long'
and so cannot discard significant bits.
In this case the 'unsigned long' value is small enough that the result
is ok.
Detected by an extra check added to min_t().
Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>
---
drivers/nvmem/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 387c88c55259..8d6e78343054 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -359,7 +359,7 @@ static ssize_t nvmem_cell_attr_read(struct file *filp, struct kobject *kobj,
goto destroy_cell;
}
- read_len = min_t(unsigned int, cell_sz - pos, count);
+ read_len = min(cell_sz - pos, count);
memcpy(buf, content + pos, read_len);
kfree(content);
--
2.39.5