[Concept,10/26] fs: ext4l: Use types from linux headers

Message ID 20251222115639.700578-11-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>

Update ext4_uboot.h to include the new linux headers instead of
defining types locally. Remove duplicate definitions of:
- MAX_JIFFY_OFFSET (now in linux/jiffies.h)
- BDEVNAME_SIZE (now in linux/blkdev.h)
- rwlock_t (now in linux/spinlock.h)

Remove rwlock_init() stub from stub.c since it's now a macro.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 fs/ext4l/ext4_uboot.h | 23 +++++++----------------
 fs/ext4l/stub.c       |  8 ++++----
 2 files changed, 11 insertions(+), 20 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index d0e60c02d77..1f823ba6ea3 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -58,14 +58,12 @@  struct timespec64 {
 /*
  * ktime_t, sector_t are in linux/types.h
  * atomic_t, atomic64_t are in asm-generic/atomic.h
+ * MAX_JIFFY_OFFSET is in linux/jiffies.h
+ * BDEVNAME_SIZE is in linux/blkdev.h
  */
 #include <asm-generic/atomic.h>
-
-/* Jiffy constants */
-#define MAX_JIFFY_OFFSET	((~0UL >> 1) - 1)
-
-/* Block device name size */
-#define BDEVNAME_SIZE		32
+#include <linux/jiffies.h>
+#include <linux/blkdev.h>
 
 /* Extra atomic operations not in asm-generic/atomic.h */
 #define atomic_dec_if_positive(v)	(--(v)->counter)
@@ -86,14 +84,8 @@  struct timespec64 {
 /* Reference count type */
 typedef struct { atomic_t refs; } refcount_t;
 
-/* Lock types - stubs for single-threaded U-Boot */
-typedef int rwlock_t;
-/* spinlock_t is defined in linux/compat.h */
-
-#define read_lock(l)		do { } while (0)
-#define read_unlock(l)		do { } while (0)
-#define write_lock(l)		do { } while (0)
-#define write_unlock(l)		do { } while (0)
+/* rwlock_t and read_lock/read_unlock are now in linux/spinlock.h */
+#include <linux/spinlock.h>
 
 /* RB tree types - stubs */
 struct rb_node {
@@ -2202,8 +2194,7 @@  void *alloc_inode_sb(struct super_block *sb, struct kmem_cache *cache,
 void inode_set_iversion(struct inode *inode, u64 version);
 int inode_generic_drop(struct inode *inode);
 
-/* Lock init - declaration for stub.c */
-void rwlock_init(rwlock_t *lock);
+/* rwlock_init is a macro in linux/spinlock.h */
 
 /* Trace stubs */
 #define trace_ext4_drop_inode(i, d)		do { } while (0)
diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c
index 93315d10fa8..e13685bf8fa 100644
--- a/fs/ext4l/stub.c
+++ b/fs/ext4l/stub.c
@@ -2,6 +2,9 @@ 
 /*
  * Stub functions for ext4l filesystem
  *
+ * Copyright 2025 Canonical Ltd
+ * Written by Simon Glass <simon.glass@canonical.com>
+ *
  * These stubs allow the ext4l code to link during development while not all
  * source files are present. They will be removed once the full ext4l
  * implementation is complete.
@@ -352,10 +355,7 @@  void inode_set_iversion(struct inode *inode, u64 version)
 {
 }
 
-/* rwlock stubs */
-void rwlock_init(rwlock_t *lock)
-{
-}
+/* rwlock_init is now a macro in linux/spinlock.h */
 
 /* trace_ext4_drop_inode is now a macro in ext4_uboot.h */