From patchwork Thu Mar 19 09:59:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick DELAUNAY X-Patchwork-Id: 1258082 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=st.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=st.com header.i=@st.com header.a=rsa-sha256 header.s=STMicroelectronics header.b=Mv9kqm/4; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48jj8g0P6rz9sPF for ; Thu, 19 Mar 2020 21:00:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 201E1816BF; Thu, 19 Mar 2020 11:00:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=st.com 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; unprotected) header.d=st.com header.i=@st.com header.b="Mv9kqm/4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0220381528; Thu, 19 Mar 2020 11:00:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (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 6E81A81218 for ; Thu, 19 Mar 2020 11:00:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=patrick.delaunay@st.com Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02J9gqro026336; Thu, 19 Mar 2020 11:00:13 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=GZ5altIhl3lz+D673IAg02GSzGi8pjX5P9Ida2RuRQU=; b=Mv9kqm/4VHhvAcVJmVmmBZ2Olpcn94lLvM8GwBmYlefLePBctJwgCQVNTpPWX2CpOc2d rn/bkzA2PyUwenlEZQ3a15D2negRHBUQOk16DniHwPdhtUbeSu97yShfmlc7Aa0Mhgml ILrbfaAD9s18CTwO0deXJN9cCb8UOwoaFaBQ/cI4sSCPfonKgjwkNev5EL7EQGBKs6yW xRcNVKBeJD0LxsC3DgxgCASgLPKA0gKui4tpUUEPAvs0iyLdguLwZ17IjqFu0bx5t6oI oAEBbhTGx2XhUOt0mZu2iWx/Kjnsl6Hp2OBSL//wiUYp7ddmndZ5zzGqfHn8tU/b76EC 0Q== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2yu95uruf8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Mar 2020 11:00:13 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EFEE210004A; Thu, 19 Mar 2020 11:00:06 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag6node3.st.com [10.75.127.18]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E16572A4D7D; Thu, 19 Mar 2020 11:00:06 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG6NODE3.st.com (10.75.127.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 19 Mar 2020 11:00:06 +0100 From: Patrick Delaunay To: CC: Patrick Delaunay , Joe Hershberger , Peng Fan , Wolfgang Denk , U-Boot STM32 Subject: [PATCH 3/3] env: mmc: add redundancy support in mmc_offset_try_partition Date: Thu, 19 Mar 2020 10:59:35 +0100 Message-ID: <20200319105917.3.I3f39ef337e2318d7c857e0458d5bc66e374dfaba@changeid> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200319105917.1.Ib0b23085d678421d429580e13560b4dad27c9378@changeid> References: <20200319105917.1.Ib0b23085d678421d429580e13560b4dad27c9378@changeid> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG6NODE3.st.com (10.75.127.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.645 definitions=2020-03-19_02:2020-03-18, 2020-03-19 signatures=0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Manage 2 copy at the end of the partition selected by config "u-boot,mmc-env-partition" to save the U-Boot environment, with CONFIG_ENV_SIZE and 2*CONFIG_ENV_SIZE offset. This patch allows to support redundancy (CONFIG_ENV_OFFSET_REDUND). Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- env/mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/env/mmc.c b/env/mmc.c index c24b169f3e..677a3d4668 100644 --- a/env/mmc.c +++ b/env/mmc.c @@ -34,7 +34,7 @@ __weak int mmc_get_env_dev(void) } #if CONFIG_IS_ENABLED(OF_CONTROL) -static inline int mmc_offset_try_partition(const char *str, s64 *val) +static inline int mmc_offset_try_partition(const char *str, int copy, s64 *val) { disk_partition_t info; struct blk_desc *desc; @@ -59,7 +59,7 @@ static inline int mmc_offset_try_partition(const char *str, s64 *val) len = DIV_ROUND_UP(CONFIG_ENV_SIZE, info.blksz); /* use the top of the partion for the environment */ - *val = (info.start + info.size - len) * info.blksz; + *val = (info.start + info.size - (1 + copy) * len) * info.blksz; return 0; } @@ -84,7 +84,7 @@ static inline s64 mmc_offset(int copy) str = fdtdec_get_config_string(gd->fdt_blob, dt_prop.partition); if (str) { /* try to place the environment at end of the partition */ - err = mmc_offset_try_partition(str, &val); + err = mmc_offset_try_partition(str, copy, &val); if (!err) return val; }