From patchwork Wed Jan 21 22:08:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1759 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769033483; bh=0DXaiiqmEcBBl5C492c1rvd+fUeacUtMqq0J9PjBWKM=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=WzdL3x74fHyTnPdKppI6ahPZf9U3kt6jQvWioiBBujdJbKyxm2LRV7T8QqALMGJh5 viqhvkmiG4yhvPqElXfXIPzfCmaW21mrD3dhUFN1kSVpdc4SbruMhi0Ozc2HaX4G3+ 6Nz9qAA89S5z/ncckMmrPSZBaJa82H3V8i5lm1mMnzdqekJpExWf+UrxJ0+Pjs7+5x 1Sz9aeZnGB6rEvfjSH3DP75QCr+sToohyYqHJG5CGDjRBnj6eYTbiPaV4Y/LtQ7/aD 9OYVbGPtRj5kv/ZxIU7eAKXZ6Ys4ZQy7dAi/X8WBXVV+L6nEcl3P18jE9ygFVWKBFa tS2u76rW8IKig== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 926F569490 for ; Wed, 21 Jan 2026 15:11:23 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id yQXR6I4Tkytm for ; Wed, 21 Jan 2026 15:11:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769033483; bh=0DXaiiqmEcBBl5C492c1rvd+fUeacUtMqq0J9PjBWKM=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=WzdL3x74fHyTnPdKppI6ahPZf9U3kt6jQvWioiBBujdJbKyxm2LRV7T8QqALMGJh5 viqhvkmiG4yhvPqElXfXIPzfCmaW21mrD3dhUFN1kSVpdc4SbruMhi0Ozc2HaX4G3+ 6Nz9qAA89S5z/ncckMmrPSZBaJa82H3V8i5lm1mMnzdqekJpExWf+UrxJ0+Pjs7+5x 1Sz9aeZnGB6rEvfjSH3DP75QCr+sToohyYqHJG5CGDjRBnj6eYTbiPaV4Y/LtQ7/aD 9OYVbGPtRj5kv/ZxIU7eAKXZ6Ys4ZQy7dAi/X8WBXVV+L6nEcl3P18jE9ygFVWKBFa tS2u76rW8IKig== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7CBBF6954C for ; Wed, 21 Jan 2026 15:11:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769033482; bh=7plm7lHhtTEXTtCCi0+rUnG+/FQiXaMnF4cz2RgjH+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Df83MKQTsx+F2zyBPHsjV8+09CNKzNtbX/34+MJvKEAImAS+PNqjTjaSL/SZBHsa7 hNlgOvnVaIHYkga+nslTq44lth1GlPNzzTC5rYERXtH+PZpjN1E+srjI037Z3p+7PQ owd2VgaSsSoVipWX6dhWOlDqTHsvWEsqJbm4mu7w4h0hWim4maRrVzG4idP549i8u0 lMrnc15Nk7az8m/UN60ckCdshTRIyaLMfzwJDMDqN03qr/MHm8CrSaRM3neD2Zud+U /dR9x4vIxwQOmpi6IPC3jUPkmZGhgAZr/vuaeKq7ZcEhYaZg2pNHlLN/8GuOT9XEsX QP7QjstEYp+IQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3C3396954C; Wed, 21 Jan 2026 15:11:22 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id Plm_ktV0eL1K; Wed, 21 Jan 2026 15:11:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769033478; bh=0yDwVUDiHKPcVRkby6x1blZJ2nMpfMsXy9AASdHPmig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hQyP4TEhM/w0ROzJ2GkY8kzhMKQGr5PN3mS5EF8YT/3+DlsZ6I3HJY6FjCp7s4/bw +Got5oXjvP0fZgoHtla2vWAGDZHcxbWvhoksowpOIZA+j88zgV25WAMeUwpAUneeZL v2BQhisWr2yDCGFxN19ky2SoaLg4w4Jy84TvQ3j4BGHVKHtb61Xsi15fmwa/N+AGSL w/5+QiZXpUi1Oey2s/NTFjq+Tr+G86vuCOgzz1vv1GS5KceLm47orOPbOufpNbSgO0 ktshB8JhkodguXQ0ZlLMpaK7XG5l7XR1iXsHiv+l8DFuja8pvTdwSxIppq8BbxL0zs 6mvrAO9o7t6wQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B662E69490; Wed, 21 Jan 2026 15:11:17 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 21 Jan 2026 15:08:46 -0700 Message-ID: <20260121220857.2137568-34-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260121220857.2137568-1-sjg@u-boot.org> References: <20260121220857.2137568-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CGBM3G2PMBDUKIT2MDQU5KDC23YSVFIY X-Message-ID-Hash: CGBM3G2PMBDUKIT2MDQU5KDC23YSVFIY X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 33/33] ext4l: Consolidate and sort includes in ext4_uboot.h List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Reorganise ext4_uboot.h to: - Move all #include directives to the top of the file - Sort includes alphabetically within each section - Place BUG_ON/BUG override immediately after linux/bug.h - Sort forward declarations and function declarations alphabetically The include order is preserved where dependencies require it, particularly for no_printk and BUG_ON/BUG overrides which must come after certain headers are included. This reduces the file from 366 to 270 lines. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 402 ++++++++++++++++-------------------------- 1 file changed, 153 insertions(+), 249 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 04ed9c3c846..24402f21790 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -19,48 +19,52 @@ #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-variable" +/* U-Boot headers */ #include +#include +#include +#include + +/* Linux types - must come first */ #include -#include -#include /* For panic() */ -#include -#include + +/* Linux headers (alphabetical) */ #include -#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include #include -#include #include -#include -#include -#include -#include +#include +#include +#include #include -#include /* Real rbtree implementation */ -#include /* For timespec64, time64_t */ -#include /* For struct folio_batch */ -#include /* For BUILD_BUG_ON */ -#include /* For WARN_ON, WARN_ONCE */ -#include /* For crc32() used by crc32_be */ -#include "ext4_trace.h" /* Trace event stubs */ -#include "ext4_fscrypt.h" /* fscrypt stubs */ +#include +#include +#include +#include /* - * __CHAR_UNSIGNED__ - directory hash algorithm selection - * - * The ext4 filesystem uses different hash algorithms for directory indexing - * depending on whether the platform's 'char' type is signed or unsigned. - * GCC automatically defines __CHAR_UNSIGNED__ on platforms where char is - * unsigned (e.g., ARM), and leaves it undefined where char is signed - * (e.g., x86/sandbox). - * - * The filesystem stores EXT2_FLAGS_UNSIGNED_HASH or EXT2_FLAGS_SIGNED_HASH - * in the superblock to record which hash variant was used when the filesystem - * was created, ensuring correct behavior regardless of the mounting platform. - * - * See super.c:5123 and ioctl.c:1489 for the hash algorithm selection code. + * BUG_ON / BUG - stubs (not using linux/bug.h which panics) + * In Linux, these indicate kernel bugs. In ext4l, some BUG_ON conditions + * that check for race conditions can trigger in single-threaded U-Boot, + * so we stub them out as no-ops. */ +#undef BUG_ON +#undef BUG +#define BUG_ON(cond) do { (void)(cond); } while (0) +#define BUG() do { } while (0) + +/* Local ext4l headers */ +#include "ext4_fscrypt.h" +#include "ext4_trace.h" /* * Override no_printk to avoid format warnings in disabled debug prints. @@ -70,53 +74,111 @@ #undef no_printk #define no_printk(fmt, ...) ({ 0; }) +/* More Linux headers (alphabetical) */ #include -#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include - -#define EXT4_FIEMAP_EXTENT_HOLE 0x08000000 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* - * BUG_ON / BUG - stubs (not using linux/bug.h which panics) - * In Linux, these indicate kernel bugs. In ext4l, some BUG_ON conditions - * that check for race conditions can trigger in single-threaded U-Boot, - * so we stub them out as no-ops. + * Hex dump - Linux kernel print_hex_dump has a different signature + * (includes log level) than U-Boot's, so we stub it out here. */ -#undef BUG_ON -#undef BUG -#define BUG_ON(cond) do { (void)(cond); } while (0) -#define BUG() do { } while (0) +#undef print_hex_dump +#define print_hex_dump(l, p, pt, rg, gc, b, len, a) do { } while (0) -#include -#include -#include -#include +/* + * __CHAR_UNSIGNED__ - directory hash algorithm selection + * + * The ext4 filesystem uses different hash algorithms for directory indexing + * depending on whether the platform's 'char' type is signed or unsigned. + * GCC automatically defines __CHAR_UNSIGNED__ on platforms where char is + * unsigned (e.g., ARM), and leaves it undefined where char is signed + * (e.g., x86/sandbox). + * + * The filesystem stores EXT2_FLAGS_UNSIGNED_HASH or EXT2_FLAGS_SIGNED_HASH + * in the superblock to record which hash variant was used when the filesystem + * was created, ensuring correct behavior regardless of the mounting platform. + * + * See super.c:5123 and ioctl.c:1489 for the hash algorithm selection code. + */ -#include -#include +/* ext4-specific constants */ +#define EXT4_FIEMAP_EXTENT_HOLE 0x08000000 +#define EXT4_SUPER_MAGIC 0xEF53 -#include -#include -#include +#define EXT4_GOING_FLAGS_DEFAULT 0 +#define EXT4_GOING_FLAGS_LOGFLUSH 1 +#define EXT4_GOING_FLAGS_NOLOGFLUSH 2 /* * U-Boot buffer head private bits. @@ -134,143 +196,30 @@ BUFFER_FNS(OwnsData, ownsdata) #define BH_Cached (BH_JBDPrivateStart + 2) BUFFER_FNS(Cached, cached) -#include -#include -#include -#include -#include - /* Forward declarations */ -struct pipe_inode_info; +struct fid; struct kstat; +struct kstatfs; struct path; - -/* QSTR_INIT and dotdot_name are now in linux/dcache.h */ - -#include - -/* indirect.c stubs */ - -/* ext4_sb_bread_nofail is stubbed in interface.c */ - -/* extents_status.c stubs */ - -/* shrinker - use linux/shrinker.h */ -#include - -/* ktime functions - use linux/ktime.h */ -#include - -/* hrtimer - use linux/hrtimer.h */ -#include - -/* folio and pagemap - use linux/pagemap.h */ -#include -#include - -/* wbc_to_tag, WB_REASON_* - use linux/writeback.h */ -#include - -/* projid_t is now in linux/projid.h */ - -/* - * Additional stubs for inode.c - */ - -/* try_cmpxchg is now in asm-generic/atomic.h */ - -/* hash_64 - use linux/hash.h */ -#include - -#include -#include - -#include -#include -#include - -/* UID/GID bit helpers - use linux/highuid.h */ -#include - -/* - * Additional stubs for dir.c - */ +struct pipe_inode_info; /* FSTR_INIT - fscrypt_str initializer (fscrypt_str defined in ext4_fscrypt.h) */ #define FSTR_INIT(n, l) { .name = (n), .len = (l) } -/* struct_size - use linux/overflow.h */ -#include - -#include - -/* - * Additional stubs for super.c - */ - /* Part stat - not used in U-Boot. Note: sectors[X] is passed as second arg */ -#define STAT_WRITE 0 #define STAT_READ 0 +#define STAT_WRITE 0 static u64 __attribute__((unused)) __ext4_sectors[2]; #define sectors __ext4_sectors #define part_stat_read(p, f) ({ (void)(p); (void)(f); 0ULL; }) -/* - * Hex dump - DUMP_PREFIX_* types are in hexdump.h. - * However, the Linux kernel print_hex_dump has a different signature - * (includes log level) than U-Boot's, so we stub it out here. - */ -#include -#undef print_hex_dump -#define print_hex_dump(l, p, pt, rg, gc, b, len, a) do { } while (0) - -/* Forward declarations for super_operations and export_operations */ -struct kstatfs; -struct fid; - -#include -#include -#include - -/* EXT4_GOING flags */ -#define EXT4_GOING_FLAGS_DEFAULT 0 -#define EXT4_GOING_FLAGS_LOGFLUSH 1 -#define EXT4_GOING_FLAGS_NOLOGFLUSH 2 - -/* ext4 superblock initialisation and commit */ -int ext4_fill_super(struct super_block *sb, struct fs_context *fc); -int ext4_commit_super(struct super_block *sb); -void ext4_unregister_li_request(struct super_block *sb); - -#include - -#include -#include - -/* I/O priority classes - use linux/ioprio.h */ -#include - -/* end_buffer_write_sync - implemented in support.c */ -void end_buffer_write_sync(struct buffer_head *bh, int uptodate); - -#define EXT4_SUPER_MAGIC 0xEF53 - -/* blockgroup_lock - use linux/blockgroup_lock.h */ -#include - -/* Buffer submission stubs - declaration for stub.c */ -int trylock_buffer(struct buffer_head *bh); - -/* Trace stubs for super.c - declaration for stub.c implementation */ -void trace_ext4_error(struct super_block *sb, const char *func, unsigned int line); - -/* ___ratelimit is now in linux/ratelimit.h */ - -/* kobject_put is now in linux/kobject.h */ -/* wait_for_completion is now a macro in linux/completion.h */ +/* CRC32 big-endian - map to U-Boot's crc32() */ +#define crc32_be(crc, p, len) crc32(crc, p, len) -/* DAX - declaration for stub.c */ -void fs_put_dax(void *dax, void *holder); +/* Memory allocation for journal.c */ +#define __get_free_pages(gfp, order) ((unsigned long)memalign(PAGE_SIZE, PAGE_SIZE << (order))) +#define free_pages(addr, order) free((void *)(addr)) +#define get_order(size) ilog2(roundup_pow_of_two((size) / PAGE_SIZE)) /* Memory allocation - declarations for stub.c */ void *kvzalloc(size_t size, gfp_t flags); @@ -280,87 +229,42 @@ void *kvzalloc(size_t size, gfp_t flags); unsigned long get_zeroed_page(gfp_t gfp); void free_page(unsigned long addr); -/* DAX - declaration for stub.c */ +/* DAX - declarations for stub.c */ void *fs_dax_get_by_bdev(struct block_device *bdev, u64 *start, u64 *len, void *holder); +void fs_put_dax(void *dax, void *holder); -#include -#include +/* Buffer submission - declaration for stub.c */ +int trylock_buffer(struct buffer_head *bh); /* Filesystem sync - declaration for stub.c */ int sync_filesystem(void *sb); -/* - * Stubs for mballoc.c - */ - -#include -#include - -/* - * Stubs for page-io.c - bio types are in linux/bio.h - */ -#include - -/* - * Stubs for readpage.c - */ - -#include - -#include - -/* - * Stubs for fast_commit.c - */ +/* Trace stubs for super.c - declaration for stub.c */ +void trace_ext4_error(struct super_block *sb, const char *func, unsigned int line); -/* Wait bit operations - use linux/wait_bit.h */ -#include +/* end_buffer_write_sync - implemented in support.c */ +void end_buffer_write_sync(struct buffer_head *bh, int uptodate); -/* JBD2 checkpoint.c and commit.c stubs */ -#include -/* smp_mb__after_atomic is now in linux/smp.h */ -#define crc32_be(crc, p, len) crc32(crc, p, len) +/* ext4 superblock initialisation and commit */ +int ext4_commit_super(struct super_block *sb); +int ext4_fill_super(struct super_block *sb, struct fs_context *fc); +void ext4_unregister_li_request(struct super_block *sb); /* ext4l support functions (support.c) */ -void ext4l_crc32c_init(void); -void bh_cache_release_jbd(void); -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 bh_cache_clear(void); +void bh_cache_release_jbd(void); +void ext4l_crc32c_init(void); +void ext4l_msg_init(void); void ext4l_print_msgs(void); +void ext4l_record_msg(const char *msg, int len); /* ext4l interface functions (interface.c) */ struct blk_desc *ext4l_get_blk_dev(void); struct disk_partition *ext4l_get_partition(void); -#include - -/* Memory allocation for journal.c */ -#define __get_free_pages(gfp, order) ((unsigned long)memalign(PAGE_SIZE, PAGE_SIZE << (order))) -#define free_pages(addr, order) free((void *)(addr)) -#define get_order(size) ilog2(roundup_pow_of_two((size) / PAGE_SIZE)) - -/* - * Stubs for mmp.c - */ - -/* init_utsname - use linux/utsname.h */ -#include - -/* - * Stubs for fsmap.c - */ - -/* fsmap is now in linux/fsmap.h */ -#include - -/* list_sort and sort for fsmap.c */ -#include -#include - #endif /* __EXT4_UBOOT_H__ */