From patchwork Mon Feb 26 21:17:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 129725 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp653535lja; Mon, 26 Feb 2018 13:18:56 -0800 (PST) X-Google-Smtp-Source: AG47ELuFXQEijrcnu+QfXYSF1fXXYNv8b7UkXQzfGBERoJ3u8lwvq5KtrZNOW+Hj+Oyvm/S82E/1 X-Received: by 10.80.222.77 with SMTP id a13mr12211454edl.176.1519679936302; Mon, 26 Feb 2018 13:18:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519679936; cv=none; d=google.com; s=arc-20160816; b=tUHOpgSsVS5o/K2pgIA/8jlnRuJIDgXA4EljeOMnJ8BX7zzIt0VIo8ByP+53tsys/K tY9jMU5XPbjZOatjm3IuHCH4/1fkMOpg1Qlcv4NgJkVKLiWtwpIH/3uyoWAie5JWZRl3 jDULPYJe8AHYjzieLOzfBvYfBE7lRBsVFSYuUVFcrIwyv0G9iHpeJ+9Z70bEir0lvsCr uqpOPWhEcOMrAJ7mIK1U6cHn208O5PEU8n3+E2sr9gFT5r6c7WBt0DPYLPncdPfuXGFD PIhenx03fvPygHGxxy7HMEcdi5FcE7z6dypepBdYO6h4zFs6wq/jO3ik6IitwvMG22fs CclA== 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:arc-authentication-results; bh=RJfn8Y84zFokEWBAAaGkz17AksAqdb9bm/alZQWsdhE=; b=LYqHKeVXykXInLyrbra67OrxvR0Hb67ddYviuM+8wWikJDUH1bMh5oiCdcU/sSsrw6 qTj4GxduGA3tYxDMpxdbwzJ4gB8uEQsm2Kx6JIC35IsTLEjT4rpd9h3WVGQaZslVhJC5 05h0d5j7jlQ1hfv70UWDThtr9lQyzbRFOqddc1MT3eKNv++M+z6tirs74cbwuwic9Nrm dM+apM2hwajcKWwyIvsH8fy2WUdhcdxf++uHXjQPWyyNBrhs3FeuNFFfRuVQOBxC13Yh SjNuAhtKVeCAnJeCS2zj54omOd5knHiekq6jIBNZZvxdP9R0KOPHLZbNQ0+KC7IcVHnz ka/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Jwe9spnD; 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 n2si763172edl.109.2018.02.26.13.18.56; Mon, 26 Feb 2018 13:18:56 -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=Jwe9spnD; 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 D36A1C21F50; Mon, 26 Feb 2018 21:18: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 79823C2216B; Mon, 26 Feb 2018 21:18:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C5BB7C21E2F; Mon, 26 Feb 2018 21:18:09 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by lists.denx.de (Postfix) with ESMTPS id 84ED3C21E5B for ; Mon, 26 Feb 2018 21:18:05 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id f14so22693725wre.8 for ; Mon, 26 Feb 2018 13:18:05 -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=DboOJj8cL/jJUi1FPmzsY98S4GJ66FuscNfiADcPWq4=; b=Jwe9spnDFDs0cTVYWE52S7/oZJPQ00bINq6/+/GE/3Opy+PRxcLRKXJApq5WkCqNfU FIvxXQ+Y0jWlQ/1f98TTWiM8h6qEacPxl0oHZi7C++1xFCOaqMas1fhv46xDa0S23PgT rXJl7sNVqHUlc9t3xm7C29Gd2KwssPSF+cnXQ= 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=DboOJj8cL/jJUi1FPmzsY98S4GJ66FuscNfiADcPWq4=; b=Z25VLWzGn7tqGfITp2nIZ3HH/p1EYCnKmCenFuZ2nHv3G9/2A6T6FD1xCBXzMOZedg sgF4br2WnINtcppQ1yhYay/GP0uWkeirQQ5H3ZOLH97Tt8dhrqQas9yZzu7+45+n1h+v 6iGw8f7En7dH9/J5gzFEJotEfdBasi8dG3Qq+yyP4mytSUM3e40HI+9HKxQrLIg+enJ2 DDqNywJ3xzPf4RU9XfSNsednm2xo8W64kgeggmdrDJ9ZFZU+J1mwHHEPK/UObWScjc2z k8sDaDQuA/8clYi9OVJmcefQE7XLlMimI0AOqEzMwREvsZW6evyDZG1uuv6q7Xj0MhBY s52Q== X-Gm-Message-State: APf1xPBtkwjehu1umzyipUwJFwXO7a9bafyOMgWFwiMZNcevOP6mkLOg Dp14Bls6LjNBQbqQXkFfqlQdFCj5oCk= X-Received: by 10.223.157.22 with SMTP id k22mr9935475wre.208.1519679884747; Mon, 26 Feb 2018 13:18:04 -0800 (PST) Received: from localhost ([195.238.92.76]) by smtp.gmail.com with ESMTPSA id l8sm8291483wmf.39.2018.02.26.13.18.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Feb 2018 13:18:03 -0800 (PST) From: Sam Protsenko To: u-boot@lists.denx.de Date: Mon, 26 Feb 2018 23:17:59 +0200 Message-Id: <20180226211801.16060-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180226211801.16060-1-semen.protsenko@linaro.org> References: <20180226211801.16060-1-semen.protsenko@linaro.org> Cc: Tom Rini , igor.opaniuk@linaro.org, Praneeth Bajjuri , Neil Williams Subject: [U-Boot] [PATCH 1/3] cmd: part: Allow passing partition name to start and size 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" Allow passing the partition name to "part start" and "part size" commands, so we can avoid magic numbers in the environment. Consider one real use-case: in include/environment/ti/boot.h we have commands like these: setenv boot_part 9 part start mmc ${mmcdev} ${boot_part} boot_start part size mmc ${mmcdev} ${boot_part} boot_size mmc read ${loadaddr} ${boot_start} ${boot_size} Now suppose that we have changed the partition table and boot_part now is 10. We will need to fix commands above. And anyone who relies on these boot commands, will need to change them accordingly, too (this was an actual case in our lab while testing Linux boot on Android environment). By providing the option to pass partition name instead, we fix mentioned issue, by eliminating the necessity to use magic numbers. Signed-off-by: Sam Protsenko Reviewed-by: Lukasz Majewski --- cmd/part.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/cmd/part.c b/cmd/part.c index 746bf40b2d..fd8825a7ec 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -113,6 +113,7 @@ static int do_part_start(int argc, char * const argv[]) struct blk_desc *desc; disk_partition_t info; char buf[512] = { 0 }; + char *endp; int part; int err; int ret; @@ -122,15 +123,20 @@ static int do_part_start(int argc, char * const argv[]) if (argc > 4) return CMD_RET_USAGE; - part = simple_strtoul(argv[2], NULL, 0); - ret = blk_get_device_by_str(argv[0], argv[1], &desc); if (ret < 0) return 1; - err = part_get_info(desc, part, &info); - if (err) - return 1; + part = simple_strtoul(argv[2], &endp, 0); + if (*endp == '\0') { + err = part_get_info(desc, part, &info); + if (err) + return 1; + } else { + part = part_get_info_by_name(desc, argv[2], &info); + if (part == -1) + return 1; + } snprintf(buf, sizeof(buf), LBAF, info.start); @@ -147,6 +153,7 @@ static int do_part_size(int argc, char * const argv[]) struct blk_desc *desc; disk_partition_t info; char buf[512] = { 0 }; + char *endp; int part; int err; int ret; @@ -156,15 +163,20 @@ static int do_part_size(int argc, char * const argv[]) if (argc > 4) return CMD_RET_USAGE; - part = simple_strtoul(argv[2], NULL, 0); - ret = blk_get_device_by_str(argv[0], argv[1], &desc); if (ret < 0) return 1; - err = part_get_info(desc, part, &info); - if (err) - return 1; + part = simple_strtoul(argv[2], &endp, 0); + if (*endp == '\0') { + err = part_get_info(desc, part, &info); + if (err) + return 1; + } else { + part = part_get_info_by_name(desc, argv[2], &info); + if (part == -1) + return 1; + } snprintf(buf, sizeof(buf), LBAF, info.size); @@ -207,6 +219,8 @@ U_BOOT_CMD( " flags can be -bootable (list only bootable partitions)\n" "part start \n" " - set environment variable to the start of the partition (in blocks)\n" + " part can be either partition number or partition name\n" "part size \n" - " - set environment variable to the size of the partition (in blocks)" + " - set environment variable to the size of the partition (in blocks)\n" + " part can be either partition number or partition name" ); From patchwork Mon Feb 26 21:18:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 129727 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp654917lja; Mon, 26 Feb 2018 13:20:32 -0800 (PST) X-Google-Smtp-Source: AH8x226ydNDF4VM1KEsr24/d74ZmZ5XOsnuGJmX1jtOPL/fedMpAYt47b/WjlklO94eN9ub6VEjd X-Received: by 10.80.151.200 with SMTP id f8mr15866935edb.10.1519680032560; Mon, 26 Feb 2018 13:20:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519680032; cv=none; d=google.com; s=arc-20160816; b=BYQY+nQ2oOsPv7A4gQlXMVfI9wOYbkgmlXUPJOkSVg1sYPWtRf3BXuniCVb9wLxtMu BNoUnDTv8c3cCdRApACV2stEZfDYZOqO1tPN17yRw+aKT6nHd4V0JYB2E0Fn6gPQNjdN KG9Xwbv/F2XXOuH2fj6L7OGpk2WO0hcZ3Y+2Uh6d3xY/ymJ79V2ZRa2LVgS8vIUoX3Nk 6D88UOQbmAmAmCY8trcaFwc8ni25SI/eu5kMCDxKS6ci9E+NDGHFO2cNkiT1U7L/8moS 3I/Pl0oIobho42h+joo1vAD9KBGsGBAeeX4iaIHJ9h8U6oJA9Q9YNiKTcAslU0n73yOF Fldg== 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:arc-authentication-results; bh=84aCjuC9M4Y7E6k4BpfX06F1GA7SoTFWGROSgIxn3ys=; b=sHBSOhAo5LHkgjLfOzj0hgrf57T/UztyZ2DlB7tOczrMrlYK/U04D+lZ0uERMUR+ZE nBtWaCmL0rwhXSCdn7zMvHu1eWLWFx0SWyCDFgjidGuqkVY5JL0Az3luQjPgF5qNrmg9 staUZSkGKCQMPgoUfyU2Ca3vgPxjmnkHZJceQP1B990TR4gnSqMtoLWkr7qnO46IzO90 g6UJ+GSutctANPp9iukPL0eHaX8I4M2QbCdHPtCcBax4EQLKzgmVaZeqqcC1+azy0Jyy YqIoJIf5WY9mPLQP5BaPjz5Ul/1b39JfxjyEMbZQ9WiwTVYEfb36+84f9ro9m6/LrCPF IIgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=P7fjBn9O; 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 u33si1080320edc.244.2018.02.26.13.20.32; Mon, 26 Feb 2018 13:20:32 -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=P7fjBn9O; 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 306A9C2215A; Mon, 26 Feb 2018 21:19:00 +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 58FAFC21F32; Mon, 26 Feb 2018 21:18:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AB5B2C21F06; Mon, 26 Feb 2018 21:18:10 +0000 (UTC) Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by lists.denx.de (Postfix) with ESMTPS id 05953C21F31 for ; Mon, 26 Feb 2018 21:18:07 +0000 (UTC) Received: by mail-wr0-f193.google.com with SMTP id w77so22683855wrc.6 for ; Mon, 26 Feb 2018 13:18:07 -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=cFuZilVNCUGeKGhd9/wfJPxNyd6e5Jt8MRW8da8wYYc=; b=P7fjBn9OxmuGaAGqgsooLsB5SQWNKFBVPhNWJUq+BLh/lZK0t12hPXtK7l8Yo4nuqG rro2DCGt0XBbvVDcx0AjIvgHtSoLHS1ZEcD8F0iVq3gKrIqRvm2WojQ7oRkVaHou3O+L 61aETwLVkOOphTjr1SkVxzUmnZT52CxLhGslQ= 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=cFuZilVNCUGeKGhd9/wfJPxNyd6e5Jt8MRW8da8wYYc=; b=swiYhZYQiBW55c15KzcaEVls+TBZKWC5sYrW7Nd2fGpiDl7xPkcYJW4QkvTU1k1ARr LB9/JQi8Df4rYGjyKb5XWys60Yj0a1PA0qFy6U+RUBkM/jG+vHF+EBRb3lZtXFZc6qUT LoG7ujOXBAE+HxsbzaeJou8au5LPOlOgZdu5pEMnrJ7HMBXgfCx0S04DiMOl1blNlxCK WBzLrDSjvlb+mO8MKK0Q4G7c5LIKh6bWVBkpnMsgcEFN+SUngoRg7z5Ms9QldHVxhggw QD2+lnt6//WaPp+s/6TRJPa83FeNSlTTQvx96jktW/NJhszalDixbFlkPmjWKQQ1xsYg suPg== X-Gm-Message-State: APf1xPA1OBihmoSHdy68cgbeI1MkEk0ZMQF4ibpXY93UKYsK6KBcoqB+ DtXwTBED75SVlgtbMozeyOp+jXmIW2Q= X-Received: by 10.223.130.76 with SMTP id 70mr10273929wrb.95.1519679886295; Mon, 26 Feb 2018 13:18:06 -0800 (PST) Received: from localhost ([195.238.92.76]) by smtp.gmail.com with ESMTPSA id e15sm9949135wmd.26.2018.02.26.13.18.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Feb 2018 13:18:05 -0800 (PST) From: Sam Protsenko To: u-boot@lists.denx.de Date: Mon, 26 Feb 2018 23:18:00 +0200 Message-Id: <20180226211801.16060-3-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180226211801.16060-1-semen.protsenko@linaro.org> References: <20180226211801.16060-1-semen.protsenko@linaro.org> Cc: Tom Rini , igor.opaniuk@linaro.org, Praneeth Bajjuri , Neil Williams Subject: [U-Boot] [PATCH 2/3] cmd: part: Extract common code to separate function 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" Refactor the code for "part start" and "part size" commands to avoid code duplication. Signed-off-by: Sam Protsenko Reviewed-by: Lukasz Majewski --- cmd/part.c | 61 +++++++++++++++++++++++-------------------------------------- 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/cmd/part.c b/cmd/part.c index fd8825a7ec..ec791fdc5d 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -22,6 +22,11 @@ #include #include +enum cmd_part_info { + CMD_PART_INFO_START = 0, + CMD_PART_INFO_SIZE, +}; + static int do_part_uuid(int argc, char * const argv[]) { int part; @@ -108,7 +113,7 @@ static int do_part_list(int argc, char * const argv[]) return 0; } -static int do_part_start(int argc, char * const argv[]) +static int do_part_info(int argc, char * const argv[], enum cmd_part_info param) { struct blk_desc *desc; disk_partition_t info; @@ -138,7 +143,17 @@ static int do_part_start(int argc, char * const argv[]) return 1; } - snprintf(buf, sizeof(buf), LBAF, info.start); + switch (param) { + case CMD_PART_INFO_START: + snprintf(buf, sizeof(buf), LBAF, info.start); + break; + case CMD_PART_INFO_SIZE: + snprintf(buf, sizeof(buf), LBAF, info.size); + break; + default: + printf("** Unknown cmd_part_info value: %d\n", param); + return 1; + } if (argc > 3) env_set(argv[3], buf); @@ -148,44 +163,14 @@ static int do_part_start(int argc, char * const argv[]) return 0; } -static int do_part_size(int argc, char * const argv[]) +static int do_part_start(int argc, char * const argv[]) { - struct blk_desc *desc; - disk_partition_t info; - char buf[512] = { 0 }; - char *endp; - int part; - int err; - int ret; - - if (argc < 3) - return CMD_RET_USAGE; - if (argc > 4) - return CMD_RET_USAGE; - - ret = blk_get_device_by_str(argv[0], argv[1], &desc); - if (ret < 0) - return 1; - - part = simple_strtoul(argv[2], &endp, 0); - if (*endp == '\0') { - err = part_get_info(desc, part, &info); - if (err) - return 1; - } else { - part = part_get_info_by_name(desc, argv[2], &info); - if (part == -1) - return 1; - } - - snprintf(buf, sizeof(buf), LBAF, info.size); - - if (argc > 3) - env_set(argv[3], buf); - else - printf("%s\n", buf); + return do_part_info(argc, argv, CMD_PART_INFO_START); +} - return 0; +static int do_part_size(int argc, char * const argv[]) +{ + return do_part_info(argc, argv, CMD_PART_INFO_SIZE); } static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) From patchwork Mon Feb 26 21:18:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 129726 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp654280lja; Mon, 26 Feb 2018 13:19:48 -0800 (PST) X-Google-Smtp-Source: AG47ELvB/rXiFRhDQ1ggmlzhcPWGMDMBZPZQeXtJg70koPMeijvnkxb/DMZeKsQPpR++PgACEpfg X-Received: by 10.80.190.133 with SMTP id b5mr6245813edk.246.1519679987594; Mon, 26 Feb 2018 13:19:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519679987; cv=none; d=google.com; s=arc-20160816; b=ea9TqXmZKbxCjsWzQLixjgKNxNyggnZPpcv6hHG9bbyW9XbXFv4FtJuBghrOll0uWx 5CTmJZp/2+Ua+kDxBWxh4Ve+2mxoh3yQVrPy90pQF0N/WhEPKn50TFnGwnCSUlcmDTnL fqo9GWJ3cMUsnabwN9MtVLO3Ji98tKXInF3AfpF9iHClFjyJi8AotCFO2yaQ4L8VPxeL xVe/8mZzyB4RRdirHFK2jVTiTz33B/C9KZ7FFKiAxkvrmlzX5swpxiqkkMuEU+pZDDYD fBdu6cNCaQioQyll1cY7hLFLL+sHN9LFOv667c10c+HXpV5RbwNguKxD3wGVkJ75YfCI LIEQ== 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:arc-authentication-results; bh=QNMkZnE4xwACerUQxZHqT2Q+oZfh5DUkcfkypgO8puQ=; b=fTOrJBSle39VKF0076o0HYQH5OQPMngtitF4CBBEAFBcoNGtp6Z5by82ebvmwvCUVJ 94vb9OyFsrkRrjCoerdzuFCpZMe8CeduQbXIOLHX6jaPEiYlkRcPhouidZz7qz4QoB5U /aENvXAfteVnI8agJeX+6zRXTRsOdV2YkDmjECBFaXSA/YEERaWVjME+WhKVV1P5X7jf asD/3l25p/AOhcMeKRaPAHx90uAXImcgyRadhhf6Ngt/HDdl7gv0OPX3+xExlWcDnxgD sHO1pW93tJHJU+vD1jwIxeMnWYxkegH/OC0sFQIyLKoXC18EJjb1WKDQL0+LDkuOTCA/ pM1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=N1P0gWUe; 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 o91si383599eda.345.2018.02.26.13.19.47; Mon, 26 Feb 2018 13:19:47 -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=N1P0gWUe; 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 33313C22172; Mon, 26 Feb 2018 21:18:24 +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 24952C220EB; Mon, 26 Feb 2018 21:18:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 743A8C21FB3; Mon, 26 Feb 2018 21:18:12 +0000 (UTC) Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by lists.denx.de (Postfix) with ESMTPS id B2DB6C22145 for ; Mon, 26 Feb 2018 21:18:08 +0000 (UTC) Received: by mail-wr0-f193.google.com with SMTP id p104so22677615wrc.12 for ; Mon, 26 Feb 2018 13:18:08 -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=P/jLUNloO3HNxo4cFy8vNNI12+kkhOdEAzMjgp32ph8=; b=N1P0gWUeMx9rEcHvgUqo7ku9pdPE6+S7o9KhhGuUFE1HgsaO4+GmHyCJmCEE9ucwiC O7FyGSaWfGix9lrUZ698qsBSSWgwzyCDtbbroxvLjAbX1UwsDF0yUGF+BBbG2jRwZN0e q8iOdh1PeZbX5GFmy6Gow44Mx9qws9RoDSQCU= 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=P/jLUNloO3HNxo4cFy8vNNI12+kkhOdEAzMjgp32ph8=; b=Zu3rhV4yWICQvRcUS5jFCo9xJZ7Cc2EUrYGwq4qfs238GjpMEw9GPRjeMzvspreZaZ 1QUj9bD4UewT6NU7k7pnLzlTgpzuAc5MfkFpZl5UQ1vn3/g61LzciI09wlIWLEBIjDe0 d8O3Qt2aIdu/vtVPtkWa+hLUZmMguS5kmDjJTIgUda5mqGIFY7EEyJHcnH8AkJ2RtdvM BVem+noGK0FjHit59rI1rrIDXIDUj6di72SRINls0uBwW9/Il0CKe0sGZiESkAVkEMFO 7vxVbjOg/3nU7xfcjTaojkYKgzGOCx7zSUBEpG3Qt64THIX7kQoS0xOe1hSX5YTzI+37 wrJQ== X-Gm-Message-State: APf1xPBbzrjeL6cWfbJ4hJJpIn/UILMKgQW1FFnKdoG7HCKFQti+8Vh9 ZgF6NHL0TAloMMsA6PIJWFJHhOOOggU= X-Received: by 10.223.136.236 with SMTP id g41mr10477175wrg.103.1519679887952; Mon, 26 Feb 2018 13:18:07 -0800 (PST) Received: from localhost ([195.238.92.76]) by smtp.gmail.com with ESMTPSA id c14sm10095127wrd.17.2018.02.26.13.18.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Feb 2018 13:18:07 -0800 (PST) From: Sam Protsenko To: u-boot@lists.denx.de Date: Mon, 26 Feb 2018 23:18:01 +0200 Message-Id: <20180226211801.16060-4-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180226211801.16060-1-semen.protsenko@linaro.org> References: <20180226211801.16060-1-semen.protsenko@linaro.org> Cc: Tom Rini , igor.opaniuk@linaro.org, Praneeth Bajjuri , Neil Williams Subject: [U-Boot] [PATCH 3/3] env: ti: boot: Get rid of magic numbers 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" Get the start address and the size of partitions using partition names rather than partition numbers. This way we can change the partition table further without changing the boot code. Signed-off-by: Sam Protsenko --- include/environment/ti/boot.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h index 0a2342061c..24b7783f88 100644 --- a/include/environment/ti/boot.h +++ b/include/environment/ti/boot.h @@ -40,15 +40,13 @@ "setenv eval_bootargs setenv bootargs $bootargs; " \ "run eval_bootargs; " \ "setenv mmcdev 1; " \ - "setenv fdt_part 3; " \ - "setenv boot_part 9; " \ "setenv machid fe6; " \ "mmc dev $mmcdev; " \ "mmc rescan; " \ - "part start mmc ${mmcdev} ${fdt_part} fdt_start; " \ - "part size mmc ${mmcdev} ${fdt_part} fdt_size; " \ - "part start mmc ${mmcdev} ${boot_part} boot_start; " \ - "part size mmc ${mmcdev} ${boot_part} boot_size; " \ + "part start mmc ${mmcdev} environment fdt_start; " \ + "part size mmc ${mmcdev} environment fdt_size; " \ + "part start mmc ${mmcdev} boot boot_start; " \ + "part size mmc ${mmcdev} boot boot_size; " \ "mmc read ${fdtaddr} ${fdt_start} ${fdt_size}; " \ "mmc read ${loadaddr} ${boot_start} ${boot_size}; " \ "bootm $loadaddr $loadaddr $fdtaddr;\0"