[Concept,09/26] linux: Add rwlock support to spinlock.h

Message ID 20251222115639.700578-10-sjg@u-boot.org
State New
Headers
Series fs: ext4l: Add support for mounting ext4 filesystems (part G) |

Commit Message

Simon Glass Dec. 22, 2025, 11:56 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Add rwlock_t type and read/write lock operation stubs to spinlock.h.
These are no-ops for single-threaded U-Boot but provide the API
needed by Linux-derived code.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 include/linux/spinlock.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
  

Patch

diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 906766931b4..75afad92b9e 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -78,4 +78,25 @@  typedef struct {
 /* Assert variants */
 #define assert_spin_locked(lock)		do { } while (0)
 
+/* Read-write lock type - just an int for U-Boot */
+typedef int rwlock_t;
+
+#define __RW_LOCK_UNLOCKED(lockname)		(0)
+#define DEFINE_RWLOCK(x)			rwlock_t x = __RW_LOCK_UNLOCKED(x)
+
+/* Read-write lock operations - all no-ops for single-threaded U-Boot */
+#define rwlock_init(lock)			do { } while (0)
+#define read_lock(lock)				do { } while (0)
+#define read_unlock(lock)			do { } while (0)
+#define write_lock(lock)			do { } while (0)
+#define write_unlock(lock)			do { } while (0)
+#define read_lock_irq(lock)			do { } while (0)
+#define read_unlock_irq(lock)			do { } while (0)
+#define write_lock_irq(lock)			do { } while (0)
+#define write_unlock_irq(lock)			do { } while (0)
+#define read_lock_irqsave(lock, flags)		do { (void)(flags); } while (0)
+#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)
+
 #endif /* __LINUX_SPINLOCK_H */