From patchwork Mon Jan 19 06:14:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1608 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=1768803350; bh=l2CseYpF9Wc304dfl2GJTDZXCT+CWMCootTu1582dbQ=; 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=gln8U3X6oumveKL4b3uY8wjkcYl02J9o7LLorvAlnzwCFQWgmHzu18SwJf8qvhUKj ieva8Y56DbxM/sSyRS3MMiRuAsL05CAoPNn2hlXdqJ8zkCMCvIIeuSl1wuv5MMKZdt oRbtwSXaX1VHYRYMiS53HWea7Uct3r4fdzWSlG7/klB6aLQWZC/J6Lo8sBCVK7SznV fzemq/AiWR/nl4zSmI09nCbjOYuiMx/OrrwhE+4vXAkk7fQNlbqoVfVv87IR2Y+m3V DgJ28zXpLK8TvEi6RYOxmaw92EsrRWKyIIPSV5jCp8UnJ8ub4Qx/wDr76nz27yc71b 0jUSsh+sAJd+A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 31419694CF for ; Sun, 18 Jan 2026 23:15:50 -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 WCCYySztaa7m for ; Sun, 18 Jan 2026 23:15:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768803350; bh=l2CseYpF9Wc304dfl2GJTDZXCT+CWMCootTu1582dbQ=; 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=gln8U3X6oumveKL4b3uY8wjkcYl02J9o7LLorvAlnzwCFQWgmHzu18SwJf8qvhUKj ieva8Y56DbxM/sSyRS3MMiRuAsL05CAoPNn2hlXdqJ8zkCMCvIIeuSl1wuv5MMKZdt oRbtwSXaX1VHYRYMiS53HWea7Uct3r4fdzWSlG7/klB6aLQWZC/J6Lo8sBCVK7SznV fzemq/AiWR/nl4zSmI09nCbjOYuiMx/OrrwhE+4vXAkk7fQNlbqoVfVv87IR2Y+m3V DgJ28zXpLK8TvEi6RYOxmaw92EsrRWKyIIPSV5jCp8UnJ8ub4Qx/wDr76nz27yc71b 0jUSsh+sAJd+A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2183C694C7 for ; Sun, 18 Jan 2026 23:15:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768803348; bh=Oau4rgdkxxwR7jK1Gsra9Em9iq4KPAKyb8cc1+uOJgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H25KEku7Jth2bXDCuEDlBBltyS9pEnRhSB40epGQeJuaUsOj6t32GA2GjhGw6Xm76 Oljgn4PqXxyeaVWBwNlTjjb1DU6cLn0LxpK2NbsxjzTEoSoML+8TgDi7mWEwc3wzKv D4pySnR8uxF1T94Zl65jRfe4TBXxUjrKiP+vRuc6kdZ/K942oiSFPfVr8wmEOSG6UM N36rmh6+tJK6t7Gqu4d2yxoK/1gvbw+2Y9jEN597o+nGbcPqzfOHyJrMjVBTMxOOof n6l1HngLZjDTZJcg2jXuWcNBzoFXgAoYUwm2y97wjG0RXHfxlZltodqvDDlKSi8kDu JYskiLOzgZMbA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5D110693AE; Sun, 18 Jan 2026 23:15:48 -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 87x50mrVuqSn; Sun, 18 Jan 2026 23:15:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768803344; bh=17aDNw560M2nqMhxb8GaaWW/FsJZHXyExJguZhNMYsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SE6dWSeFf17PL39ZDkv+d6itmoRBor3Y6lB5AS3jeq+fWK42ShXIH1mjYagS8ubIn VM5NIwLcCeFYRIPQ5li3M7IAIwfGY0hBodDVWY0aWCL9tvQrmprZDu74HE7R63Amiy dC91z5NbP3ThEBI8lKCorO65cfO8BurnY7b3PA1xmTYmzD2mqVFN9vVOTOB+u/h5KQ eUOoskIJh18CNAp7N5zJcKIKXJcZqVRwqofTrwIPbJ/DdYqfS2Gk0IYOkH81ZQdfNz wcWcQzSSSUdfZwVmlkHDaAsLSApZw8s2SxOTJ8tAMt58PMi463l5gXpWM/cgM9y2aM oQAWRTLXU/Pog== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0F792694D9; Sun, 18 Jan 2026 23:15:44 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 23:14:59 -0700 Message-ID: <20260119061529.3383191-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260119061529.3383191-1-sjg@u-boot.org> References: <20260119061529.3383191-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: AZKSIBYU5OQOBRVDFK4YZW6PUOSVYQMQ X-Message-ID-Hash: AZKSIBYU5OQOBRVDFK4YZW6PUOSVYQMQ 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 01/23] linux: random: Add get_random_u32_below and prandom_u32_max 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 Add get_random_u32_below() and prandom_u32_max() stub macros to linux/random.h for filesystem code that uses random number generation. Update ext4_uboot.h to use linux/random.h instead of duplicating these definitions. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 8 +++----- include/linux/random.h | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 3c6b3ca5507..4fb8f9111b0 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -252,8 +252,8 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); /* d_inode is now in linux/dcache.h */ -/* Random number functions */ -#define get_random_u32_below(max) (0) +/* Random number functions - use linux/random.h */ +#include /* Buffer cache operations */ #define sb_find_get_block(sb, block) ((struct buffer_head *)NULL) @@ -1267,9 +1267,7 @@ 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); -/* prandom */ -#define get_random_u32() 0 -#define prandom_u32_max(max) 0 +/* prandom - get_random_u32, prandom_u32_max are in linux/random.h */ /* ctype */ #include diff --git a/include/linux/random.h b/include/linux/random.h index cb09c6c6b05..1a9de842a4c 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -1,6 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Stub definitions for random number generation. + * Random number generation definitions for U-Boot + * + * Based on Linux random.h - random number generation. + * U-Boot stub - returns constant values. */ #ifndef _LINUX_RANDOM_H #define _LINUX_RANDOM_H @@ -12,4 +15,24 @@ #define get_random_u32() 0 #define get_random_u64() 0ULL +/** + * get_random_u32_below() - get random number below a ceiling + * @ceil: upper bound (exclusive) + * + * U-Boot stub - always returns 0. + * + * Return: random value in [0, ceil) + */ +#define get_random_u32_below(ceil) (0) + +/** + * prandom_u32_max() - get random number up to a maximum + * @max: upper bound (inclusive) + * + * U-Boot stub - always returns 0. + * + * Return: random value in [0, max] + */ +#define prandom_u32_max(max) (0) + #endif /* _LINUX_RANDOM_H */