From patchwork Tue Jan 20 23:43:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1725 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768952727; bh=5YRzoP5r9N/Fyt1dktPmnTIqK7iv+X79TbGy1O13s04=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=fKDOOgNAffJP+W8ttVuKU95DyoAFtQyYELCbscdETjjETO/7LeKDn4kxbA/EalsCK 3xaY26Kp2If0CitneaF2sCyTzSVz844xk4iM6uJr2hZAkYFZu4CqZzSwSDNKTriXlV NzozkQ/rjf/dLXSzrA5etn5plBbGRx14DkGWp2j6W3zVYN85ESSGf+AuU8LpvC29z1 kLn2kGWLgOvA4+vK1JQEbojW+E6nKg512EeBTOOs0d3b899CtbHGmO2fv0nD/Tikmp eNir+F/Yw40MmrjzHUsf6JxV4sfp94QVh4mG77yUEyHT4VVb05qPffAICXxQaVMa7U 3qOTXI42RpQ/Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 26F10695A6 for ; Tue, 20 Jan 2026 16:45:27 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id psQUu0ZBtp4T for ; Tue, 20 Jan 2026 16:45:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768952725; bh=5YRzoP5r9N/Fyt1dktPmnTIqK7iv+X79TbGy1O13s04=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=oWEiDBxPAk9aCf3QAg6w8iI4GCp5bzI//9BnScU8sE3RebS2yXiAtKmLQS2pm/z4k bONldlb4KBAd8qguhlVQJI9tZdguMP4fHp10BJxhdoTvBj9VNKJO63khnigpfUC/hA N6ibmks/00hjDvsxoAOc67LGUk3ZrRpsFq5WLGPtifZSCyLRZzEm1kG2T4XGQSPfEw GscUC/dP9cnVq01SiGaJ4ZQCLOGiHoj/Z/dD7W+qS1j+i86tsPtoSDcdKsBnBa6xde q7GSjSx/F4xSett8XTwb6Qod+F6tngIN/nPUQQjzRRH8jD/Y2kYSs0TC0NY9smHDbF Zx5KE23ShShPw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1298E69597 for ; Tue, 20 Jan 2026 16:45:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768952724; bh=1xSYUFnpb4GXNzjhNqGj8vKznO/DXnC2utl0FKg0Nfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VuZIV1alZj+GdZE7umsJJL4eFfWMk/A7Eg2n1Y7I6ih9ufNkgqBBWblR96an9/S6C wlRRcaTI0fbmg9wk0iyT1Xqo/o21qNBcFupQRQGERsFXemlmt9pmImhdMddjM6Pb8n Uvk7iIho1fc7uUU5QvorEWMxF4ZlubZMhY35i9zDJ//tVGHruTGfC0gl6pcD/51SoF +XYa1TVSgibH1tF46+HZ4liULbAvufq9cmrDOTazcGaoUWVPzY6VvrxnbylsThABPo g8Cp7yUuxgc5REyxMQabVBLKn+QPUJEfGKWSnIVentW68f/iLNINRh7d1UYRUORcul zig9ev7imBhzA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3CC4869597; Tue, 20 Jan 2026 16:45:24 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 4vsqlrM-Mso7; Tue, 20 Jan 2026 16:45:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768952723; bh=Eu2jdpaisBKmNxp22bskfYpxcLS2lGvKCbQYs2gUrt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bIw0vdAcSzwV82is44YgsU7PyzhBlqlHiANbpm2MK2KiUcOjc55dT7A2XFS9z4h+n xr6XX9OqOGXkm7QdzwqUhZnEKgV+uzIVUUO67ojazrAahjiu6HOjXIA7DI3LlZBumL pSueP1dUkNoXc+99tX9yrUdX2JG/uOB7YekPxRpytEmqEDwo5DLoXVeYz+mxeBeQpq GFuPAxQ5tuf3yUCywXye+2lHFFh3G15KR7phMytznjNX3XgjFsuo6QeX21JaCv8YvN aEnWWhzUp9WBBGGgryLDZLxZcCNbNjCUiyDHdiQtJwfGsiYUCs059ZUeA3CLBXGYtg fcxq/3iczOSYA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9A7A469555; Tue, 20 Jan 2026 16:45:23 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:43:36 -0700 Message-ID: <20260120234344.495605-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260120234344.495605-1-sjg@u-boot.org> References: <20260120234344.495605-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: IAB3IJ3SIVC6OHSSRRVGOSIHXMQ5IVSY X-Message-ID-Hash: IAB3IJ3SIVC6OHSSRRVGOSIHXMQ5IVSY X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/17] ext4l: Move lock bit operations to asm-generic/bitops/lock.h List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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 Signed-off-by: Simon Glass --- 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 -/* 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 /* 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 + +/** + * 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 */