[Concept,12/16] ext4l: Move umin to linux/minmax.h

Message ID 20260119214846.3087611-13-sjg@u-boot.org
State New
Headers
Series ext4l: Move definitions to standard Linux headers |

Commit Message

Simon Glass Jan. 19, 2026, 9:48 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Move the umin() macro to include/linux/minmax.h and add the matching
umax() macro. These return the minimum/maximum of two unsigned values.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 fs/ext4l/ext4_uboot.h  |  3 +--
 include/linux/minmax.h | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 310d79227b7..b50004bca55 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -699,8 +699,7 @@  struct dx_hash_info {
 
 /* indirect.c stubs */
 
-/* umin - unsigned min (Linux 6.x) */
-#define umin(x, y)	((x) < (y) ? (x) : (y))
+/* umin is in linux/minmax.h */
 
 /* truncate_inode_pages is in linux/pagemap.h */
 
diff --git a/include/linux/minmax.h b/include/linux/minmax.h
index 52ce477459d..38b27c0232f 100644
--- a/include/linux/minmax.h
+++ b/include/linux/minmax.h
@@ -49,4 +49,22 @@  static inline bool in_range32(u32 val, u32 start, u32 len)
 	return (val - start) < len;
 }
 
+/**
+ * umin - Return the minimum of two unsigned values
+ * @x: First value
+ * @y: Second value
+ *
+ * Return: The smaller of @x and @y
+ */
+#define umin(x, y)	((x) < (y) ? (x) : (y))
+
+/**
+ * umax - Return the maximum of two unsigned values
+ * @x: First value
+ * @y: Second value
+ *
+ * Return: The larger of @x and @y
+ */
+#define umax(x, y)	((x) > (y) ? (x) : (y))
+
 #endif /* _LINUX_MINMAX_H */