From patchwork Thu Jan 8 18:51:20 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1346 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=1767898349; bh=Xpn+gOUIM0JCgAMNmGSwEUxOdQBcKNVZgPTaM2XcUEQ=; 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=m7LkjUYb+6qOZtP6iVMCb/e1JZ3lr731OW/CRm3Lzw5b1LBGV82jlFA8qHWNdNboc uFJqarfoKcWJr0j5b87MWBTMbmbnioKzXKgeVCJkpR9/Sj/DgmGDsNKP7fPUWbkuCA 3mynnNPveYngEXHfmtvfzkfPUS2dnu5d1T6PLo8HKC9908OwgiMNWdQuHCJ5Dkhyn7 J6DvUKLBo7GMZUdD8Vzs7Ql7j2NoulQALaUJbYXvDO+3UqwOX3mZ9FI6V/IPMu9sBa obPEWAgUondJN8mTsWdUQjR3dVGsDiAxAfCUYxkXn1zFo0axgitQhyNGhu6sEwTG1x du8UG7UO3WfjA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 742F1691CB for ; Thu, 8 Jan 2026 11:52: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 Dwu6h7UisZ1q for ; Thu, 8 Jan 2026 11:52:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898349; bh=Xpn+gOUIM0JCgAMNmGSwEUxOdQBcKNVZgPTaM2XcUEQ=; 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=m7LkjUYb+6qOZtP6iVMCb/e1JZ3lr731OW/CRm3Lzw5b1LBGV82jlFA8qHWNdNboc uFJqarfoKcWJr0j5b87MWBTMbmbnioKzXKgeVCJkpR9/Sj/DgmGDsNKP7fPUWbkuCA 3mynnNPveYngEXHfmtvfzkfPUS2dnu5d1T6PLo8HKC9908OwgiMNWdQuHCJ5Dkhyn7 J6DvUKLBo7GMZUdD8Vzs7Ql7j2NoulQALaUJbYXvDO+3UqwOX3mZ9FI6V/IPMu9sBa obPEWAgUondJN8mTsWdUQjR3dVGsDiAxAfCUYxkXn1zFo0axgitQhyNGhu6sEwTG1x du8UG7UO3WfjA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 62AC4691C4 for ; Thu, 8 Jan 2026 11:52:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898347; bh=8URt8HelkXMzKup1j0Ndj3a9Z+HYxJ14um4jwr2gMrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WNoD0jlahI8JPmZdyKDyvB5UwfpXacMMqDUX+2V0wYshukUQlumYLgZtzroraXM04 g9O8e4jTEgCNM05frTnqDPO0Pl8hvixWAQTFg7EGeiJKuc2Mp5FdQjizF91WTT30Sx ZvsDACbZM9Gxhpl72u2Q7jJOuF7vlJX9tT09DDzTACxihWfEdmD7cyISJvPr23j3GG KsBy9uZ1/xadtIMQz1JUomxh1L8ZI4rny8fObZAMOT3AQbriCNrgyQ5Pox+h9TzTNS zW/+SKXzIM4XYJPX0ANL6Yfpmiq+UgMOhb1kJ+UYQ2xI7p2n5PHAXhUelVMUUJxSTz urcKY2/Lv79CQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 71EA5691BF; Thu, 8 Jan 2026 11:52: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 7QNrOF69eqVi; Thu, 8 Jan 2026 11:52:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767898343; bh=4Frth0ufDXqjvkhPSfGpWxht/+gTEzjLGNNWWUmj9A0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jtqwRE7uVNY9fV689BWRZRcSdOfqqGK6x0ya867joFpP2s6Ulsm1TdHjhw7HmUhUW iIoqnjhctgmr9ZSQkrLq9d5R3TJ06Hj83+EVVPn2P8adX6A86EaPfK0qjujP+LSlBi axlFkwhEOswZq+Kdh6nVU2CAMaW/nVUf5mqQjuzQO7607UT3XNVZlbYJ7+qu7ou2Ob oNIM6T+QdfPG2lHptP3w2DqMdTTKJDKyKjSM68whBiB8ZVB4LL7c7Bor5YezoYuJB9 OBf35xi1QT9zSrBpyj9lRnFkQZMzy9c0nBoFYqqUBsruKBzXHwZKv3zQMtGLnNnlfi RVS3ZzfzzGomg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 01F6369101; Thu, 8 Jan 2026 11:52:22 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 8 Jan 2026 11:51:20 -0700 Message-ID: <20260108185149.1995917-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260108185149.1995917-1-sjg@u-boot.org> References: <20260108185149.1995917-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HBNOWFQA4XCRQVODVXJ4P3DOGMGX2OXB X-Message-ID-Hash: HBNOWFQA4XCRQVODVXJ4P3DOGMGX2OXB 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/21] ext4l: Use 64-bit operations for block calculations 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 current implementation is designed for 64-bit machines. Use the available functions and macros so that probing and reading work correctly on all machines. Signed-off-by: Simon Glass --- fs/ext4l/interface.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index f581c32359e..9a3fda48300 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "ext4_uboot.h" @@ -387,7 +388,7 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, /* Read sectors containing the superblock */ if (blk_dread(fs_dev_desc, - (part_offset + BLOCK_SIZE) / fs_dev_desc->blksz, + div_u64(part_offset + BLOCK_SIZE, fs_dev_desc->blksz), 2, buf) != 2) { ret = -EIO; goto err_free_buf; @@ -414,7 +415,7 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, * If write returns 0, the device is read-only (e.g. LUKS/blkmap_crypt) */ if (blk_dwrite(fs_dev_desc, - (part_offset + BLOCK_SIZE) / fs_dev_desc->blksz, + div_u64(part_offset + BLOCK_SIZE, fs_dev_desc->blksz), 2, buf) != 2) { sb->s_bdev->read_only = true; sb->s_flags |= SB_RDONLY; @@ -846,9 +847,11 @@ int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len, dst = buf; while (bytes_left > 0) { + u32 rem; + /* Calculate logical block number and offset within block */ - block = offset / blksize; - blk_off = offset % blksize; + block = div_u64_rem(offset, blksize, &rem); + blk_off = rem; /* Read the block */ bh = ext4_bread(NULL, inode, block, 0);