From: Simon Glass <simon.glass@canonical.com> Create asm-generic/bitops/lock.h with clear_bit_unlock() and test_and_set_bit_lock() stubs, matching the Linux kernel's location. Move write_trylock() to linux/spinlock.h where the Linux kernel defines it. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 9 ++++----- include/asm-generic/bitops/lock.h | 30 ++++++++++++++++++++++++++++++ include/linux/spinlock.h | 1 + 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 include/asm-generic/bitops/lock.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 5ab32cba969..7d1704945a3 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -669,8 +669,7 @@ struct dx_hash_info { /* hrtimer - use linux/hrtimer.h */ #include <linux/hrtimer.h> -/* write lock variants */ -#define write_trylock(lock) ({ (void)(lock); 1; }) +/* write_trylock is in linux/spinlock.h */ /* percpu_counter_init/destroy are in linux/percpu_counter.h */ @@ -1291,7 +1290,8 @@ struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned /* spin_needbreak is in linux/spinlock.h */ /* JBD2 commit.c stubs (folio_trylock is in linux/pagemap.h) */ -#define clear_bit_unlock(nr, addr) clear_bit(nr, addr) +/* clear_bit_unlock is in asm-generic/bitops/lock.h */ +#include <asm-generic/bitops/lock.h> /* smp_mb__after_atomic is now in linux/smp.h */ #define ktime_get_coarse_real_ts64(ts) do { (ts)->tv_sec = 0; (ts)->tv_nsec = 0; } while (0) #define filemap_fdatawait_range_keep_errors(m, s, e) \ @@ -1391,8 +1391,7 @@ loff_t seq_lseek(struct file *f, loff_t o, int w); * Stubs for resize.c */ -/* test_and_set_bit_lock - test and set a bit atomically */ -#define test_and_set_bit_lock(nr, addr) test_and_set_bit(nr, addr) +/* test_and_set_bit_lock is in asm-generic/bitops/lock.h */ /* time_is_before_jiffies - check if time is before current jiffies */ #define time_is_before_jiffies(a) ({ (void)(a); 0; }) diff --git a/include/asm-generic/bitops/lock.h b/include/asm-generic/bitops/lock.h new file mode 100644 index 00000000000..34fe437b1f1 --- /dev/null +++ b/include/asm-generic/bitops/lock.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Locking bit operations + * + * U-Boot stub - single-threaded, no actual locking needed. + */ +#ifndef _ASM_GENERIC_BITOPS_LOCK_H +#define _ASM_GENERIC_BITOPS_LOCK_H + +#include <linux/bitops.h> + +/** + * clear_bit_unlock - clear a bit with release semantics + * @nr: bit number to clear + * @addr: address of the bitmap + * + * U-Boot stub - just calls clear_bit() since we're single-threaded. + */ +#define clear_bit_unlock(nr, addr) clear_bit(nr, addr) + +/** + * test_and_set_bit_lock - test and set a bit with acquire semantics + * @nr: bit number to test and set + * @addr: address of the bitmap + * + * U-Boot stub - just calls test_and_set_bit() since we're single-threaded. + */ +#define test_and_set_bit_lock(nr, addr) test_and_set_bit(nr, addr) + +#endif /* _ASM_GENERIC_BITOPS_LOCK_H */ diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 09fe285dfed..d938cd69d2b 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -101,5 +101,6 @@ typedef int rwlock_t; #define read_unlock_irqrestore(lock, flags) do { (void)(flags); } while (0) #define write_lock_irqsave(lock, flags) do { (void)(flags); } while (0) #define write_unlock_irqrestore(lock, flags) do { (void)(flags); } while (0) +#define write_trylock(lock) ({ (void)(lock); 1; }) #endif /* __LINUX_SPINLOCK_H */ -- 2.43.0