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 C8FAEE7D266 for ; Tue, 26 Sep 2023 08:47:25 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C9DC86D22; Tue, 26 Sep 2023 10:47:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinylab.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 823AB86D4A; Tue, 26 Sep 2023 10:47:23 +0200 (CEST) Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) (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 B173186BCE for ; Tue, 26 Sep 2023 10:47:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinylab.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng@tinylab.org X-QQ-mid: bizesmtp63t1695718021tp7qc85d Received: from pek-vx-bsp2.wrs.com ( [60.247.85.88]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 26 Sep 2023 16:47:00 +0800 (CST) X-QQ-SSF: 01200000000000F0I000000A0000000 X-QQ-FEAT: ILHsT53NKPjiLoKPHaqoE3GVR/rsmlj3FUxxhIdF9q1W9XCMVkFpjyGlorbtI 6Hkyjm6DaI3YSf9KR3ReUutBe6sMpOXNy5FNV4F99nu7Od4Ca4/MqcTI7ilQcaHchCXryX+ AlO1bs6XFo9D47yciANqmACq80WKTlhW6XIpcXGQlVI4ou2Y2gsgzlyvYpcLBBc6op9ICfU HWt9hHUV0LxLcKbwbghEDA8n+mYYGemw5Fhlfp7wMLfTQ5EE+HYzyOO//jDMloALYwXM0RE STag89YH1QOZYOmtt/tZy0Hq5ua97mc0a7EUGzw0jsvj2IJ5x6/Y7xIO1NXGMZ8E8xZSNSI 24WwTThDfkSlGXs9AE8BdFmjcu4czyHiWvDjljDU+i93UNF5YQ= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 3404121737275044572 From: Bin Meng To: Simon Glass , U-Boot Mailing List Cc: Heinrich Schuchardt Subject: [PATCH 03/15] blk: sandbox: Support binding a device with a given logical block size Date: Tue, 26 Sep 2023 16:43:33 +0800 Message-Id: <20230926084346.2237483-4-bmeng@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230926084346.2237483-1-bmeng@tinylab.org> References: <20230926084346.2237483-1-bmeng@tinylab.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz7a-0 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 Allow optionally set the logical block size of the host device to bind in the "host bind" command. If not given, defaults to 512. Signed-off-by: Bin Meng --- cmd/host.c | 16 +++++++++++++--- drivers/block/host-uclass.c | 15 ++++++++++++--- include/sandbox_host.h | 7 +++++-- test/dm/blk.c | 7 ++++--- test/dm/host.c | 6 +++--- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/cmd/host.c b/cmd/host.c index b924940ffb..2334ccd9bc 100644 --- a/cmd/host.c +++ b/cmd/host.c @@ -13,6 +13,7 @@ #include #include #include +#include static int do_host_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) @@ -45,6 +46,7 @@ static int do_host_bind(struct cmd_tbl *cmdtp, int flag, int argc, struct udevice *dev; const char *label; char *file; + unsigned long blksz = DEFAULT_BLKSZ; int ret; /* Skip 'bind' */ @@ -59,12 +61,19 @@ static int do_host_bind(struct cmd_tbl *cmdtp, int flag, int argc, argv++; } - if (argc != 2) + if (argc < 2 || argc > 3) return CMD_RET_USAGE; label = argv[0]; file = argv[1]; + if (argc > 2) { + blksz = dectoul(argv[2], NULL); + if (blksz < DEFAULT_BLKSZ || !is_power_of_2(blksz)) { + printf("blksz must be >= 512 and power of 2\n"); + return CMD_RET_FAILURE; + } + } - ret = host_create_attach_file(label, file, removable, &dev); + ret = host_create_attach_file(label, file, removable, blksz, &dev); if (ret) { printf("Cannot create device / bind file\n"); return CMD_RET_FAILURE; @@ -253,7 +262,8 @@ U_BOOT_CMD( "host save hostfs - [] - " "save a file to host\n" "host size hostfs - - determine size of file on host\n" - "host bind [-r]