From patchwork Wed Jan 14 22:56:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1510 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=1768431483; bh=ZQ60/OSpz3Mm0bE1DSKZwNAJJXYro6i5mfCpaiOU1uU=; 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=U0ysUuZuzK60Ku0EnxXq3RHe5zFZIPEH34+NwdSZh082RUw+Pwai89Y7rUwXLa84E oxGCy2indUvhWsVfjkSZJBu9Kta38Ilvzy7r5ud4jZkPGmcQ4lCkD5+TcPLHi+tN34 v3Blpw4xMkUl9KAfcH0FdOqUUyLxw+Ob3CrYkmaByT5Ef7g+D6/Y7d2aI5RswMJtMk pAuyil7CVm2kzyx1HGA3edZrd/krevgANyD3/GDYJ7XQYujqOczBHQlZ0Fzx/uaFIT FNYp87wWL5y+FzvzXG8GtAENmfyHRYN097jtffqG8Zp47hwKAx1VxoAgrBKHf5Dbjk 84AyE265KBZyA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B0045692E6 for ; Wed, 14 Jan 2026 15:58:03 -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 F2l62mqRK-Mw for ; Wed, 14 Jan 2026 15:58:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768431483; bh=ZQ60/OSpz3Mm0bE1DSKZwNAJJXYro6i5mfCpaiOU1uU=; 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=U0ysUuZuzK60Ku0EnxXq3RHe5zFZIPEH34+NwdSZh082RUw+Pwai89Y7rUwXLa84E oxGCy2indUvhWsVfjkSZJBu9Kta38Ilvzy7r5ud4jZkPGmcQ4lCkD5+TcPLHi+tN34 v3Blpw4xMkUl9KAfcH0FdOqUUyLxw+Ob3CrYkmaByT5Ef7g+D6/Y7d2aI5RswMJtMk pAuyil7CVm2kzyx1HGA3edZrd/krevgANyD3/GDYJ7XQYujqOczBHQlZ0Fzx/uaFIT FNYp87wWL5y+FzvzXG8GtAENmfyHRYN097jtffqG8Zp47hwKAx1VxoAgrBKHf5Dbjk 84AyE265KBZyA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9F38D6934D for ; Wed, 14 Jan 2026 15:58:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768431482; bh=GHslN7zWmwIh0aG88pOFGOI5COaxWBefLGI2wGDQtzQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pjw4QDT9yV7w2w2stbOftt5wIHrzZLOZTZiuFrk1OFrAv6gAxPC4pRE9XyyRNN1NE cCIVGFFwIWva3ppt+z7U6obNPJbAWgKTL01fJLalPlrFfnbejampqg7/TTdAU3PAtM uLc/rIm9hGQUSuvy2Sv13zf9hPjJwkBGwZVU4Ivmt58MxZVez3+RQZlC0KeKV+DJO2 7wE9Udc2ABW2EkZ61ofgjMkwfYDMz3LiP9D8Ir5T2csTohJX20oO2Ax41VBRPOXWCM PHjMg5jsS/ZFQbwZptnXl4aflM3KTdMoMXC4ERyQTAPF7zMDkxgUlruMCUOftas7y6 WmOthM4KrWmog== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4D019692E6; Wed, 14 Jan 2026 15:58:02 -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 8wUb7wn3P79z; Wed, 14 Jan 2026 15:58:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768431478; bh=nZpknmCrJTusXwJOyxiXr2Pd+hHI4IHjUCvT0I7ZcB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vkklIwsCqQRSrHiW5gGOEqtMWxskZwE578jNt92/yc2wwkVbTqUb6sEP3Wkixtvuy 8C4mfZAIJ/PJEI5LhKyJcSgYC2eqqHZ8yxGVfHgw8fIFjFnABcI+PjtOJaHNiU4HHX 2Y4W0iwDPGHCuQzj0nu7ugOOszK0be7cHtpTituLjvrMAfmfSqwQcIDD1ogiMdTTbE GbdwRpBHeSAG4FN4898utffG+4dVD5vjQO9XzoznomVDGYrRc4tFUNiOCrnP1ET8+Q Qi/UuH5rwfmGeYGsU7wD6d9piVu2+4LVRjTSIJFs5fZ2NqyOH8DCEjCicMh2gaifkf G6OILh9PJNLdw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E6D1D69342; Wed, 14 Jan 2026 15:57:57 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 14 Jan 2026 15:56:06 -0700 Message-ID: <20260114225635.3407989-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260114225635.3407989-1-sjg@u-boot.org> References: <20260114225635.3407989-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ABE67JVXDWJ4UPMULVIHOQEIZDML3PP5 X-Message-ID-Hash: ABE67JVXDWJ4UPMULVIHOQEIZDML3PP5 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 16/34] ext4l: Use linux/build_bug.h and linux/bug.h for macros 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 The ext4l code defines local versions of BUILD_BUG_ON(), WARN_ON(), and WARN_ONCE() instead of using the standard U-Boot headers. Use linux/build_bug.h and linux/bug.h to provide these macros. Keep BUG()/BUG_ON() as no-op stubs since linux/bug.h's versions call panic(). Some BUG_ON() conditions check for race conditions that can trigger in single-threaded U-Boot, so they must be stubbed out. Add a bio_sectors() inline function which is now needed because WARN_ONCE() evaluates its arguments (unlike the previous no-op stub). Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 715407b83d8..b13e653c883 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -39,6 +39,8 @@ #include #include /* Real rbtree implementation */ #include /* For timespec64, time64_t */ +#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 */ @@ -248,8 +250,15 @@ struct user_namespace { }; extern struct user_namespace init_user_ns; -/* BUG_ON / BUG - stubs (panic is in vsprintf.h) */ -#define BUG_ON(cond) do { } while (0) +/* + * 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) /* might_sleep - stub */ @@ -930,13 +939,8 @@ struct seq_file; #define fallthrough __attribute__((__fallthrough__)) #endif -/* BUILD_BUG_ON - compile-time assertion */ -#define BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)])) - -/* Warning macros - stubs */ -#define WARN_ON_ONCE(cond) ({ (void)(cond); 0; }) -#define WARN_ON(cond) ({ (void)(cond); 0; }) -#define WARN_ONCE(cond, fmt, ...) ({ (void)(cond); 0; }) +/* BUILD_BUG_ON is in linux/build_bug.h */ +/* WARN_ON, WARN_ON_ONCE, WARN_ONCE are in linux/bug.h */ #define pr_warn_once(fmt, ...) do { } while (0) /* lockdep stubs */ @@ -2418,6 +2422,12 @@ struct bio { void (*bi_end_io)(struct bio *); }; +/* bio_sectors - return number of sectors in bio */ +static inline unsigned int bio_sectors(struct bio *bio) +{ + return bio->bi_iter.bi_size >> 9; +} + /* folio_iter for bio iteration */ struct folio_iter { int i;