From: Patrice CHOTARD <patrice.chotard@foss.st.com>
To: Patrick Delaunay <patrick.delaunay@foss.st.com>, <u-boot@lists.denx.de>
Cc: Peng Fan <peng.fan@nxp.com>, Wolfgang Denk <wd@denx.de>,
Joe Hershberger <joe.hershberger@ni.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
U-Boot STM32 <uboot-stm32@st-md-mailman.stormreply.com>
Subject: Re: [Uboot-stm32] [PATCH 1/8] env: mmc: introduced ENV_MMC_OFFSET
Date: Tue, 6 Dec 2022 09:11:07 +0100 [thread overview]
Message-ID: <4de9711e-e109-e192-de27-cdb2726af669@foss.st.com> (raw)
In-Reply-To: <20221110114828.1.Id1b34c2a5cfbd6b1fbc2f49e4d542c3954c1e9f2@changeid>
On 11/10/22 11:48, Patrick Delaunay wrote:
> Introduce ENV_MMC_OFFSET defines.
> It is a preliminary step to the next patches to simplify the code.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
>
> env/mmc.c | 24 ++++++++++++++++++++----
> 1 file changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/env/mmc.c b/env/mmc.c
> index c28f4c6c6dc0..42bcf7e775cc 100644
> --- a/env/mmc.c
> +++ b/env/mmc.c
> @@ -24,6 +24,17 @@
> #define __STR(X) #X
> #define STR(X) __STR(X)
>
> +#define ENV_MMC_INVALID_OFFSET ((s64)-1)
> +
> +/* Default ENV offset when not defined in Device Tree */
> +#define ENV_MMC_OFFSET CONFIG_ENV_OFFSET
> +
> +#if defined(CONFIG_ENV_OFFSET_REDUND)
> +#define ENV_MMC_OFFSET_REDUND CONFIG_ENV_OFFSET_REDUND
> +#else
> +#define ENV_MMC_OFFSET_REDUND ENV_MMC_INVALID_OFFSET
> +#endif
> +
> DECLARE_GLOBAL_DATA_PTR;
>
> /*
> @@ -94,12 +105,12 @@ static inline s64 mmc_offset(int copy)
> return val;
> }
>
> - defvalue = CONFIG_ENV_OFFSET;
> + defvalue = ENV_MMC_OFFSET;
> propname = dt_prop.offset;
>
> #if defined(CONFIG_ENV_OFFSET_REDUND)
> if (copy) {
> - defvalue = CONFIG_ENV_OFFSET_REDUND;
> + defvalue = ENV_MMC_OFFSET_REDUND;
> propname = dt_prop.offset_redund;
> }
> #endif
> @@ -108,11 +119,11 @@ static inline s64 mmc_offset(int copy)
> #else
> static inline s64 mmc_offset(int copy)
> {
> - s64 offset = CONFIG_ENV_OFFSET;
> + s64 offset = ENV_MMC_OFFSET;
>
> #if defined(CONFIG_ENV_OFFSET_REDUND)
> if (copy)
> - offset = CONFIG_ENV_OFFSET_REDUND;
> + offset = ENV_MMC_OFFSET_REDUND;
> #endif
> return offset;
> }
> @@ -122,6 +133,11 @@ __weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
> {
> s64 offset = mmc_offset(copy);
>
> + if (offset == ENV_MMC_INVALID_OFFSET) {
> + printf("Invalid ENV offset in MMC, copy=%d\n", copy);
> + return -ENOENT;
> + }
> +
> if (offset < 0)
> offset += mmc->capacity;
>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Thanks
Patrice
next prev parent reply other threads:[~2022-12-06 8:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 10:48 [PATCH 0/8] env: mmc: improvements and corrections Patrick Delaunay
2022-11-10 10:48 ` [PATCH 1/8] env: mmc: introduced ENV_MMC_OFFSET Patrick Delaunay
2022-12-06 8:11 ` Patrice CHOTARD [this message]
2022-11-10 10:48 ` [PATCH 2/8] env: mcc: Drop unnecessary #ifdefs Patrick Delaunay
2022-12-06 8:11 ` [Uboot-stm32] " Patrice CHOTARD
2022-11-10 10:49 ` [PATCH 3/8] env: mcc: fix compilation error with ENV_IS_EMBEDDED Patrick Delaunay
2022-12-06 8:11 ` [Uboot-stm32] " Patrice CHOTARD
2022-11-10 10:49 ` [PATCH 4/8] env: mmc: add CONFIG_ENV_MMC_USE_DT Patrick Delaunay
2022-12-06 8:11 ` [Uboot-stm32] " Patrice CHOTARD
2022-11-10 10:49 ` [PATCH 5/8] configs: stm32mp: activate CONFIG_ENV_MMC_USE_DT Patrick Delaunay
2022-12-06 8:17 ` Patrice CHOTARD
2022-11-10 10:49 ` [PATCH 6/8] env: mmc: select GPT env partition by type guid Patrick Delaunay
2022-12-06 8:11 ` [Uboot-stm32] " Patrice CHOTARD
2022-11-10 10:49 ` [PATCH 7/8] env: mmc: add debug message when mmc-env-partition is not found Patrick Delaunay
2022-12-06 8:16 ` [Uboot-stm32] " Patrice CHOTARD
2022-11-10 10:49 ` [PATCH 8/8] env: mmc: cosmetic: remove unused macro STR(X) Patrick Delaunay
2022-12-06 8:16 ` [Uboot-stm32] " Patrice CHOTARD
2022-11-10 20:40 ` [PATCH 0/8] env: mmc: improvements and corrections Simon Glass
2022-11-12 19:21 ` Tom Rini
2023-01-10 19:51 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4de9711e-e109-e192-de27-cdb2726af669@foss.st.com \
--to=patrice.chotard@foss.st.com \
--cc=jh80.chung@samsung.com \
--cc=joe.hershberger@ni.com \
--cc=patrick.delaunay@foss.st.com \
--cc=peng.fan@nxp.com \
--cc=u-boot@lists.denx.de \
--cc=uboot-stm32@st-md-mailman.stormreply.com \
--cc=wd@denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox