[Concept,09/26] linux: Add rwlock support to spinlock.h
Commit Message
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(+)
@@ -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 */