From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3091FC76196 for ; Tue, 11 Apr 2023 18:42:58 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 420B68574A; Tue, 11 Apr 2023 20:42:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="IM5ScyOp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 23C7C8574A; Tue, 11 Apr 2023 20:42:54 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E938C85D95 for ; Tue, 11 Apr 2023 20:42:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 96D7360DFA; Tue, 11 Apr 2023 18:42:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8590C433EF; Tue, 11 Apr 2023 18:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681238569; bh=geWxzebE0VJXyLKQ7s8rSBTpFZFynLwWpxMYKiprY6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IM5ScyOp3Za9+F5oQo0xf8PVuIW6CG6vwFnYCXb/OZ+ZywjPxgHgV7HO1tZzDCJ0A yxe8hSE+YysjtwfvBU0nxFFB1JnLVl7++hcKe8SAruBsqSbUZD1Mj53hW5BwlrBLF/ yfsN0cDAm8Vub3SSKrl9Wi0Hnx5s0Yw0IRJHpb5SCYJjL3+wENT70XNCLNObFxVn/L /Ex2JT+gSoqlD4ctul1rXp99RjoSSNE0zKHHcs9+skeX0C2LjaSlDL/9W7sCch7Vug Mc6gJubMM+NhFlzD25dc6vWecEFq/j+daRE3+lWAoGNDQiDB3GeWoyu94QcUPyBXYn bHKd8lHzs2kyg== Received: by pali.im (Postfix) id 40EBD854; Tue, 11 Apr 2023 20:42:46 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese Cc: u-boot@lists.denx.de Subject: [PATCH v2 u-boot-mvebu] cmd: mvebu/bubt: a38x: Do not hardcode SATA block size to 512 Date: Tue, 11 Apr 2023 20:35:51 +0200 Message-Id: <20230411183551.16431-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230329192558.12417-3-pali@kernel.org> References: <20230329192558.12417-3-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Find SATA block device by blk_get_devnum_by_uclass_id() function and read from it the real block size of the SATA disk. In case of error, fallback back to 512 bytes. Signed-off-by: Pali Rohár --- cmd/mvebu/bubt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index 49797b23144b..b3ac7a589d81 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -925,8 +925,11 @@ static int check_image_header(void) offset = le32_to_cpu(hdr->srcaddr); size = le32_to_cpu(hdr->blocksize); - if (hdr->blockid == 0x78) /* SATA id */ - offset *= 512; + if (hdr->blockid == 0x78) { /* SATA id */ + struct blk_desc *blk_dev = IS_ENABLED(BLK) ? blk_get_devnum_by_uclass_id(UCLASS_SCSI, 0) : NULL; + unsigned long blksz = blk_dev ? blk_dev->blksz : 512; + offset *= blksz; + } if (offset % 4 != 0 || size < 4 || size % 4 != 0) { printf("Error: Bad A38x image blocksize.\n"); -- 2.20.1