From patchwork Wed Dec 12 17:12:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruslan Trofymenko X-Patchwork-Id: 153578 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2051172ljp; Wed, 12 Dec 2018 09:12:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vm0hPiINqd9ADFgYjO+t7G8PsNGENuPCaY53/VsrtpHktHQRURwT/yWQcvYTDaYsvHq8Db X-Received: by 2002:a50:a347:: with SMTP id 65mr20120752edn.40.1544634763974; Wed, 12 Dec 2018 09:12:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544634763; cv=none; d=google.com; s=arc-20160816; b=q094dXCzR6FlUrb7ZPmLIth2ryTEM12yNeqWgftmQn5nTp5+6S0g+BrmjgosqllMzh U5i0N7vrlJXz/hIQT4WyTxYi4ftbkqfGbvSxSZ6YbLC5JR3Xdsrs3x5MBTslP5bF/haO o2jxqhke3o8HSegR2mETbxD6+9luq1F1HIO55OX8BUD3XcvITXDPogGa/MUspTesBKaY jVZqlHP+++ttDbY4tCP+D86qjhATBSmfcMatNBSa/yGZIVmzxmhzub6KYW2b19VN2jYH Nn5L8TdjbhFdBbfq+bWlre83/VWdQ5he/8kr7xSh+OjS87SNjP7EELMgy86O8HSzQ9x/ 08tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature; bh=FGDL7CGXhjmA6Xu7hdiLAWcY52FksH1klNNpAItm9tk=; b=rSexsTRJG/8018uWxKEehLGP+Wxdyn9qV/whyaYKF9XX3iyluCHYW+mEj+1MB54u6n frSGQl9NcPfudsjqtLBG9pOK+x2CtWwfcwotqtKIU29LbqVv0FUi/VTT3Z7904SlbAZR dcUFApx3aMBSMWDclHIbskKcOGuk/NUbOH2GRd9fAtEAkm19SXOyV9xljXzrkR6gV7us SoLkMYYtQBqpDe0U06UNHBgSw+o7uNSGOERMOetcZeeMkX1ptLFwBFiXv1De9J6Tgr+O GidOg1NRagEqTG6nKsMmUC3ZokExohfUFq2ZZy5QlI5Twjn4OyW9oLgM8SDgaRdd9Rs4 DT1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZpwhZDns; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id e19-v6si5657783ejj.140.2018.12.12.09.12.43; Wed, 12 Dec 2018 09:12:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZpwhZDns; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 0750FC2276C; Wed, 12 Dec 2018 17:12:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0A848C21F51; Wed, 12 Dec 2018 17:12:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 36F2BC21FE1; Wed, 12 Dec 2018 17:12:39 +0000 (UTC) Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by lists.denx.de (Postfix) with ESMTPS id B68CEC21FD2 for ; Wed, 12 Dec 2018 17:12:38 +0000 (UTC) Received: by mail-lf1-f66.google.com with SMTP id z13so14094194lfe.11 for ; Wed, 12 Dec 2018 09:12:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=veTJ1CqzhnJWnT/G+NcjVe+w+V622zMQKl82TBQKqis=; b=ZpwhZDns1PfkBonwuimr4HeS/BA6wcr+w+Qo2+J9OOj7YY+EECtM8Bk9dSt+pLfpIT y5Popi5diMNjkARPCh3dwX8isNgXkdfvEr206vqM6G9d9Pci4GL2kqJ55my2g/H1qAzM cp8RD9SczzrpjHuJ5dAo750qFXjUihxAtNFMY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=veTJ1CqzhnJWnT/G+NcjVe+w+V622zMQKl82TBQKqis=; b=bVHI5zqWSwMQNwtbNJpqbrEm9ZLADntEazFheSVjXD1oIhtiLzvtCa9i5pT7+0rw1v hYn1tY+JSOWA84P3ycLjBNEUdLuHkjjIdr0aZuklAesue+vML8/gJ/nScQZjslVyLMpN 1FpMvQAgi8GCslB4pwYeB5tvb82hYlURT0q/DG+p8e7QBsWee+ltKMjB+PJDLHUcNgp9 jfvYvHsaB2Xzumg5dXqKoiFRlO/P0pPusAA/BxeCkG2aXTxn0cEGSeWLOG2KcqW8ym5X Tvg4rvyhbyjc43iI79fZQbHG9+P/2uEzP0YhSVSCxgn5odT0jeGr7Wl4an7Kry5WBMbo I3Jg== X-Gm-Message-State: AA+aEWa4QJXSiw7G9Nvq55bFlP9iPXpptXX3TVRWIFQ+lTO4ihhiiRcI PyM+XSdVISn+SNOfUIyZVOwPUiKDpeY= X-Received: by 2002:a19:910d:: with SMTP id t13mr2371527lfd.98.1544634757870; Wed, 12 Dec 2018 09:12:37 -0800 (PST) Received: from kbp1-dhp-f54913.synapse.com ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id t81sm3358020lfe.84.2018.12.12.09.12.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Dec 2018 09:12:37 -0800 (PST) From: Ruslan Trofymenko To: u-boot@lists.denx.de Date: Wed, 12 Dec 2018 19:12:28 +0200 Message-Id: <1544634754-3435-2-git-send-email-ruslan.trofymenko@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544634754-3435-1-git-send-email-ruslan.trofymenko@linaro.org> References: <1544634754-3435-1-git-send-email-ruslan.trofymenko@linaro.org> Cc: Tom Rini , Praneeth Bajjuri , Alistair Strachan Subject: [U-Boot] [PATCH v2 1/7] cmd: part: Add 'number' sub-command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This sub-command serves for getting the partition index from partition name. Also it can be used to test the existence of specified partition. Signed-off-by: Ruslan Trofymenko Reviewed-by: Alistair Strachan Reviewed-by: Sam Protsenko Reviewed-by: Simon Glass Reviewed-by: Igor Opaniuk --- Changes in v2: None cmd/part.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cmd/part.c b/cmd/part.c index bfb6488..653e13c 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -24,6 +24,7 @@ enum cmd_part_info { CMD_PART_INFO_START = 0, CMD_PART_INFO_SIZE, + CMD_PART_INFO_NUMBER }; static int do_part_uuid(int argc, char * const argv[]) @@ -149,6 +150,9 @@ static int do_part_info(int argc, char * const argv[], enum cmd_part_info param) case CMD_PART_INFO_SIZE: snprintf(buf, sizeof(buf), LBAF, info.size); break; + case CMD_PART_INFO_NUMBER: + snprintf(buf, sizeof(buf), "%d", part); + break; default: printf("** Unknown cmd_part_info value: %d\n", param); return 1; @@ -172,6 +176,11 @@ static int do_part_size(int argc, char * const argv[]) return do_part_info(argc, argv, CMD_PART_INFO_SIZE); } +static int do_part_number(int argc, char * const argv[]) +{ + return do_part_info(argc, argv, CMD_PART_INFO_NUMBER); +} + static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc < 2) @@ -185,6 +194,8 @@ static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return do_part_start(argc - 2, argv + 2); else if (!strcmp(argv[1], "size")) return do_part_size(argc - 2, argv + 2); + else if (!strcmp(argv[1], "number")) + return do_part_number(argc - 2, argv + 2); return CMD_RET_USAGE; } @@ -206,5 +217,8 @@ U_BOOT_CMD( " part can be either partition number or partition name\n" "part size \n" " - set environment variable to the size of the partition (in blocks)\n" - " part can be either partition number or partition name" + " part can be either partition number or partition name\n" + "part number \n" + " - set environment variable to the partition number using the partition name\n" + " part must be specified as partition name" );