From: Simon Glass <simon.glass@canonical.com> Create a new linux/lockdep.h header to consolidate all the scattered lockdep stubs from ext4_uboot.h. This includes lock_class_key, lockdep_map, and all the lockdep assertion macros. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 22 ++++++---------------- include/linux/lockdep.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 include/linux/lockdep.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4c214fa5bdc..ce40888879e 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -123,11 +123,7 @@ struct kobject { }; /* lockdep stubs - needed before jbd2.h is included */ -struct lockdep_map { int dummy; }; -struct lock_class_key { int dummy; }; -#define rwsem_acquire(l, s, t, i) do { } while (0) -#define rwsem_acquire_read(l, s, t, i) do { } while (0) -#define rwsem_release(l, i) do { } while (0) +#include <linux/lockdep.h> #define _THIS_IP_ ((unsigned long)0) /* completion - use Linux header */ @@ -388,8 +384,7 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode, /* RCU head for callbacks - defined in linux/compat.h as callback_head */ -/* lockdep stubs */ -#define lockdep_is_held(lock) (1) +/* lockdep_is_held is in linux/lockdep.h */ /* Memory allocation - use linux/slab.h which is already available */ #include <linux/slab.h> @@ -938,8 +933,7 @@ struct dx_hash_info { /* WARN_ON, WARN_ON_ONCE, WARN_ONCE are in linux/bug.h */ /* pr_warn_once is in linux/printk.h */ -/* lockdep stubs */ -#define lockdep_assert_held_read(l) do { (void)(l); } while (0) +/* lockdep_assert_held_read is in linux/lockdep.h */ /* strtomem_pad - copy string to fixed-size buffer with padding */ #define strtomem_pad(dest, src, pad) do { \ @@ -987,9 +981,7 @@ static inline unsigned long memweight(const void *ptr, size_t bytes) #define inode_trylock_shared(inode) (1) #define inode_dio_wait(inode) do { } while (0) -/* Lock debugging - no-ops in U-Boot */ -#define lockdep_assert_held_write(l) do { } while (0) -#define lockdep_assert_held(l) do { } while (0) +/* Lock debugging stubs are in linux/lockdep.h */ /* File operations */ #define file_modified(file) ({ (void)(file); 0; }) @@ -2502,8 +2494,7 @@ struct wait_bit_entry { #define release_dentry_name_snapshot(snap) \ do { (void)(snap); } while (0) -/* lockdep stubs */ -#define lockdep_assert_not_held(lock) do { (void)(lock); } while (0) +/* lockdep_assert_not_held is in linux/lockdep.h */ /* Request flags for block I/O */ #define REQ_IDLE 0 @@ -2591,8 +2582,7 @@ loff_t seq_lseek(struct file *f, loff_t o, int w); ({ (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) -/* lockdep stubs (struct lock_class_key defined earlier) */ -#define lockdep_init_map(...) do { } while (0) +/* lockdep_init_map and lock_class_key are in linux/lockdep.h */ /* Block device operations for journal.c */ int bh_read(struct buffer_head *bh, int flags); diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h new file mode 100644 index 00000000000..e95b6d171ad --- /dev/null +++ b/include/linux/lockdep.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Lock dependency validator stubs for U-Boot + * + * U-Boot is single-threaded, so lock dependency checking is not needed. + * These stubs allow Linux kernel code to compile unchanged. + */ +#ifndef _LINUX_LOCKDEP_H +#define _LINUX_LOCKDEP_H + +/* Lock class key - used for lockdep annotations */ +struct lock_class_key { + int dummy; +}; + +/* Lockdep map - used for lock tracking */ +struct lockdep_map { + int dummy; +}; + +/* Lockdep assertion macros - all no-ops in U-Boot */ +#define lockdep_is_held(lock) (1) +#define lockdep_assert_held(lock) do { (void)(lock); } while (0) +#define lockdep_assert_held_read(lock) do { (void)(lock); } while (0) +#define lockdep_assert_held_write(lock) do { (void)(lock); } while (0) +#define lockdep_assert_not_held(lock) do { (void)(lock); } while (0) + +/* Lockdep initialisation and tracking - no-ops */ +#define lockdep_init_map(...) do { } while (0) + +/* RW semaphore lockdep stubs */ +#define rwsem_acquire(l, s, t, i) do { } while (0) +#define rwsem_acquire_read(l, s, t, i) do { } while (0) +#define rwsem_release(l, i) do { } while (0) + +#endif /* _LINUX_LOCKDEP_H */ -- 2.43.0