From patchwork Mon Sep 2 18:49:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Paukrt X-Patchwork-Id: 1979722 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=email.cz header.i=@email.cz header.a=rsa-sha256 header.s=szn20221014 header.b=uq+IMVJM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WyHqG1VgBz1yZ9 for ; Tue, 3 Sep 2024 04:49:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B84A9888FB; Mon, 2 Sep 2024 20:49:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=email.cz 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; secure) header.d=email.cz header.i=@email.cz header.b="uq+IMVJM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 33F5388A0A; Mon, 2 Sep 2024 20:49:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mxc-1-40a.seznam.cz (mxc-1-40a.seznam.cz [IPv6:2a02:598:128:8a00::1000:40a]) (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 359CA88860 for ; Mon, 2 Sep 2024 20:49:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=email.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=tomaspaukrt@email.cz Received: from email.seznam.cz by smtpc-mxc-6f6fb7bdc4-w9hp5 (smtpc-mxc-6f6fb7bdc4-w9hp5 [2a02:598:128:8a00::1000:40a]) id 145428f9eaa09a5314daa6e1; Mon, 02 Sep 2024 20:49:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=email.cz; s=szn20221014; t=1725302960; bh=ssD5Ovu1nocnf9V7Rzhs/QeK/ybLLbKjohu2wQf2O40=; h=Received:From:To:Cc:Subject:Date:Message-Id:Mime-Version:X-Mailer: Content-Type:Content-Transfer-Encoding; b=uq+IMVJM5oDg1lVaWIsluYeW+EZwEIy0ox3XuxW486QvexWLWawPbaubxIBPUbD3b pnKqGa1BaFn5cho2HY24KlUyhnUbUDcNU3+XN05RLUTp/FcoDBg/inM0HWpQp9OCrK cCKuPS+C1RH2YQbGSqhB8xzgXea6JInFU/N5FlhOFv/TVg8jGn94gqi2haPnsvbchm NJDhxc1WWKs9+9e/D8d6466gZPf9r4AipJJ19udVR2Pd4kcBftSJeJi3SO/IGDd46W 2ehqUjVPuEafHRXtzuR4Dm8KXMAfbCv73ybqnP3a/joM5rQhzznFHbrOvPejAt2C6p y6na27iL3iUdw== Received: from 184-143.ktuo.cz (184-143.ktuo.cz [82.144.143.184]) by email.seznam.cz (szn-UNKNOWN-unknown) with HTTP; Mon, 02 Sep 2024 20:49:17 +0200 (CEST) From: "Tomas Paukrt" To: Cc: , Subject: =?utf-8?q?=5BPATCH_v3=5D_cmd=3A_mmc=3A_Allow_using_partition_name_i?= =?utf-8?q?n_mmc_erase_command_?= Date: Mon, 02 Sep 2024 20:49:17 +0200 (CEST) Message-Id: <3hD.ZbWV.1{t85GxWb7T.1crWYj@seznam.cz> Mime-Version: 1.0 (szn-mime-2.1.61) X-Mailer: szn-UNKNOWN-unknown 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 The mmc erase command currently requires blk# and cnt parameters which can be obtained using the part start and part size commands if the entire partition needs to be erased. Simplify the use of the mmc erase command by allowing the partition name to be specified directly. Signed-off-by: Tomas Paukrt Reviewed-by: Quentin Schulz --- Changes since v1: - Swapped init_mmc_device call and argc check - Removed round down info.size to a multiple of erase_grp_size - Split the syntax into two separate lines --- cmd/mmc.c | 17 +++++++++++++---- doc/usage/cmd/mmc.rst | 6 +++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/cmd/mmc.c b/cmd/mmc.c index 7244a90..2fc05f9 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -472,18 +472,26 @@ static int do_mmc_erase(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct mmc *mmc; + struct disk_partition info; u32 blk, cnt, n; - if (argc != 3) + if (argc < 2 || argc > 3) return CMD_RET_USAGE; - blk = hextoul(argv[1], NULL); - cnt = hextoul(argv[2], NULL); - mmc = init_mmc_device(curr_device, false); if (!mmc) return CMD_RET_FAILURE; + if (argc == 3) { + blk = hextoul(argv[1], NULL); + cnt = hextoul(argv[2], NULL); + } else if (part_get_info_by_name(mmc_get_blk_desc(mmc), argv[1], &info) >= 0) { + blk = info.start; + cnt = info.size; + } else { + return CMD_RET_FAILURE; + } + printf("\nMMC erase: dev # %d, block # %d, count %d ... ", curr_device, blk, cnt); @@ -1271,6 +1279,7 @@ U_BOOT_CMD( "mmc swrite addr blk#\n" #endif "mmc erase blk# cnt\n" + "mmc erase partname\n" "mmc rescan [mode]\n" "mmc part - lists available partition on current mmc device\n" "mmc dev [dev] [part] [mode] - show or set current mmc device [partition] and set mode\n" diff --git a/doc/usage/cmd/mmc.rst b/doc/usage/cmd/mmc.rst index 5a64400..55391fd 100644 --- a/doc/usage/cmd/mmc.rst +++ b/doc/usage/cmd/mmc.rst @@ -15,6 +15,7 @@ Synopsis mmc read addr blk# cnt mmc write addr blk# cnt mmc erase blk# cnt + mmc erase partname mmc rescan [mode] mmc part mmc dev [dev] [part] [mode] @@ -44,12 +45,15 @@ The 'mmc write' command writes raw data to MMC device from memory address with b cnt block count -The 'mmc erase' command erases *cnt* blocks on the MMC device starting at block *blk#*. +The 'mmc erase' command erases *cnt* blocks on the MMC device starting at block *blk#* or +the entire partition specified by *partname*. blk# start block offset cnt block count + partname + partition name The 'mmc rescan' command scans the available MMC device.