[Concept,12/12] linux: Add blockgroup_lock.h and delayed_call.h headers
Commit Message
From: Simon Glass <simon.glass@canonical.com>
Create linux/blockgroup_lock.h with blockgroup_lock structure and
lock operation stubs.
Create linux/delayed_call.h with delayed_call structure and
set_delayed_call() macro for deferred function calls.
Update ext4_uboot.h to use these headers instead of duplicating the
definitions.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
fs/ext4l/ext4_uboot.h | 25 ++++-----------
include/linux/blockgroup_lock.h | 25 +++++++++++++++
include/linux/delayed_call.h | 56 +++++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+), 19 deletions(-)
create mode 100644 include/linux/blockgroup_lock.h
create mode 100644 include/linux/delayed_call.h
@@ -305,8 +305,7 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode,
/* atomic_add_unless is now in asm-generic/atomic.h */
-/* Block group lock - stub */
-#define bgl_lock_ptr(lock, group) NULL
+/* bgl_lock_ptr is now in linux/blockgroup_lock.h */
/* RCU stubs - use linux/rcupdate.h */
#include <linux/rcupdate.h>
@@ -1107,17 +1106,8 @@ struct file_operations {
int (*release)(struct inode *, struct file *);
};
-/* delayed_call - for delayed freeing of symlink data */
-typedef void (*delayed_call_func_t)(const void *);
-struct delayed_call {
- delayed_call_func_t fn;
- const void *arg;
-};
-
-#define set_delayed_call(dc, func, data) do { \
- (dc)->fn = (func); \
- (dc)->arg = (data); \
-} while (0)
+/* delayed_call - use linux/delayed_call.h */
+#include <linux/delayed_call.h>
#define kfree_link kfree
@@ -1335,10 +1325,8 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate);
/* Max file size for large files */
#define MAX_LFS_FILESIZE ((loff_t)LLONG_MAX)
-/* blockgroup_lock for per-group locking */
-struct blockgroup_lock {
- int num_locks; /* U-Boot doesn't need real locking */
-};
+/* blockgroup_lock - use linux/blockgroup_lock.h */
+#include <linux/blockgroup_lock.h>
/* Buffer submission stubs - declarations for stub.c implementations */
int submit_bh(int op_flags, struct buffer_head *bh);
@@ -1444,8 +1432,7 @@ int generic_check_addressable(unsigned int blocksize_bits, u64 num_blocks);
u64 sb_bdev_nr_blocks(struct super_block *sb);
unsigned int bdev_max_discard_sectors(struct block_device *bdev);
-/* Blockgroup lock init - stub */
-#define bgl_lock_init(lock) do { } while (0)
+/* bgl_lock_init is now in linux/blockgroup_lock.h */
/* Task I/O priority - declaration for stub.c */
void set_task_ioprio(void *task, int ioprio);
new file mode 100644
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Block group lock definitions for U-Boot
+ *
+ * Based on Linux blockgroup_lock.h - per-block-group locking.
+ * U-Boot stub - locking not needed in single-threaded environment.
+ */
+#ifndef _LINUX_BLOCKGROUP_LOCK_H
+#define _LINUX_BLOCKGROUP_LOCK_H
+
+/**
+ * struct blockgroup_lock - per-block-group lock
+ * @num_locks: number of locks (unused in U-Boot)
+ *
+ * U-Boot stub - real locking not needed.
+ */
+struct blockgroup_lock {
+ int num_locks;
+};
+
+/* Block group lock operations - all no-ops */
+#define bgl_lock_init(lock) do { } while (0)
+#define bgl_lock_ptr(lock, group) ((spinlock_t *)NULL)
+
+#endif /* _LINUX_BLOCKGROUP_LOCK_H */
new file mode 100644
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Delayed call definitions for U-Boot
+ *
+ * Based on Linux delayed_call.h - deferred function calls.
+ */
+#ifndef _LINUX_DELAYED_CALL_H
+#define _LINUX_DELAYED_CALL_H
+
+/**
+ * typedef delayed_call_func_t - delayed call function type
+ */
+typedef void (*delayed_call_func_t)(const void *);
+
+/**
+ * struct delayed_call - delayed function call
+ * @fn: function to call
+ * @arg: argument to pass to function
+ */
+struct delayed_call {
+ delayed_call_func_t fn;
+ const void *arg;
+};
+
+/**
+ * set_delayed_call() - set up a delayed call
+ * @dc: delayed call structure
+ * @func: function to call
+ * @data: data to pass to function
+ */
+#define set_delayed_call(dc, func, data) do { \
+ (dc)->fn = (func); \
+ (dc)->arg = (data); \
+} while (0)
+
+/**
+ * do_delayed_call() - execute a delayed call
+ * @dc: delayed call structure
+ */
+static inline void do_delayed_call(struct delayed_call *dc)
+{
+ if (dc->fn)
+ dc->fn(dc->arg);
+}
+
+/**
+ * clear_delayed_call() - clear a delayed call
+ * @dc: delayed call structure
+ */
+static inline void clear_delayed_call(struct delayed_call *dc)
+{
+ dc->fn = NULL;
+ dc->arg = NULL;
+}
+
+#endif /* _LINUX_DELAYED_CALL_H */