[Concept,06/17] ext4l: Move uuid_to_fsid to linux/statfs.h and use hexdump.h

Message ID 20260120234344.495605-7-sjg@u-boot.org
State New
Headers
Series ext4l: Move compatibility stubs to standard Linux headers |

Commit Message

Simon Glass Jan. 20, 2026, 11:43 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Move uuid_to_fsid() to linux/statfs.h where it belongs in the Linux
kernel header hierarchy. Also use hexdump.h for DUMP_PREFIX_* types,
with a stub for print_hex_dump since the Linux kernel has a different
function signature than U-Boot.

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

 fs/ext4l/ext4_uboot.h  | 21 ++++++++-------------
 include/linux/statfs.h | 19 +++++++++++++++++++
 2 files changed, 27 insertions(+), 13 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 6f2ea69a888..09e58989888 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -1003,8 +1003,13 @@  static u64 __attribute__((unused)) __ext4_sectors[2];
 
 /* system_state, SYSTEM_HALT, etc. are in linux/kernel.h */
 
-/* Hex dump */
-#define DUMP_PREFIX_ADDRESS	0
+/*
+ * Hex dump - DUMP_PREFIX_* types are in hexdump.h.
+ * However, the Linux kernel print_hex_dump has a different signature
+ * (includes log level) than U-Boot's, so we stub it out here.
+ */
+#include <hexdump.h>
+#undef print_hex_dump
 #define print_hex_dump(l, p, pt, rg, gc, b, len, a) do { } while (0)
 
 /* SLAB_RECLAIM_ACCOUNT, SLAB_ACCOUNT are in linux/slab.h */
@@ -1037,17 +1042,7 @@  struct super_operations {
 /* export_operations and fid - use linux/exportfs.h */
 #include <linux/exportfs.h>
 
-/* uuid_to_fsid - convert UUID to fsid */
-static inline __kernel_fsid_t uuid_to_fsid(const u8 *uuid)
-{
-	__kernel_fsid_t fsid;
-
-	fsid.val[0] = (uuid[0] << 24) | (uuid[1] << 16) |
-		      (uuid[2] << 8) | uuid[3];
-	fsid.val[1] = (uuid[4] << 24) | (uuid[5] << 16) |
-		      (uuid[6] << 8) | uuid[7];
-	return fsid;
-}
+/* uuid_to_fsid is in linux/statfs.h */
 
 /* kstatfs - use linux/statfs.h */
 #include <linux/statfs.h>
diff --git a/include/linux/statfs.h b/include/linux/statfs.h
index bdc3f9b9e87..6ba93c5b292 100644
--- a/include/linux/statfs.h
+++ b/include/linux/statfs.h
@@ -39,4 +39,23 @@  struct kstatfs {
 	long f_spare[4];
 };
 
+/**
+ * uuid_to_fsid - convert UUID to filesystem ID
+ * @uuid: UUID to convert (at least 8 bytes)
+ *
+ * Converts the first 8 bytes of a UUID to a filesystem ID.
+ *
+ * Return: the filesystem ID
+ */
+static inline __kernel_fsid_t uuid_to_fsid(const u8 *uuid)
+{
+	__kernel_fsid_t fsid;
+
+	fsid.val[0] = (uuid[0] << 24) | (uuid[1] << 16) |
+		      (uuid[2] << 8) | uuid[3];
+	fsid.val[1] = (uuid[4] << 24) | (uuid[5] << 16) |
+		      (uuid[6] << 8) | uuid[7];
+	return fsid;
+}
+
 #endif /* _LINUX_STATFS_H */