[Concept,32/33] linux: Add DEFINE_RAW_FLEX to linux/overflow.h

Message ID 20260121220857.2137568-33-sjg@u-boot.org
State New
Headers
Series Reorganise ext4l compatibility stubs |

Commit Message

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

Move DEFINE_RAW_FLEX macro from ext4_uboot.h to linux/overflow.h
where it belongs alongside struct_size() and other size helpers.

In the kernel this macro allocates a flexible array struct on the
stack. In U-Boot it is stubbed to NULL since the code paths that
use it are not exercised.

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

 fs/ext4l/ext4_uboot.h    |  4 ----
 include/linux/overflow.h | 12 ++++++++++++
 2 files changed, 12 insertions(+), 4 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index ad3e59a7f6c..04ed9c3c846 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -297,10 +297,6 @@  int sync_filesystem(void *sb);
 #include <asm-generic/timex.h>
 #include <linux/nospec.h>
 
-/* DEFINE_RAW_FLEX - define a flexible array struct on the stack (stubbed to NULL) */
-#define DEFINE_RAW_FLEX(type, name, member, count) \
-	type *name = NULL
-
 /*
  * Stubs for page-io.c - bio types are in linux/bio.h
  */
diff --git a/include/linux/overflow.h b/include/linux/overflow.h
index 672377ede42..75e8ad44ecf 100644
--- a/include/linux/overflow.h
+++ b/include/linux/overflow.h
@@ -20,4 +20,16 @@ 
 #define struct_size(p, member, count)		\
 	(sizeof(*(p)) + sizeof((p)->member[0]) * (count))
 
+/**
+ * DEFINE_RAW_FLEX() - Define a flexible array struct on the stack
+ * @type: Structure type containing flexible array
+ * @name: Variable name for the struct pointer
+ * @member: Name of the flexible array member
+ * @count: Number of elements
+ *
+ * In the kernel this allocates on stack; U-Boot stubs it to NULL.
+ */
+#define DEFINE_RAW_FLEX(type, name, member, count) \
+	type *name = NULL
+
 #endif /* _LINUX_OVERFLOW_H */