From patchwork Sun Jan 18 20:37:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1590 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=1768768769; bh=MApekY38i1w8tpLAqkiAu060z5TOlrrPmOFHOnoamY0=; 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=fEQaTf3ZfAfngtUGXIEQwuwa0bal8ufwZS7ss+DndXOJtgq+4JRyDcSO7bnLiXu+t AD9olKe1AsAvs/UgbNVQq9Ya3uRU1VbVYpfNPnjo9eFJ8UxZh+aLF2dN8ORNJ4JsRn Gh9+TPhE+tnNvG+1Q04p45CalcnvXFY0wIY/bvgj1tSJa91dENka8+NqtqOFPElXIF fWq+Zpj7kfLwiw0xnGmLyPH4SUcLJITIvwLSufTt6gdmoNKOQqsHsVGw4GR7FuxBSB qlNBgLI3z9mlb5chR7iJHmJl9551D3Yu4TJEvjrjQamot/QzAx/ow8R4LE54YLeqEo FhFivSgunaCDw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2A680693A2 for ; Sun, 18 Jan 2026 13:39:29 -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 pmRhyZ4lUuTN for ; Sun, 18 Jan 2026 13:39:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768768769; bh=MApekY38i1w8tpLAqkiAu060z5TOlrrPmOFHOnoamY0=; 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=fEQaTf3ZfAfngtUGXIEQwuwa0bal8ufwZS7ss+DndXOJtgq+4JRyDcSO7bnLiXu+t AD9olKe1AsAvs/UgbNVQq9Ya3uRU1VbVYpfNPnjo9eFJ8UxZh+aLF2dN8ORNJ4JsRn Gh9+TPhE+tnNvG+1Q04p45CalcnvXFY0wIY/bvgj1tSJa91dENka8+NqtqOFPElXIF fWq+Zpj7kfLwiw0xnGmLyPH4SUcLJITIvwLSufTt6gdmoNKOQqsHsVGw4GR7FuxBSB qlNBgLI3z9mlb5chR7iJHmJl9551D3Yu4TJEvjrjQamot/QzAx/ow8R4LE54YLeqEo FhFivSgunaCDw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0117A6948C for ; Sun, 18 Jan 2026 13:39:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768768767; bh=jwBF+B4RL08VOLS3+PgZPRoXL4POeTZ9hYGfHPzId8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lDpG0xF3F8FQnqDpsLhAPnoZkewikWoNkH7U4T1m7m1TKkAMaE87hyEABrGkC8CU7 Njs7EMpks+YyAbIft2udmlvHulUQ7r3INC4n3mId+W6qJZU1FKfqTM2MllfOOGsiVs ndJFbxibUQy+4vIG8NIkKzNZWZUDzRlUG99jmG2Ws8SCuhXQ/x5LD4vOWfIyTOWIdO EGNmtJeNWMbEwI+8Wfs0/uML6yOZ2hn6LJ15SkwwRj1kus54dh1uj4dw7xjVx3929a VWVJ0iomUI18AK6703jXoJqvnvlPpvsXey481Q03Y++l1ptwHrvMawU9W6NWGPA4e3 xd19nB4CgV/nw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A046693A2; Sun, 18 Jan 2026 13:39:27 -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 q2zxzZipFD87; Sun, 18 Jan 2026 13:39:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768768762; bh=CrUyAhnNlG6DmS/rUvWzaZrl36qGSfDSMvOmpY5HfVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tMzWid3Gj1kg3OWIbsYRmQPG4sc++gdJNdi0bGI0o1LVUFmEb6/kyYILLLZiCltaQ 3HwR29tzkrozrnKNH4+x4l6h5qspL9O1tde5zu/L6qPJT5UCVMIrLWnarH7dlFE72/ mkEDSnQtYNsNX4JJCOK/VL6sQhmzdu3NQJ2QKx/VsEeolJkq3hzmSt9BMLix7eL9yL OCAJZkLZEKFlNG+ttQ67Pn6MvEA9aK4e+s/8Rw7QdcAnd4XTtFtHQxW1l5euq09dJM ilk+WvX8DXfPNKtgOEvH3OPa8H67+mjK7xBjGf8JjlNoStYLVwgPSGsLrEUImSzxD1 4B1cf2WCwjLhw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2061269499; Sun, 18 Jan 2026 13:39:22 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:37:33 -0700 Message-ID: <20260118133734.11.397d736c6788ee2e24a276a8634e9d22d18dd84d@changeid> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260118203739.1974323-1-sjg@u-boot.org> References: <20260118203739.1974323-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XNWGXZUY4DHIY6FYZTXQZCHRO2CLR4U5 X-Message-ID-Hash: XNWGXZUY4DHIY6FYZTXQZCHRO2CLR4U5 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 11/12] linux: Add hash.h header with hash_64 function 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 Create linux/hash.h with hash_64() and hash_32() hash functions. Update ext4_uboot.h to use the new header instead of duplicating the hash_64 definition. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 6 +++--- include/linux/hash.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 include/linux/hash.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4bc25b73f76..b861079bf48 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -901,8 +901,8 @@ void mapping_clear_folio_cache(struct address_space *mapping); /* try_cmpxchg is now in asm-generic/atomic.h */ -/* hash_64 - simple 64-bit hash */ -#define hash_64(val, bits) ((unsigned long)((val) >> (64 - (bits)))) +/* hash_64 - use linux/hash.h */ +#include /* Dentry operations are now in linux/dcache.h */ #define finish_open_simple(f, e) (e) @@ -1820,7 +1820,7 @@ int ext4_update_overhead(struct super_block *sb, bool force); /* fsmap is now in linux/fsmap.h */ #include -/* list_sort and sort stubs for fsmap.c */ +/* list_sort and sort stubs for fsmap.c - not used in U-Boot */ #define list_sort(priv, head, cmp) \ do { (void)(priv); (void)(head); (void)(cmp); } while (0) #define sort(base, num, size, cmp, swap) \ diff --git a/include/linux/hash.h b/include/linux/hash.h new file mode 100644 index 00000000000..276619ca310 --- /dev/null +++ b/include/linux/hash.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Hash functions for U-Boot + * + * Based on Linux hash.h - fast hashing routines. + */ +#ifndef _LINUX_HASH_H +#define _LINUX_HASH_H + +#include + +/** + * hash_64() - 64-bit hash function + * @val: value to hash + * @bits: number of bits in result + * + * Simple hash by shifting. In Linux this uses multiplication by a + * golden ratio constant, but for U-Boot a simple shift suffices. + * + * Return: hash value with @bits significant bits + */ +#define hash_64(val, bits) ((unsigned long)((val) >> (64 - (bits)))) + +/** + * hash_32() - 32-bit hash function + * @val: value to hash + * @bits: number of bits in result + * + * Return: hash value with @bits significant bits + */ +#define hash_32(val, bits) ((unsigned int)((val) >> (32 - (bits)))) + +#endif /* _LINUX_HASH_H */