[Concept,08/11] ext4l: Extract initcall declarations into their own file

Message ID 20251216211817.4131167-9-sjg@u-boot.org
State New
Headers
Series ext4l: Add Linux compatibility headers |

Commit Message

Simon Glass Dec. 16, 2025, 9:18 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Create include/linux/init.h with stub definitions for kernel
initialization macros. U-Boot has its own initialization mechanism.

Includes:
- Section markers: __init, __exit, __initdata, __devinit, etc.
- Initcall levels: core_initcall(), late_initcall(), etc.

Update compat.h to include init.h and remove duplicate definitions.

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

 include/linux/compat.h | 10 +--------
 include/linux/init.h   | 49 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 9 deletions(-)
 create mode 100644 include/linux/init.h
  

Patch

diff --git a/include/linux/compat.h b/include/linux/compat.h
index 3bba18d637d..fc0bfc31e5f 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -13,6 +13,7 @@ 
 #include <linux/err.h>
 #include <linux/export.h>
 #include <linux/freezer.h>
+#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -147,8 +148,6 @@  typedef unsigned long blkcnt_t;
 
 #define blocking_notifier_call_chain(...) 0
 
-#define __initdata
-#define late_initcall(...)
 
 #define dev_set_name(...)		do { } while (0)
 #define device_register(...)		0
@@ -197,13 +196,6 @@  typedef int	wait_queue_head_t;
 #define cond_resched()			do { } while (0)
 #define yield()				do { } while (0)
 
-#define __init
-#define __exit
-#define __devinit
-#define __devinitdata
-#define __devinitconst
-#define __initconst
-#define __initdata
 
 #define kthread_create(...)	__builtin_return_address(0)
 #define kthread_stop(...)	do { } while (0)
diff --git a/include/linux/init.h b/include/linux/init.h
new file mode 100644
index 00000000000..ea74422c337
--- /dev/null
+++ b/include/linux/init.h
@@ -0,0 +1,49 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * These macros are used to mark some functions or initialized data
+ * as 'initialization' functions. The kernel can take this as hint
+ * that the function is used only during the initialization phase
+ * and free up used memory resources after.
+ *
+ * Stub definitions for Linux kernel initialization macros.
+ * U-Boot has its own initialization mechanism.
+ */
+#ifndef _LINUX_INIT_H
+#define _LINUX_INIT_H
+
+/* Section markers - these are no-ops in U-Boot */
+#define __init
+#define __exit
+#define __initdata
+#define __exitdata
+#define __initconst
+#define __exitconst
+#define __devinit
+#define __devexit
+#define __devinitdata
+#define __devexitdata
+#define __devinitconst
+#define __devexitconst
+
+/* Initcall levels - no-ops in U-Boot */
+#define pure_initcall(fn)
+#define core_initcall(fn)
+#define core_initcall_sync(fn)
+#define postcore_initcall(fn)
+#define postcore_initcall_sync(fn)
+#define arch_initcall(fn)
+#define arch_initcall_sync(fn)
+#define subsys_initcall(fn)
+#define subsys_initcall_sync(fn)
+#define fs_initcall(fn)
+#define fs_initcall_sync(fn)
+#define rootfs_initcall(fn)
+#define device_initcall(fn)
+#define device_initcall_sync(fn)
+#define late_initcall(fn)
+#define late_initcall_sync(fn)
+
+#define __initcall(fn)
+#define __exitcall(fn)
+
+#endif /* _LINUX_INIT_H */