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 diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 2274f24f426..a493fb58ad7 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.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 */ diff --git a/include/kunit/static_stub.h b/include/kunit/static_stub.h index 995a919f641..265622c519b 100644 --- a/include/kunit/static_stub.h +++ b/include/kunit/static_stub.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 */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 475085e18ee..993985f88f3 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.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) diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h new file mode 100644 index 00000000000..7a105f768cb --- /dev/null +++ b/include/linux/sched/mm.h @@ -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 */ -- 2.43.0