[Concept,08/26] ext4l: Move message buffer functions to support.c

Message ID 20251231223008.3251711-9-sjg@u-boot.org
State New
Headers
Series ext4l: Add write support (part L) |

Commit Message

Simon Glass Dec. 31, 2025, 10:29 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Move the message buffer functions from interface.c to support.c since
they are internal support code rather than filesystem-interface
functions. This keeps interface.c focused on functions called from the
U-Boot filesystem layer.

Functions moved:
- ext4l_msg_init()
- ext4l_record_msg()
- ext4l_get_msg_buf()
- ext4l_print_msgs()

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

 fs/ext4l/ext4_uboot.h |  6 +++--
 fs/ext4l/interface.c  | 51 -------------------------------------------
 fs/ext4l/support.c    | 51 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 53 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 087d8394ab6..37a4abb537f 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -2892,12 +2892,14 @@  void bh_cache_clear(void);
 int bh_cache_sync(void);
 int ext4l_read_block(sector_t block, size_t size, void *buffer);
 int ext4l_write_block(sector_t block, size_t size, void *buffer);
+void ext4l_msg_init(void);
+void ext4l_record_msg(const char *msg, int len);
+struct membuf *ext4l_get_msg_buf(void);
+void ext4l_print_msgs(void);
 
 /* ext4l interface functions (interface.c) */
 struct blk_desc *ext4l_get_blk_dev(void);
 struct disk_partition *ext4l_get_partition(void);
-void ext4l_record_msg(const char *msg, int len);
-struct membuf *ext4l_get_msg_buf(void);
 
 #define sb_is_blkdev_sb(sb)		({ (void)(sb); 0; })
 
diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c
index 7c37c99488a..aebcc17fd3a 100644
--- a/fs/ext4l/interface.c
+++ b/fs/ext4l/interface.c
@@ -13,7 +13,6 @@ 
 #include <env.h>
 #include <fs.h>
 #include <fs_legacy.h>
-#include <membuf.h>
 #include <part.h>
 #include <malloc.h>
 #include <u-boot/uuid.h>
@@ -24,9 +23,6 @@ 
 #include "ext4_uboot.h"
 #include "ext4.h"
 
-/* Message buffer size */
-#define EXT4L_MSG_BUF_SIZE	4096
-
 /* Global state */
 static struct blk_desc *ext4l_dev_desc;
 static struct disk_partition ext4l_part;
@@ -42,10 +38,6 @@  static int ext4l_open_dirs;
 /* Global super_block pointer for filesystem operations */
 static struct super_block *ext4l_sb;
 
-/* Message recording buffer */
-static struct membuf ext4l_msg_buf;
-static char ext4l_msg_data[EXT4L_MSG_BUF_SIZE];
-
 /**
  * ext4l_get_blk_dev() - Get the current block device
  *
@@ -150,49 +142,6 @@  void ext4l_clear_blk_dev(void)
 	ext4l_mounted = 0;
 }
 
-/**
- * ext4l_msg_init() - Initialize the message buffer
- */
-static void ext4l_msg_init(void)
-{
-	membuf_init(&ext4l_msg_buf, ext4l_msg_data, EXT4L_MSG_BUF_SIZE);
-}
-
-/**
- * ext4l_record_msg() - Record a message in the buffer
- *
- * @msg: Message string to record
- * @len: Length of message
- */
-void ext4l_record_msg(const char *msg, int len)
-{
-	membuf_put(&ext4l_msg_buf, msg, len);
-}
-
-/**
- * ext4l_get_msg_buf() - Get the message buffer
- *
- * Return: Pointer to the message buffer
- */
-struct membuf *ext4l_get_msg_buf(void)
-{
-	return &ext4l_msg_buf;
-}
-
-/**
- * ext4l_print_msgs() - Print all recorded messages
- *
- * Prints the contents of the message buffer to the console.
- */
-static void ext4l_print_msgs(void)
-{
-	char *data;
-	int len;
-
-	while ((len = membuf_getraw(&ext4l_msg_buf, 80, true, &data)) > 0)
-		printf("%.*s", len, data);
-}
-
 int ext4l_probe(struct blk_desc *fs_dev_desc,
 		struct disk_partition *fs_partition)
 {
diff --git a/fs/ext4l/support.c b/fs/ext4l/support.c
index 72bf819c3d6..1fc0bc0aa21 100644
--- a/fs/ext4l/support.c
+++ b/fs/ext4l/support.c
@@ -10,6 +10,7 @@ 
  */
 
 #include <blk.h>
+#include <membuf.h>
 #include <part.h>
 #include <malloc.h>
 #include <u-boot/crc.h>
@@ -19,6 +20,13 @@ 
 #include "ext4_uboot.h"
 #include "ext4.h"
 
+/* Message buffer size */
+#define EXT4L_MSG_BUF_SIZE	4096
+
+/* Message recording buffer */
+static struct membuf ext4l_msg_buf;
+static char ext4l_msg_data[EXT4L_MSG_BUF_SIZE];
+
 /*
  * Global task_struct for U-Boot.
  * This must be a single global instance shared across all translation units,
@@ -46,6 +54,49 @@  u32 ext4l_crc32c(u32 crc, const void *address, unsigned int length)
 	return crc32c_cal(crc, address, length, ext4l_crc32c_table);
 }
 
+/**
+ * ext4l_msg_init() - Initialise the message buffer
+ */
+void ext4l_msg_init(void)
+{
+	membuf_init(&ext4l_msg_buf, ext4l_msg_data, EXT4L_MSG_BUF_SIZE);
+}
+
+/**
+ * ext4l_record_msg() - Record a message in the buffer
+ *
+ * @msg: Message string to record
+ * @len: Length of message
+ */
+void ext4l_record_msg(const char *msg, int len)
+{
+	membuf_put(&ext4l_msg_buf, msg, len);
+}
+
+/**
+ * ext4l_get_msg_buf() - Get the message buffer
+ *
+ * Return: Pointer to the message buffer
+ */
+struct membuf *ext4l_get_msg_buf(void)
+{
+	return &ext4l_msg_buf;
+}
+
+/**
+ * ext4l_print_msgs() - Print all recorded messages
+ *
+ * Prints the contents of the message buffer to the console.
+ */
+void ext4l_print_msgs(void)
+{
+	char *data;
+	int len;
+
+	while ((len = membuf_getraw(&ext4l_msg_buf, 80, true, &data)) > 0)
+		printf("%.*s", len, data);
+}
+
 /*
  * iget_locked - allocate a new inode
  * @sb: super block of filesystem