From patchwork Tue Nov 27 19:57:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruslan Trofymenko X-Patchwork-Id: 152163 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp216408ljp; Tue, 27 Nov 2018 12:11:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/UKB8sXdgbiU1e18z7/3fdCht2i+jGgMVOztA475i9jleqcfeu6k68A29suX0Hb1uRK3ySX X-Received: by 2002:a50:c2d9:: with SMTP id u25mr23840782edf.280.1543349476244; Tue, 27 Nov 2018 12:11:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543349476; cv=none; d=google.com; s=arc-20160816; b=XoRYmxLpTqmpYWy4uGSZ4tZQdvW6/PzX4a38B8gg6EOJUPqwJidEAwIaU34oKezjAQ 8xugtfuco2froIia8MJw8ba8Zs5MG8VMFS9DtKx70Yrf1hJLlE2ES731FISDsxyQPwdg Z/6NhYnAeOTVPJo5r1CSHVcmvMOqOKKQCU5sELL+L1Rg/N3q1+zXcuVK7O0NtTiL6nWW 8Vu9pKDeGvpAkGTjwjpA/PRUcq0dQWFjVbNrMshCowltUAKKby1nDxD3WPlL2TzD63Ai Su9OvdNGoFgfd5lSgj77R52Dv7QCH87snRuc5db0TFHWkMbLnJJ5gj+tm2pnwjPMJ1kN 9rsQ== 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=ZRxvQRAnOnWWjm5Y4cDGVkY+nKkM20wC+SA92HJgcuY=; b=Dngkci3Y2pshlv/oVIOM5wWpj49W+zMNgfE7hdPGHixehZf5/wjCmDgG3940AfvBLM YGO40Co/SJDSsAQ18FGrXdKqa0M0EV2FKW2/+CzrfKtTeoYLvtG0AwfavJnLHJL9d6Y9 g9fweyEyx+1y2UvSwhwvo487l3vNqJrf9vHxfpaaR0rn+g6Ch7zq8j9Y63hqetIsIyoQ eoMgGArVMyWk8bggYG3/suphysLQFIL7603FPOCVv8lRFQC5VTz6CeAcVEdc7s4VfH69 WRYsfEBCj+sBi37c4IzRMPUiyx/rHd3aWrIBXCOQDOz+0PGbxOtIBKr0nu3xXCPPJ38G NYCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cWKCEnpE; 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 t37si492176eda.73.2018.11.27.12.11.15; Tue, 27 Nov 2018 12:11:16 -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=cWKCEnpE; 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 B1A31C2215A; Tue, 27 Nov 2018 20:10:56 +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 6FC6CC221B9; Tue, 27 Nov 2018 20:10:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 181E9C21EAE; Tue, 27 Nov 2018 19:57:27 +0000 (UTC) Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by lists.denx.de (Postfix) with ESMTPS id A68A9C21DD7 for ; Tue, 27 Nov 2018 19:57:26 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id x85-v6so21221462ljb.2 for ; Tue, 27 Nov 2018 11:57:26 -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=s5tuNFuL3KUFvnEbMUeDwm3zdzbt8dPfpwD+7jSySnI=; b=cWKCEnpEj/MhLBa4NP4TWmRAjMNfc7gWfkpSK3bm3rUjwXB82BFCMcwfr/mH1cZZWH 7Op55sfRxL/15ye9829VNV+XIAm77qyL90rWrACq4dZf5UVwTuwFNXUZBDWI6JPLz5vq cg1e74fa4fN9E5o58FFQJ4iajmqyrt2VcMPlk= 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=s5tuNFuL3KUFvnEbMUeDwm3zdzbt8dPfpwD+7jSySnI=; b=ScJiYZUMc7CUga+N8YCOr6zCVheYxgk/ptcRVGwtTO+YkzSO/XATJRbuDSAchkNOid KXiJa7vBRrY34kQOz8ypOYI2DoeDwWQf/u5vLfWe5LjVW7FxL3EUvPsoJtJvy44MOoYq Vv0YZ6i2LdFvSag7cD1xaY5Tjz/us/RcANSAFx+yZgj1A1VdKJWID2hKDkMJrNbCk3JR ZGKSvM/hp2TFfZFvD6tMSKBcYg/luJ202lwHH9xzBWgRYomzhqCqVzOu8WDf4BWYimYl /ioBnbUe9C3e2XeRre88dt/JT46qZ++Rhi7CToUfu/SFcuFRHcCZKFGbJFCqxznzM+yq fErw== X-Gm-Message-State: AA+aEWb9BoVdJC5S+ru586Iq7iEyEj5JC+/JWo+c+2eN9Vh2xQVvoG/p 7ZeHeR5kYzazzcdasjJJ4fqIgaL/r1o= X-Received: by 2002:a2e:9783:: with SMTP id y3-v6mr20426505lji.167.1543348645773; Tue, 27 Nov 2018 11:57:25 -0800 (PST) Received: from kbp1-dhp-f54913.synapse.com ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id g12-v6sm738725lja.74.2018.11.27.11.57.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Nov 2018 11:57:25 -0800 (PST) From: Ruslan Trofymenko To: u-boot@lists.denx.de Date: Tue, 27 Nov 2018 21:57:16 +0200 Message-Id: <1543348642-31045-2-git-send-email-ruslan.trofymenko@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543348642-31045-1-git-send-email-ruslan.trofymenko@linaro.org> References: <1543348642-31045-1-git-send-email-ruslan.trofymenko@linaro.org> X-Mailman-Approved-At: Tue, 27 Nov 2018 20:10:30 +0000 Cc: Tom Rini , Praneeth Bajjuri , Alistair Strachan Subject: [U-Boot] [PATCH 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: Simon Glass --- 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" );