[Concept,14/34] ext4l: Move buffer operation stubs to linux/buffer_head.h

Message ID 20260114225635.3407989-15-sjg@u-boot.org
State New
Headers
Series ext4l: Clean up ext4_uboot.h by moving definitions to standard headers |

Commit Message

Simon Glass Jan. 14, 2026, 10:56 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Move simple buffer operation stubs to include/linux/buffer_head.h where
they belong. These operations are no-ops in single-threaded U-Boot:

- wait_on_buffer: no waiting needed
- __bforget: no buffer cache to forget from
- lock_buffer: uses set_buffer_locked (already in header)
- unlock_buffer: uses clear_buffer_locked (already in header)
- test_clear_buffer_dirty: always returns 0

The mark_buffer_dirty macros remain in ext4_uboot.h as they depend on
sync_dirty_buffer which is defined later in ext4l.

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

 fs/ext4l/ext4_uboot.h       | 7 +------
 include/linux/buffer_head.h | 9 +++++++++
 2 files changed, 10 insertions(+), 6 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index e09f5c31ebe..9329d854bd3 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -260,15 +260,10 @@  extern struct user_namespace init_user_ns;
 
 /* Trace stubs are now in ext4_trace.h */
 
-/* Buffer operations - stubs */
-#define wait_on_buffer(bh)		do { } while (0)
-#define __bforget(bh)			do { } while (0)
+/* Buffer operations - wait_on_buffer, lock_buffer, unlock_buffer etc are in linux/buffer_head.h */
 #define mark_buffer_dirty_inode(bh, i)	sync_dirty_buffer(bh)
 #define mark_buffer_dirty(bh)		sync_dirty_buffer(bh)
-#define lock_buffer(bh)			set_buffer_locked(bh)
-#define unlock_buffer(bh)		clear_buffer_locked(bh)
 struct buffer_head *sb_getblk(struct super_block *sb, sector_t block);
-#define test_clear_buffer_dirty(bh)	({ (void)(bh); 0; })
 #define wait_on_bit_io(addr, bit, mode)	do { (void)(addr); (void)(bit); (void)(mode); } while (0)
 
 /* inode_needs_sync - stub */
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index b22df564119..94bd2bab96a 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -177,4 +177,13 @@  static inline void put_bh(struct buffer_head *bh)
 void brelse(struct buffer_head *bh);
 void __brelse(struct buffer_head *bh);
 
+/*
+ * Buffer operation stubs - U-Boot is single-threaded
+ */
+#define wait_on_buffer(bh)		do { } while (0)
+#define __bforget(bh)			do { } while (0)
+#define lock_buffer(bh)			set_buffer_locked(bh)
+#define unlock_buffer(bh)		clear_buffer_locked(bh)
+#define test_clear_buffer_dirty(bh)	({ (void)(bh); 0; })
+
 #endif /* _LINUX_BUFFER_HEAD_H */