[Concept,04/17] ext4l: Move memory and kunit stubs to standard headers
Commit Message
From: Simon Glass <simon.glass@canonical.com>
Move several compatibility stubs to their canonical Linux header
locations:
- Create linux/sched/mm.h with memalloc_nofs_save/restore stubs
- Create kunit/static_stub.h with KUNIT_STATIC_STUB_REDIRECT stub
- Add IS_CASEFOLDED to linux/fs.h
This continues reducing ext4_uboot.h by placing these definitions in
their proper locations in the Linux header hierarchy.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
fs/ext4l/ext4_uboot.h | 12 +++++-------
include/kunit/static_stub.h | 12 ++++++++----
include/linux/fs.h | 3 ++-
include/linux/sched/mm.h | 32 ++++++++++++++++++++++++++++++++
4 files changed, 47 insertions(+), 12 deletions(-)
create mode 100644 include/linux/sched/mm.h
@@ -163,12 +163,10 @@
/* percpu rw semaphore is in linux/percpu.h */
-/* Memory allocation context - stubs */
-static inline unsigned int memalloc_nofs_save(void) { return 0; }
-static inline void memalloc_nofs_restore(unsigned int flags) { }
+/* Memory allocation context - use linux/sched/mm.h */
+#include <linux/sched/mm.h>
-/* Inode flags - stubs */
-#define IS_CASEFOLDED(inode) (0)
+/* IS_CASEFOLDED is in linux/fs.h */
/* IS_ENCRYPTED and FSCRYPT_SET_CONTEXT_MAX_SIZE are in ext4_fscrypt.h */
#define S_NOQUOTA 0
@@ -216,8 +214,8 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block);
#define __test_and_set_bit_le(nr, addr) \
({ int __old = test_bit(nr, addr); set_bit(nr, addr); __old; })
-/* KUNIT stub */
-#define KUNIT_STATIC_STUB_REDIRECT(...) do { } while (0)
+/* KUNIT stub - use kunit/static_stub.h */
+#include <kunit/static_stub.h>
/* percpu_counter operations are in linux/percpu_counter.h */
@@ -1,13 +1,17 @@
/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * KUnit static stub support for U-Boot
+ *
+ * Based on Linux include/kunit/static_stub.h
+ */
#ifndef _KUNIT_STATIC_STUB_H
#define _KUNIT_STATIC_STUB_H
/*
- * Stub header for U-Boot ext4l.
+ * KUNIT_STATIC_STUB_REDIRECT - call a replacement stub if one exists
*
- * KUnit static stubs are for kernel unit testing - not needed in U-Boot.
+ * U-Boot doesn't support KUnit, so this is a no-op.
*/
-
-#define KUNIT_STATIC_STUB_REDIRECT(func, args...) do { } while (0)
+#define KUNIT_STATIC_STUB_REDIRECT(...) do { } while (0)
#endif /* _KUNIT_STATIC_STUB_H */
@@ -300,10 +300,11 @@ enum {
/* inode_newsize_ok - check if new size is valid (always ok in U-Boot) */
#define inode_newsize_ok(i, s) ({ (void)(i); (void)(s); 0; })
-/* IS_SYNC, IS_APPEND, IS_IMMUTABLE - inode flag checks */
+/* IS_SYNC, IS_APPEND, IS_IMMUTABLE, IS_CASEFOLDED - inode flag checks */
#define IS_SYNC(inode) (0)
#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
+#define IS_CASEFOLDED(inode) (0) /* Case-folding not supported */
/* inode_needs_sync - check if inode needs synchronous writes (always false) */
#define inode_needs_sync(inode) (0)
new file mode 100644
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Memory allocation context helpers for U-Boot
+ *
+ * Based on Linux include/linux/sched/mm.h
+ */
+#ifndef _LINUX_SCHED_MM_H
+#define _LINUX_SCHED_MM_H
+
+/**
+ * memalloc_nofs_save() - Mark implicit GFP_NOFS allocation scope
+ *
+ * U-Boot stub - no filesystem allocation context tracking needed.
+ *
+ * Return: 0 (no flags to restore)
+ */
+static inline unsigned int memalloc_nofs_save(void)
+{
+ return 0;
+}
+
+/**
+ * memalloc_nofs_restore() - End implicit GFP_NOFS scope
+ * @flags: flags returned by memalloc_nofs_save()
+ *
+ * U-Boot stub - no filesystem allocation context tracking needed.
+ */
+static inline void memalloc_nofs_restore(unsigned int flags)
+{
+}
+
+#endif /* _LINUX_SCHED_MM_H */