[Concept,04/16] ext4l: Move data_race, might_sleep, fallthrough to standard headers

Message ID 20260119214846.3087611-5-sjg@u-boot.org
State New
Headers
Series ext4l: Move definitions to standard Linux headers |

Commit Message

Simon Glass Jan. 19, 2026, 9:48 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Move data_race() to linux/compiler.h and might_sleep() to linux/kernel.h
where they belong. The fallthrough attribute is already provided by
linux/compiler_attributes.h, so just remove the duplicate definition.

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

 fs/ext4l/ext4_uboot.h    | 10 +++-------
 include/linux/compiler.h |  8 ++++++++
 include/linux/kernel.h   |  8 ++++++++
 3 files changed, 19 insertions(+), 7 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 0b3b2d6f2e5..564e63d6882 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -123,7 +123,7 @@ 
 
 /* Pointer check macros */
 #define ZERO_OR_NULL_PTR(x)		((unsigned long)(x) <= PAGE_SIZE)
-#define data_race(expr)			(expr)
+/* data_race is in linux/compiler.h */
 
 /* REQ_META, REQ_PRIO, REQ_RAHEAD are in linux/blk_types.h */
 /* __GFP_MOVABLE, __GFP_FS are in linux/slab.h */
@@ -191,8 +191,7 @@  extern struct user_namespace init_user_ns;
 #define BUG_ON(cond)	do { (void)(cond); } while (0)
 #define BUG()		do { } while (0)
 
-/* might_sleep - stub */
-#define might_sleep()	do { } while (0)
+/* might_sleep is in linux/kernel.h */
 
 /* sb_rdonly is in linux/super.h */
 
@@ -642,10 +641,7 @@  struct dx_hash_info {
 	do { } while (0)
 #endif
 
-/* fallthrough annotation */
-#ifndef fallthrough
-#define fallthrough __attribute__((__fallthrough__))
-#endif
+/* fallthrough is in linux/compiler_attributes.h */
 
 /* BUILD_BUG_ON is in linux/build_bug.h */
 /* WARN_ON, WARN_ON_ONCE, WARN_ONCE are in linux/bug.h */
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 09cea0e95e2..c1131fe886b 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -352,4 +352,12 @@  static inline void *offset_to_ptr(const int *off)
 /* &a[0] degrades to a pointer: a different type from an array */
 #define __must_be_array(a)	BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
 
+/*
+ * data_race - mark data race intentional
+ *
+ * In U-Boot (single-threaded), no actual data races are possible,
+ * so just evaluate the expression.
+ */
+#define data_race(expr)		(expr)
+
 #endif /* __LINUX_COMPILER_H */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d6cd54f20b9..0da0d4915ec 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -313,4 +313,12 @@  enum system_states {
 
 #define system_state	SYSTEM_RUNNING
 
+/*
+ * might_sleep - indicate that a function may sleep
+ *
+ * U-Boot is single-threaded and doesn't have a scheduler, so this is a no-op.
+ */
+#define might_sleep()		do { } while (0)
+#define might_sleep_if(cond)	do { } while (0)
+
 #endif