[PATCH 00/12] ext4l: Continue reducing ext4_uboot.h size with more headers
From: Simon Glass <simon.glass@canonical.com> This series continues reducing fs/ext4l/ext4_uboot.h by moving more definitions to appropriate include/linux/ header files. The previous series reduced the file from 2584 to 1980 lines. This series further reduces it to 1816 lines (total 30% reduction). New headers created: - fiemap.h: FIEMAP extent types and fiemap_extent_info structure - statfs.h: kstatfs structure for filesystem statistics - exportfs.h: NFS export operations (fid, export_operations) - mbcache.h: Metadata block cache stubs - wait_bit.h: Wait bit operation stubs - ratelimit.h: Rate limiting stubs - projid.h: Project ID type (kprojid_t) - mnt_idmap.h: Mount ID mapping stub - hash.h: hash_64() and hash_32() functions - blockgroup_lock.h: Block group lock structure - delayed_call.h: Delayed function call support Updated headers: - capability.h: Added CAP_SYS_ADMIN - uio.h: Added kiocb and IOCB_* flags - utsname.h: Added init_utsname() function - proc_fs.h: Added proc_ops structure and procfs stubs All implementations are appropriate stubs for U-Boot's single-threaded environment. Tests pass with these changes. Simon Glass (12): linux: capability: Add CAP_SYS_ADMIN constant linux: uio: Add kiocb struct and IOCB_* flags linux: Add fiemap.h header with extent mapping types linux: Add statfs.h header with kstatfs struct linux: Add exportfs.h header with NFS export operations linux: Add mbcache.h header with metadata cache stubs linux: Add wait_bit.h header with wait bit stubs linux: Add ratelimit.h header with rate limiting stubs linux: utsname/proc_fs: Add init_utsname() and proc_ops linux: Add projid.h and mnt_idmapping.h headers linux: Add hash.h header with hash_64 function linux: Add blockgroup_lock.h and delayed_call.h headers fs/ext4l/ext4_uboot.h | 250 ++++++-------------------------- include/linux/blockgroup_lock.h | 25 ++++ include/linux/capability.h | 1 + include/linux/delayed_call.h | 56 +++++++ include/linux/exportfs.h | 78 ++++++++++ include/linux/fiemap.h | 45 ++++++ include/linux/hash.h | 33 +++++ include/linux/mbcache.h | 60 ++++++++ include/linux/mnt_idmapping.h | 23 +++ include/linux/proc_fs.h | 25 ++++ include/linux/projid.h | 43 ++++++ include/linux/ratelimit.h | 35 +++++ include/linux/statfs.h | 42 ++++++ include/linux/uio.h | 19 +++ include/linux/utsname.h | 12 ++ include/linux/wait_bit.h | 47 ++++++ 16 files changed, 587 insertions(+), 207 deletions(-) create mode 100644 include/linux/blockgroup_lock.h create mode 100644 include/linux/delayed_call.h create mode 100644 include/linux/exportfs.h create mode 100644 include/linux/fiemap.h create mode 100644 include/linux/hash.h create mode 100644 include/linux/mbcache.h create mode 100644 include/linux/mnt_idmapping.h create mode 100644 include/linux/projid.h create mode 100644 include/linux/ratelimit.h create mode 100644 include/linux/statfs.h create mode 100644 include/linux/wait_bit.h -- 2.43.0 base-commit: 3e4570227c362cc009a7f308c824c50da750bf1c branch: exts
From: Simon Glass <simon.glass@canonical.com> Add CAP_SYS_ADMIN to capability.h and update ext4_uboot.h to use the header instead of duplicating the capability definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 8 +++----- include/linux/capability.h | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index a4baac6fc86..80a1c5c6bc9 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -138,6 +138,9 @@ typedef struct { unsigned int val; } kprojid_t; #define __GFP_MOVABLE 0 #define __GFP_FS 0 +/* Capabilities - use linux/capability.h */ +#include <linux/capability.h> + /* FIEMAP extent flags */ #define FIEMAP_EXTENT_LAST 0x00000001 #define FIEMAP_EXTENT_UNKNOWN 0x00000002 @@ -198,11 +201,6 @@ struct fiemap_extent_info { void *fi_extents_start; }; -/* Capabilities - stubs (always allow) */ -#define CAP_SYS_ADMIN 0 -#define CAP_SYS_RESOURCE 0 -#define capable(cap) (1) - /* fscrypt_str, qstr are now in ext4_fscrypt.h */ /* percpu rw semaphore is in linux/percpu.h */ diff --git a/include/linux/capability.h b/include/linux/capability.h index 1192c8a4033..5f402de52e9 100644 --- a/include/linux/capability.h +++ b/include/linux/capability.h @@ -12,6 +12,7 @@ #ifndef _LINUX_CAPABILITY_H #define _LINUX_CAPABILITY_H +#define CAP_SYS_ADMIN 21 #define CAP_SYS_RESOURCE 24 static inline bool capable(int cap) -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Add the kernel I/O control block (kiocb) structure and associated flags to uio.h, and update ext4_uboot.h to use the header instead of duplicating these definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 19 ++----------------- include/linux/uio.h | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 80a1c5c6bc9..937c819a3f0 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -164,23 +164,8 @@ typedef struct { unsigned int val; } kprojid_t; /* struct file is defined in linux/fs.h */ -/* kiocb - kernel I/O control block */ -struct iov_iter; - -struct kiocb { - int ki_flags; - struct file *ki_filp; - loff_t ki_pos; -}; - -#define IOCB_DIRECT 0x0001 -#define IOCB_NOWAIT 0x0002 -#define IOCB_ATOMIC 0x0004 - -/* iov_iter stubs */ -#define iov_iter_truncate(i, count) do { } while (0) -#define iov_iter_count(i) 0 -#define iov_iter_alignment(iter) 0 +/* kiocb, iov_iter - use linux/uio.h */ +#include <linux/uio.h> /* __counted_by attribute - not available in U-Boot */ #define __counted_by(x) diff --git a/include/linux/uio.h b/include/linux/uio.h index cb050705597..e347d318c60 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -63,4 +63,23 @@ static inline size_t iov_iter_alignment(const struct iov_iter *i) return 0; /* Stub - assume aligned */ } +/** + * struct kiocb - kernel I/O control block + * @ki_flags: I/O flags + * @ki_filp: file pointer + * @ki_pos: file position + * + * U-Boot stub for asynchronous I/O control. + */ +struct kiocb { + int ki_flags; + struct file *ki_filp; + loff_t ki_pos; +}; + +/* kiocb flags */ +#define IOCB_DIRECT 0x0001 +#define IOCB_NOWAIT 0x0002 +#define IOCB_ATOMIC 0x0004 + #endif /* __LINUX_UIO_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/fiemap.h with FIEMAP extent flags, fiemap_extent_info structure, and fiemap operation stubs. Update ext4_uboot.h to use the new header instead of duplicating these definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 24 +++------------------- include/linux/fiemap.h | 45 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 include/linux/fiemap.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 937c819a3f0..185951ac4c1 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -141,11 +141,8 @@ typedef struct { unsigned int val; } kprojid_t; /* Capabilities - use linux/capability.h */ #include <linux/capability.h> -/* FIEMAP extent flags */ -#define FIEMAP_EXTENT_LAST 0x00000001 -#define FIEMAP_EXTENT_UNKNOWN 0x00000002 -#define FIEMAP_EXTENT_DELALLOC 0x00000004 -#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 +/* FIEMAP types - use linux/fiemap.h */ +#include <linux/fiemap.h> #define EXT4_FIEMAP_EXTENT_HOLE 0x08000000 /* FALLOC_FL_* flags are in linux/fs.h */ @@ -174,18 +171,6 @@ typedef struct { unsigned int val; } kprojid_t; /* iomap types and structs are in linux/iomap.h */ -/* fiemap types */ -#define FIEMAP_FLAG_SYNC 0x00000001 -#define FIEMAP_FLAG_XATTR 0x00000002 -#define FIEMAP_FLAG_CACHE 0x00000004 - -struct fiemap_extent_info { - unsigned int fi_flags; - unsigned int fi_extents_mapped; - unsigned int fi_extents_max; - void *fi_extents_start; -}; - /* fscrypt_str, qstr are now in ext4_fscrypt.h */ /* percpu rw semaphore is in linux/percpu.h */ @@ -850,10 +835,7 @@ static inline int in_range(unsigned long val, unsigned long start, /* Quota stub */ #define dquot_reclaim_block(i, n) do { } while (0) -/* fiemap stubs */ -#define fiemap_prep(i, fi, s, l, f) ({ (void)(i); (void)(fi); (void)(s); (void)(l); (void)(f); 0; }) -#define fiemap_fill_next_extent(fi, l, p, sz, f) ({ (void)(fi); (void)(l); (void)(p); (void)(sz); (void)(f); 0; }) -#define iomap_fiemap(i, fi, s, l, o) ({ (void)(i); (void)(fi); (void)(s); (void)(l); (void)(o); 0; }) +/* fiemap stubs are now in linux/fiemap.h */ /* Memory retry wait */ #define memalloc_retry_wait(g) do { } while (0) diff --git a/include/linux/fiemap.h b/include/linux/fiemap.h new file mode 100644 index 00000000000..f02080832be --- /dev/null +++ b/include/linux/fiemap.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Fiemap definitions for U-Boot + * + * Based on Linux fiemap.h - extent mapping interface. + */ +#ifndef _LINUX_FIEMAP_H +#define _LINUX_FIEMAP_H + +#include <linux/types.h> + +/* FIEMAP extent flags */ +#define FIEMAP_EXTENT_LAST 0x00000001 +#define FIEMAP_EXTENT_UNKNOWN 0x00000002 +#define FIEMAP_EXTENT_DELALLOC 0x00000004 +#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 + +/* FIEMAP flags */ +#define FIEMAP_FLAG_SYNC 0x00000001 +#define FIEMAP_FLAG_XATTR 0x00000002 +#define FIEMAP_FLAG_CACHE 0x00000004 + +/** + * struct fiemap_extent_info - fiemap request to a filesystem + * @fi_flags: flags as passed from user + * @fi_extents_mapped: number of mapped extents + * @fi_extents_max: size of fiemap_extent array + * @fi_extents_start: start of fiemap_extent array + */ +struct fiemap_extent_info { + unsigned int fi_flags; + unsigned int fi_extents_mapped; + unsigned int fi_extents_max; + void *fi_extents_start; +}; + +/* Fiemap stubs - fiemap not supported in U-Boot */ +#define fiemap_prep(i, fi, s, l, f) \ + ({ (void)(i); (void)(fi); (void)(s); (void)(l); (void)(f); 0; }) +#define fiemap_fill_next_extent(fi, l, p, sz, f) \ + ({ (void)(fi); (void)(l); (void)(p); (void)(sz); (void)(f); 0; }) +#define iomap_fiemap(i, fi, s, l, o) \ + ({ (void)(i); (void)(fi); (void)(s); (void)(l); (void)(o); 0; }) + +#endif /* _LINUX_FIEMAP_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/statfs.h with the kstatfs structure for filesystem statistics reporting. Update ext4_uboot.h to use the new header instead of duplicating the structure definition. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 17 ++--------------- include/linux/statfs.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 15 deletions(-) create mode 100644 include/linux/statfs.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 185951ac4c1..f686364a761 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1300,21 +1300,8 @@ static inline __kernel_fsid_t uuid_to_fsid(const u8 *uuid) return fsid; } -/* kstatfs for statfs */ -struct kstatfs { - long f_type; - long f_bsize; - u64 f_blocks; - u64 f_bfree; - u64 f_bavail; - u64 f_files; - u64 f_ffree; - __kernel_fsid_t f_fsid; - long f_namelen; - long f_frsize; - long f_flags; - long f_spare[4]; -}; +/* kstatfs - use linux/statfs.h */ +#include <linux/statfs.h> /* struct seq_file is in linux/seq_file.h */ diff --git a/include/linux/statfs.h b/include/linux/statfs.h new file mode 100644 index 00000000000..bdc3f9b9e87 --- /dev/null +++ b/include/linux/statfs.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Filesystem statistics definitions for U-Boot + * + * Based on Linux statfs.h + */ +#ifndef _LINUX_STATFS_H +#define _LINUX_STATFS_H + +#include <linux/types.h> + +/** + * struct kstatfs - kernel filesystem statistics + * @f_type: filesystem type + * @f_bsize: optimal transfer block size + * @f_blocks: total data blocks in filesystem + * @f_bfree: free blocks in filesystem + * @f_bavail: free blocks available to unprivileged user + * @f_files: total file nodes in filesystem + * @f_ffree: free file nodes in filesystem + * @f_fsid: filesystem ID + * @f_namelen: maximum length of filenames + * @f_frsize: fragment size + * @f_flags: mount flags + * @f_spare: spare for later + */ +struct kstatfs { + long f_type; + long f_bsize; + u64 f_blocks; + u64 f_bfree; + u64 f_bavail; + u64 f_files; + u64 f_ffree; + __kernel_fsid_t f_fsid; + long f_namelen; + long f_frsize; + long f_flags; + long f_spare[4]; +}; + +#endif /* _LINUX_STATFS_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/exportfs.h with struct fid, export_operations, and generic file handle encoder/decoder declarations for NFS export support. Update ext4_uboot.h to use the new header instead of duplicating these definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 38 ++------------------ include/linux/exportfs.h | 78 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 35 deletions(-) create mode 100644 include/linux/exportfs.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index f686364a761..b6744894169 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1259,34 +1259,8 @@ struct super_operations { struct dentry *(*get_dquots)(struct inode *); }; -/* export_operations for NFS */ -struct export_operations { - int (*encode_fh)(struct inode *, __u32 *, int *, struct inode *); - struct dentry *(*fh_to_dentry)(struct super_block *, struct fid *, int, int); - struct dentry *(*fh_to_parent)(struct super_block *, struct fid *, int, int); - struct dentry *(*get_parent)(struct dentry *); - int (*commit_metadata)(struct inode *); -}; - -/* Generic file handle encoder for NFS exports - stub */ -static inline int generic_encode_ino32_fh(struct inode *inode, __u32 *fh, - int *max_len, struct inode *parent) -{ - return 0; -} - -/* fid for export_operations */ -struct fid { - union { - struct { - u32 ino; - u32 gen; - u32 parent_ino; - u32 parent_gen; - } i32; - __u32 raw[0]; - }; -}; +/* 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) @@ -1433,13 +1407,7 @@ int inode_generic_drop(struct inode *inode); /* fsverity stubs (fscrypt macros are in ext4_fscrypt.h) */ #define fsverity_cleanup_inode(i) do { } while (0) -/* NFS export helpers - declarations for stub.c */ -struct dentry *generic_fh_to_dentry(struct super_block *sb, struct fid *fid, - int fh_len, int fh_type, - struct inode *(*get_inode)(struct super_block *, u64, u32)); -struct dentry *generic_fh_to_parent(struct super_block *sb, struct fid *fid, - int fh_len, int fh_type, - struct inode *(*get_inode)(struct super_block *, u64, u32)); +/* NFS export helpers are now in linux/exportfs.h */ /* Path operations */ #define path_put(p) do { } while (0) diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h new file mode 100644 index 00000000000..d42b9f63d15 --- /dev/null +++ b/include/linux/exportfs.h @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * NFS export operations for U-Boot + * + * Based on Linux exportfs.h - filesystem export support for NFS. + */ +#ifndef _LINUX_EXPORTFS_H +#define _LINUX_EXPORTFS_H + +#include <linux/types.h> + +struct super_block; +struct dentry; +struct inode; + +/** + * struct fid - NFS file handle + * + * Flexible file handle for NFS export. + */ +struct fid { + union { + struct { + u32 ino; + u32 gen; + u32 parent_ino; + u32 parent_gen; + } i32; + __u32 raw[0]; + }; +}; + +/** + * struct export_operations - NFS export operations + * @encode_fh: encode file handle + * @fh_to_dentry: decode file handle to dentry + * @fh_to_parent: decode file handle to parent dentry + * @get_parent: get parent directory + * @commit_metadata: commit metadata changes + * + * Operations for NFS export support. + */ +struct export_operations { + int (*encode_fh)(struct inode *, __u32 *, int *, struct inode *); + struct dentry *(*fh_to_dentry)(struct super_block *, struct fid *, + int, int); + struct dentry *(*fh_to_parent)(struct super_block *, struct fid *, + int, int); + struct dentry *(*get_parent)(struct dentry *); + int (*commit_metadata)(struct inode *); +}; + +/** + * generic_encode_ino32_fh() - generic file handle encoder + * @inode: inode to encode + * @fh: file handle buffer + * @max_len: maximum length of buffer + * @parent: parent inode (may be NULL) + * + * U-Boot stub - returns 0. + */ +static inline int generic_encode_ino32_fh(struct inode *inode, __u32 *fh, + int *max_len, struct inode *parent) +{ + return 0; +} + +/* NFS export helpers - stubs for U-Boot */ +struct dentry *generic_fh_to_dentry(struct super_block *sb, struct fid *fid, + int fh_len, int fh_type, + struct inode *(*get_inode)(struct super_block *, + u64, u32)); +struct dentry *generic_fh_to_parent(struct super_block *sb, struct fid *fid, + int fh_len, int fh_type, + struct inode *(*get_inode)(struct super_block *, + u64, u32)); + +#endif /* _LINUX_EXPORTFS_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/mbcache.h with mb_cache structure and cache operation stubs. Metadata block caching is not supported in U-Boot. Update ext4_uboot.h to use the new header instead of duplicating these definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 29 ++------------------ include/linux/mbcache.h | 60 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 27 deletions(-) create mode 100644 include/linux/mbcache.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index b6744894169..ba90cce3e67 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1477,33 +1477,8 @@ static inline void super_set_uuid(struct super_block *sb, const u8 *uuid, /* super_set_sysfs_name_bdev is now in linux/kobject.h */ -/* - * mb_cache - metadata block cache stubs for xattr.c - * Not supported in U-Boot - xattr caching disabled - */ -struct mb_cache { - int dummy; -}; - -struct mb_cache_entry { - u64 e_value; - unsigned long e_flags; -}; - -/* MB cache flags */ -#define MBE_REUSABLE_B 0 - -#define mb_cache_create(bits) kzalloc(sizeof(struct mb_cache), GFP_KERNEL) -#define mb_cache_destroy(cache) do { kfree(cache); } while (0) -#define mb_cache_entry_find_first(c, h) ((struct mb_cache_entry *)NULL) -#define mb_cache_entry_find_next(c, e) ((struct mb_cache_entry *)NULL) -#define mb_cache_entry_delete_or_get(c, k, v) ((struct mb_cache_entry *)NULL) -#define mb_cache_entry_get(c, k, v) ((struct mb_cache_entry *)NULL) -#define mb_cache_entry_put(c, e) do { (void)(c); (void)(e); } while (0) -#define mb_cache_entry_create(c, f, k, v, r) ({ (void)(c); (void)(f); (void)(k); (void)(v); (void)(r); 0; }) -#define mb_cache_entry_delete(c, k, v) do { (void)(c); (void)(k); (void)(v); } while (0) -#define mb_cache_entry_touch(c, e) do { (void)(c); (void)(e); } while (0) -#define mb_cache_entry_wait_unused(e) do { (void)(e); } while (0) +/* mb_cache - use linux/mbcache.h */ +#include <linux/mbcache.h> /* xattr helper stubs for xattr.c */ #define xattr_handler_can_list(h, d) ({ (void)(h); (void)(d); 0; }) diff --git a/include/linux/mbcache.h b/include/linux/mbcache.h new file mode 100644 index 00000000000..b2383891211 --- /dev/null +++ b/include/linux/mbcache.h @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Metadata block cache definitions for U-Boot + * + * Based on Linux mbcache.h - cache for filesystem metadata blocks. + * U-Boot stubs - metadata caching is not supported. + */ +#ifndef _LINUX_MBCACHE_H +#define _LINUX_MBCACHE_H + +#include <linux/types.h> +#include <linux/slab.h> + +/** + * struct mb_cache - metadata block cache + * + * U-Boot stub - caching not supported. + */ +struct mb_cache { + int dummy; +}; + +/** + * struct mb_cache_entry - cache entry + * @e_value: cached value + * @e_flags: entry flags + */ +struct mb_cache_entry { + u64 e_value; + unsigned long e_flags; +}; + +/* MB cache flags */ +#define MBE_REUSABLE_B 0 + +/* MB cache operations - all stubbed as no-ops */ +#define mb_cache_create(bits) \ + kzalloc(sizeof(struct mb_cache), GFP_KERNEL) +#define mb_cache_destroy(cache) \ + do { kfree(cache); } while (0) +#define mb_cache_entry_find_first(c, h) \ + ((struct mb_cache_entry *)NULL) +#define mb_cache_entry_find_next(c, e) \ + ((struct mb_cache_entry *)NULL) +#define mb_cache_entry_delete_or_get(c, k, v) \ + ((struct mb_cache_entry *)NULL) +#define mb_cache_entry_get(c, k, v) \ + ((struct mb_cache_entry *)NULL) +#define mb_cache_entry_put(c, e) \ + do { (void)(c); (void)(e); } while (0) +#define mb_cache_entry_create(c, f, k, v, r) \ + ({ (void)(c); (void)(f); (void)(k); (void)(v); (void)(r); 0; }) +#define mb_cache_entry_delete(c, k, v) \ + do { (void)(c); (void)(k); (void)(v); } while (0) +#define mb_cache_entry_touch(c, e) \ + do { (void)(c); (void)(e); } while (0) +#define mb_cache_entry_wait_unused(e) \ + do { (void)(e); } while (0) + +#endif /* _LINUX_MBCACHE_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/wait_bit.h with wait_bit_entry structure and wait bit operation stubs. These are no-ops in U-Boot's single-threaded environment. Update ext4_uboot.h to use the new header instead of duplicating these definitions. 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/wait_bit.h | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 include/linux/wait_bit.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index ba90cce3e67..102f03fe002 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -213,7 +213,7 @@ extern struct user_namespace init_user_ns; #define mark_buffer_dirty_inode(bh, i) sync_dirty_buffer(bh) #define mark_buffer_dirty(bh) sync_dirty_buffer(bh) struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); -#define wait_on_bit_io(addr, bit, mode) do { (void)(addr); (void)(bit); (void)(mode); } while (0) +/* wait_on_bit_io is now in linux/wait_bit.h */ /* inode_needs_sync - stub */ #define inode_needs_sync(inode) (0) @@ -1685,20 +1685,8 @@ bool __folio_start_writeback(struct folio *folio, bool keep_write); * Stubs for fast_commit.c */ -/* Wait bit operations - stubbed for single-threaded U-Boot */ -struct wait_bit_entry { - struct list_head wq_entry; -}; -#define DEFINE_WAIT_BIT(name, word, bit) \ - struct wait_bit_entry name = { } -#define bit_waitqueue(word, bit) \ - ({ (void)(word); (void)(bit); (wait_queue_head_t *)NULL; }) -#define prepare_to_wait(wq, wait, state) \ - do { (void)(wq); (void)(wait); (void)(state); } while (0) -#define prepare_to_wait_exclusive(wq, wait, state) \ - do { (void)(wq); (void)(wait); (void)(state); } while (0) -#define finish_wait(wq, wait) \ - do { (void)(wq); (void)(wait); } while (0) +/* Wait bit operations - use linux/wait_bit.h */ +#include <linux/wait_bit.h> /* Dentry name snapshot operations are now in linux/dcache.h */ @@ -1708,8 +1696,7 @@ struct wait_bit_entry { #define REQ_IDLE 0 #define REQ_PREFLUSH 0 -/* wake_up_bit - wake up threads waiting on a bit */ -#define wake_up_bit(word, bit) do { (void)(word); (void)(bit); } while (0) +/* wake_up_bit is now in linux/wait_bit.h */ /* d_alloc, d_drop are now in linux/dcache.h */ diff --git a/include/linux/wait_bit.h b/include/linux/wait_bit.h new file mode 100644 index 00000000000..ace3fbc1763 --- /dev/null +++ b/include/linux/wait_bit.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Wait bit definitions for U-Boot + * + * Based on Linux wait_bit.h - wait on a bit to be cleared/set. + * U-Boot stubs for single-threaded environment. + */ +#ifndef _LINUX_WAIT_BIT_H +#define _LINUX_WAIT_BIT_H + +#include <linux/types.h> +#include <linux/list.h> +#include <linux/wait.h> + +/** + * struct wait_bit_entry - wait queue entry for bit waits + * @wq_entry: wait queue list entry + * + * U-Boot stub - bit waiting not needed in single-threaded environment. + */ +struct wait_bit_entry { + struct list_head wq_entry; +}; + +/* Wait bit macros - all no-ops in single-threaded U-Boot */ +#define DEFINE_WAIT_BIT(name, word, bit) \ + struct wait_bit_entry name = { } + +#define bit_waitqueue(word, bit) \ + ({ (void)(word); (void)(bit); (wait_queue_head_t *)NULL; }) + +#define prepare_to_wait(wq, wait, state) \ + do { (void)(wq); (void)(wait); (void)(state); } while (0) + +#define prepare_to_wait_exclusive(wq, wait, state) \ + do { (void)(wq); (void)(wait); (void)(state); } while (0) + +#define finish_wait(wq, wait) \ + do { (void)(wq); (void)(wait); } while (0) + +#define wake_up_bit(word, bit) \ + do { (void)(word); (void)(bit); } while (0) + +#define wait_on_bit_io(addr, bit, mode) \ + do { (void)(addr); (void)(bit); (void)(mode); } while (0) + +#endif /* _LINUX_WAIT_BIT_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/ratelimit.h with ratelimit_state structure and rate limiting operation stubs. Rate limiting is not needed in U-Boot. Update ext4_uboot.h to use the new header instead of duplicating these definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 19 +++++-------------- include/linux/ratelimit.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 include/linux/ratelimit.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 102f03fe002..f6883d888f4 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -384,10 +384,8 @@ typedef int (get_block_t)(struct inode *inode, sector_t iblock, /* crc32c - from linux/crc32c.h */ #include <linux/crc32c.h> -/* ratelimit_state - stub */ -struct ratelimit_state { - int dummy; -}; +/* ratelimit_state - use linux/ratelimit.h */ +#include <linux/ratelimit.h> /* fscrypt_dummy_policy and qstr are now in ext4_fscrypt.h */ @@ -869,12 +867,7 @@ static inline int in_range(unsigned long val, unsigned long start, /* percpu_counter_init/destroy are in linux/percpu_counter.h */ -/* ratelimit macros */ -#define DEFAULT_RATELIMIT_INTERVAL (5 * 1000) -#define DEFAULT_RATELIMIT_BURST 10 -#define DEFINE_RATELIMIT_STATE(name, interval, burst) \ - int name __attribute__((unused)) = 0 -#define __ratelimit(state) ({ (void)(state); 1; }) +/* ratelimit macros are now in linux/ratelimit.h */ /* SEQ_START_TOKEN is in linux/seq_file.h */ @@ -1364,8 +1357,7 @@ int trylock_buffer(struct buffer_head *bh); /* Trace stubs for super.c - declaration for stub.c implementation */ void trace_ext4_error(struct super_block *sb, const char *func, unsigned int line); -/* Ratelimiting - declaration for stub.c */ -int ___ratelimit(struct ratelimit_state *rs, const char *func); +/* ___ratelimit is now in linux/ratelimit.h */ /* Filesystem notification - declaration for stub.c */ void fsnotify_sb_error(struct super_block *sb, struct inode *inode, int error); @@ -1502,8 +1494,7 @@ static inline void super_set_uuid(struct super_block *sb, const u8 *uuid, /* strreplace is in linux/string.h */ -/* Ratelimit - declaration for stub.c */ -void ratelimit_state_init(void *rs, int interval, int burst); +/* ratelimit_state_init is now in linux/ratelimit.h */ /* Block device operations - declarations for stub.c */ void bdev_fput(void *file); diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h new file mode 100644 index 00000000000..319f794f059 --- /dev/null +++ b/include/linux/ratelimit.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Rate limit definitions for U-Boot + * + * Based on Linux ratelimit.h - rate limiting for messages. + * U-Boot stubs - rate limiting not needed. + */ +#ifndef _LINUX_RATELIMIT_H +#define _LINUX_RATELIMIT_H + +/** + * struct ratelimit_state - rate limiter state + * + * U-Boot stub - rate limiting not supported. + */ +struct ratelimit_state { + int dummy; +}; + +/* Default rate limit parameters */ +#define DEFAULT_RATELIMIT_INTERVAL (5 * 1000) +#define DEFAULT_RATELIMIT_BURST 10 + +/* Define a rate limit state variable */ +#define DEFINE_RATELIMIT_STATE(name, interval, burst) \ + int name __attribute__((unused)) = 0 + +/* Rate limiting operations - all return true (allow) */ +#define __ratelimit(state) ({ (void)(state); 1; }) + +/* Rate limit functions - implemented in stub.c */ +int ___ratelimit(struct ratelimit_state *rs, const char *func); +void ratelimit_state_init(void *rs, int interval, int burst); + +#endif /* _LINUX_RATELIMIT_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Add init_utsname() function to utsname.h for getting the system name. Add proc_ops structure and procfs operation stubs to proc_fs.h. Update ext4_uboot.h to use these headers instead of duplicating the definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 26 +++++--------------------- include/linux/proc_fs.h | 25 +++++++++++++++++++++++++ include/linux/utsname.h | 12 ++++++++++++ 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index f6883d888f4..b5df747b963 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1742,13 +1742,8 @@ int bmap(struct inode *inode, sector_t *block); #define seq_open(f, ops) ({ (void)(f); (void)(ops); 0; }) #define seq_release(i, f) ({ (void)(i); (void)(f); 0; }) -/* proc_ops structure for journal.c */ -struct proc_ops { - int (*proc_open)(struct inode *, struct file *); - ssize_t (*proc_read)(struct file *, char *, size_t, loff_t *); - loff_t (*proc_lseek)(struct file *, loff_t, int); - int (*proc_release)(struct inode *, struct file *); -}; +/* proc_ops - use linux/proc_fs.h */ +#include <linux/proc_fs.h> /* seq_read and seq_lseek declarations (defined in stub.c) */ ssize_t seq_read(struct file *f, char *b, size_t s, loff_t *p); @@ -1756,11 +1751,7 @@ loff_t seq_lseek(struct file *f, loff_t o, int w); /* S_IRUGO is in linux/fs.h */ -/* procfs stubs */ -#define proc_mkdir(name, parent) ({ (void)(name); (void)(parent); (struct proc_dir_entry *)NULL; }) -#define proc_create_data(n, m, p, ops, d) \ - ({ (void)(n); (void)(m); (void)(p); (void)(ops); (void)(d); (struct proc_dir_entry *)NULL; }) -#define remove_proc_entry(n, p) do { (void)(n); (void)(p); } while (0) +/* procfs stubs are now in linux/proc_fs.h */ /* lockdep_init_map and lock_class_key are in linux/lockdep.h */ @@ -1790,15 +1781,8 @@ int bh_read(struct buffer_head *bh, int flags); * Stubs for mmp.c */ -/* init_utsname - returns pointer to system name structure */ -struct new_utsname { - char nodename[65]; -}; -static inline struct new_utsname *init_utsname(void) -{ - static struct new_utsname uts = { .nodename = "u-boot" }; - return &uts; -} +/* init_utsname - use linux/utsname.h */ +#include <linux/utsname.h> /* * Stubs for move_extent.c diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 838321f62bc..ba674440c44 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -9,5 +9,30 @@ /* proc_fs is not used in U-Boot - provide empty stubs */ struct proc_dir_entry; +struct inode; +struct file; + +/** + * struct proc_ops - proc file operations + * @proc_open: open callback + * @proc_read: read callback + * @proc_lseek: seek callback + * @proc_release: release callback + */ +struct proc_ops { + int (*proc_open)(struct inode *, struct file *); + ssize_t (*proc_read)(struct file *, char *, size_t, loff_t *); + loff_t (*proc_lseek)(struct file *, loff_t, int); + int (*proc_release)(struct inode *, struct file *); +}; + +/* procfs stubs - not supported in U-Boot */ +#define proc_mkdir(name, parent) \ + ({ (void)(name); (void)(parent); (struct proc_dir_entry *)NULL; }) +#define proc_create_data(n, m, p, ops, d) \ + ({ (void)(n); (void)(m); (void)(p); (void)(ops); (void)(d); \ + (struct proc_dir_entry *)NULL; }) +#define remove_proc_entry(n, p) \ + do { (void)(n); (void)(p); } while (0) #endif /* _LINUX_PROC_FS_H */ diff --git a/include/linux/utsname.h b/include/linux/utsname.h index 4e1c712ee56..7f77e7e9511 100644 --- a/include/linux/utsname.h +++ b/include/linux/utsname.h @@ -18,4 +18,16 @@ struct uts_namespace { extern struct uts_namespace init_uts_ns; +/** + * init_utsname() - get initial UTS name structure + * + * Return: pointer to static utsname structure + */ +static inline struct new_utsname *init_utsname(void) +{ + static struct new_utsname uts = { .nodename = "u-boot" }; + + return &uts; +} + #endif /* _LINUX_UTSNAME_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/projid.h with kprojid_t type definition and INVALID_PROJID constant for filesystem project quotas. Create linux/mnt_idmapping.h with mnt_idmap structure stub for mount ID mapping. U-Boot does not support ID mapping, so this provides only the nop_mnt_idmap reference. Update ext4_uboot.h to use these headers instead of duplicating the definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 18 ++++----------- include/linux/mnt_idmapping.h | 23 +++++++++++++++++++ include/linux/projid.h | 43 +++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 include/linux/mnt_idmapping.h create mode 100644 include/linux/projid.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index b5df747b963..4bc25b73f76 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -105,12 +105,8 @@ #include <linux/percpu_counter.h> #include <linux/percpu.h> -/* Project ID type */ -typedef struct { unsigned int val; } kprojid_t; - -#define make_kprojid(ns, id) ((kprojid_t){ .val = (id) }) -#define from_kprojid(ns, kprojid) ((kprojid).val) -#define projid_eq(a, b) ((a).val == (b).val) +/* Project ID type - use linux/projid.h */ +#include <linux/projid.h> /* kobject is now in linux/kobject.h */ #include <linux/kobject.h> @@ -421,11 +417,8 @@ typedef long long qsize_t; /* DT_* directory entry types are in linux/fs.h */ -/* mnt_idmap - stub */ -struct mnt_idmap { - int dummy; -}; -extern struct mnt_idmap nop_mnt_idmap; +/* mnt_idmap - use linux/mnt_idmapping.h */ +#include <linux/mnt_idmapping.h> /* fstrim_range - stub */ struct fstrim_range { @@ -900,8 +893,7 @@ void folio_put(struct folio *folio); void folio_get(struct folio *folio); void mapping_clear_folio_cache(struct address_space *mapping); -/* projid_t - project ID type */ -typedef unsigned int projid_t; +/* projid_t is now in linux/projid.h */ /* * Additional stubs for inode.c diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h new file mode 100644 index 00000000000..3f4e35951da --- /dev/null +++ b/include/linux/mnt_idmapping.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Mount ID mapping definitions for U-Boot + * + * Based on Linux mnt_idmapping.h - user ID mapping for mounts. + * U-Boot stub - ID mapping not supported. + */ +#ifndef _LINUX_MNT_IDMAPPING_H +#define _LINUX_MNT_IDMAPPING_H + +/** + * struct mnt_idmap - mount ID mapping + * + * U-Boot stub - ID mapping not used. + */ +struct mnt_idmap { + int dummy; +}; + +/* Global no-op ID map */ +extern struct mnt_idmap nop_mnt_idmap; + +#endif /* _LINUX_MNT_IDMAPPING_H */ diff --git a/include/linux/projid.h b/include/linux/projid.h new file mode 100644 index 00000000000..d736630a957 --- /dev/null +++ b/include/linux/projid.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Project ID definitions for U-Boot + * + * Based on Linux projid.h - filesystem project IDs for quotas. + */ +#ifndef _LINUX_PROJID_H +#define _LINUX_PROJID_H + +/** + * typedef kprojid_t - kernel project ID + * + * Wrapper type for project IDs used in filesystem quotas. + */ +typedef struct { unsigned int val; } kprojid_t; + +/** + * typedef projid_t - user-space project ID + */ +typedef unsigned int projid_t; + +/** + * make_kprojid() - create a kernel project ID + * @ns: user namespace (ignored in U-Boot) + * @id: project ID value + */ +#define make_kprojid(ns, id) ((kprojid_t){ .val = (id) }) + +/** + * from_kprojid() - extract project ID value + * @ns: user namespace (ignored in U-Boot) + * @kprojid: kernel project ID + */ +#define from_kprojid(ns, kprojid) ((kprojid).val) + +/** + * projid_eq() - compare two project IDs + * @a: first project ID + * @b: second project ID + */ +#define projid_eq(a, b) ((a).val == (b).val) + +#endif /* _LINUX_PROJID_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/hash.h with hash_64() and hash_32() hash functions. Update ext4_uboot.h to use the new header instead of duplicating the hash_64 definition. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 6 +++--- include/linux/hash.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 include/linux/hash.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4bc25b73f76..b861079bf48 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -901,8 +901,8 @@ void mapping_clear_folio_cache(struct address_space *mapping); /* try_cmpxchg is now in asm-generic/atomic.h */ -/* hash_64 - simple 64-bit hash */ -#define hash_64(val, bits) ((unsigned long)((val) >> (64 - (bits)))) +/* hash_64 - use linux/hash.h */ +#include <linux/hash.h> /* Dentry operations are now in linux/dcache.h */ #define finish_open_simple(f, e) (e) @@ -1820,7 +1820,7 @@ int ext4_update_overhead(struct super_block *sb, bool force); /* fsmap is now in linux/fsmap.h */ #include <linux/fsmap.h> -/* list_sort and sort stubs for fsmap.c */ +/* list_sort and sort stubs for fsmap.c - not used in U-Boot */ #define list_sort(priv, head, cmp) \ do { (void)(priv); (void)(head); (void)(cmp); } while (0) #define sort(base, num, size, cmp, swap) \ diff --git a/include/linux/hash.h b/include/linux/hash.h new file mode 100644 index 00000000000..276619ca310 --- /dev/null +++ b/include/linux/hash.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Hash functions for U-Boot + * + * Based on Linux hash.h - fast hashing routines. + */ +#ifndef _LINUX_HASH_H +#define _LINUX_HASH_H + +#include <linux/types.h> + +/** + * hash_64() - 64-bit hash function + * @val: value to hash + * @bits: number of bits in result + * + * Simple hash by shifting. In Linux this uses multiplication by a + * golden ratio constant, but for U-Boot a simple shift suffices. + * + * Return: hash value with @bits significant bits + */ +#define hash_64(val, bits) ((unsigned long)((val) >> (64 - (bits)))) + +/** + * hash_32() - 32-bit hash function + * @val: value to hash + * @bits: number of bits in result + * + * Return: hash value with @bits significant bits + */ +#define hash_32(val, bits) ((unsigned int)((val) >> (32 - (bits)))) + +#endif /* _LINUX_HASH_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/blockgroup_lock.h with blockgroup_lock structure and lock operation stubs. Create linux/delayed_call.h with delayed_call structure and set_delayed_call() macro for deferred function calls. Update ext4_uboot.h to use these headers instead of duplicating the definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 25 ++++----------- include/linux/blockgroup_lock.h | 25 +++++++++++++++ include/linux/delayed_call.h | 56 +++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 19 deletions(-) create mode 100644 include/linux/blockgroup_lock.h create mode 100644 include/linux/delayed_call.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index b861079bf48..3c6b3ca5507 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -305,8 +305,7 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode, /* atomic_add_unless is now in asm-generic/atomic.h */ -/* Block group lock - stub */ -#define bgl_lock_ptr(lock, group) NULL +/* bgl_lock_ptr is now in linux/blockgroup_lock.h */ /* RCU stubs - use linux/rcupdate.h */ #include <linux/rcupdate.h> @@ -1107,17 +1106,8 @@ struct file_operations { int (*release)(struct inode *, struct file *); }; -/* delayed_call - for delayed freeing of symlink data */ -typedef void (*delayed_call_func_t)(const void *); -struct delayed_call { - delayed_call_func_t fn; - const void *arg; -}; - -#define set_delayed_call(dc, func, data) do { \ - (dc)->fn = (func); \ - (dc)->arg = (data); \ -} while (0) +/* delayed_call - use linux/delayed_call.h */ +#include <linux/delayed_call.h> #define kfree_link kfree @@ -1335,10 +1325,8 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate); /* Max file size for large files */ #define MAX_LFS_FILESIZE ((loff_t)LLONG_MAX) -/* blockgroup_lock for per-group locking */ -struct blockgroup_lock { - int num_locks; /* U-Boot doesn't need real locking */ -}; +/* blockgroup_lock - use linux/blockgroup_lock.h */ +#include <linux/blockgroup_lock.h> /* Buffer submission stubs - declarations for stub.c implementations */ int submit_bh(int op_flags, struct buffer_head *bh); @@ -1444,8 +1432,7 @@ int generic_check_addressable(unsigned int blocksize_bits, u64 num_blocks); u64 sb_bdev_nr_blocks(struct super_block *sb); unsigned int bdev_max_discard_sectors(struct block_device *bdev); -/* Blockgroup lock init - stub */ -#define bgl_lock_init(lock) do { } while (0) +/* bgl_lock_init is now in linux/blockgroup_lock.h */ /* Task I/O priority - declaration for stub.c */ void set_task_ioprio(void *task, int ioprio); diff --git a/include/linux/blockgroup_lock.h b/include/linux/blockgroup_lock.h new file mode 100644 index 00000000000..13b51ba0e57 --- /dev/null +++ b/include/linux/blockgroup_lock.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Block group lock definitions for U-Boot + * + * Based on Linux blockgroup_lock.h - per-block-group locking. + * U-Boot stub - locking not needed in single-threaded environment. + */ +#ifndef _LINUX_BLOCKGROUP_LOCK_H +#define _LINUX_BLOCKGROUP_LOCK_H + +/** + * struct blockgroup_lock - per-block-group lock + * @num_locks: number of locks (unused in U-Boot) + * + * U-Boot stub - real locking not needed. + */ +struct blockgroup_lock { + int num_locks; +}; + +/* Block group lock operations - all no-ops */ +#define bgl_lock_init(lock) do { } while (0) +#define bgl_lock_ptr(lock, group) ((spinlock_t *)NULL) + +#endif /* _LINUX_BLOCKGROUP_LOCK_H */ diff --git a/include/linux/delayed_call.h b/include/linux/delayed_call.h new file mode 100644 index 00000000000..d4248dce742 --- /dev/null +++ b/include/linux/delayed_call.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Delayed call definitions for U-Boot + * + * Based on Linux delayed_call.h - deferred function calls. + */ +#ifndef _LINUX_DELAYED_CALL_H +#define _LINUX_DELAYED_CALL_H + +/** + * typedef delayed_call_func_t - delayed call function type + */ +typedef void (*delayed_call_func_t)(const void *); + +/** + * struct delayed_call - delayed function call + * @fn: function to call + * @arg: argument to pass to function + */ +struct delayed_call { + delayed_call_func_t fn; + const void *arg; +}; + +/** + * set_delayed_call() - set up a delayed call + * @dc: delayed call structure + * @func: function to call + * @data: data to pass to function + */ +#define set_delayed_call(dc, func, data) do { \ + (dc)->fn = (func); \ + (dc)->arg = (data); \ +} while (0) + +/** + * do_delayed_call() - execute a delayed call + * @dc: delayed call structure + */ +static inline void do_delayed_call(struct delayed_call *dc) +{ + if (dc->fn) + dc->fn(dc->arg); +} + +/** + * clear_delayed_call() - clear a delayed call + * @dc: delayed call structure + */ +static inline void clear_delayed_call(struct delayed_call *dc) +{ + dc->fn = NULL; + dc->arg = NULL; +} + +#endif /* _LINUX_DELAYED_CALL_H */ -- 2.43.0
participants (1)
-
Simon Glass