From: Patrice Chotard <patrice.chotard@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 04/14] env: ext4: Allow overriding interface, device and partition
Date: Fri, 10 May 2019 18:11:21 +0200 [thread overview]
Message-ID: <1557504691-26188-5-git-send-email-patrice.chotard@st.com> (raw)
In-Reply-To: <1557504691-26188-1-git-send-email-patrice.chotard@st.com>
For platform which can boot on different device, this allows
to override interface, device and partition from board code.
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---
env/ext4.c | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/env/ext4.c b/env/ext4.c
index 388474a..9947381 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -30,6 +30,16 @@
#include <ext4fs.h>
#include <mmc.h>
+__weak const char *env_ext4_get_intf(void)
+{
+ return (const char *)CONFIG_ENV_EXT4_INTERFACE;
+}
+
+__weak const char *env_ext4_get_dev_part(void)
+{
+ return (const char *)CONFIG_ENV_EXT4_DEVICE_AND_PART;
+}
+
#ifdef CONFIG_CMD_SAVEENV
static int env_ext4_save(void)
{
@@ -38,13 +48,14 @@ static int env_ext4_save(void)
disk_partition_t info;
int dev, part;
int err;
+ const char *ifname = env_ext4_get_intf();
+ const char *dev_and_part = env_ext4_get_dev_part();
err = env_export(&env_new);
if (err)
return err;
- part = blk_get_device_part_str(CONFIG_ENV_EXT4_INTERFACE,
- CONFIG_ENV_EXT4_DEVICE_AND_PART,
+ part = blk_get_device_part_str(ifname, dev_and_part,
&dev_desc, &info, 1);
if (part < 0)
return 1;
@@ -54,8 +65,7 @@ static int env_ext4_save(void)
if (!ext4fs_mount(info.size)) {
printf("\n** Unable to use %s %s for saveenv **\n",
- CONFIG_ENV_EXT4_INTERFACE,
- CONFIG_ENV_EXT4_DEVICE_AND_PART);
+ ifname, dev_and_part);
return 1;
}
@@ -65,8 +75,7 @@ static int env_ext4_save(void)
if (err == -1) {
printf("\n** Unable to write \"%s\" from %s%d:%d **\n",
- CONFIG_ENV_EXT4_FILE, CONFIG_ENV_EXT4_INTERFACE, dev,
- part);
+ CONFIG_ENV_EXT4_FILE, ifname, dev, part);
return 1;
}
@@ -83,14 +92,15 @@ static int env_ext4_load(void)
int dev, part;
int err;
loff_t off;
+ const char *ifname = env_ext4_get_intf();
+ const char *dev_and_part = env_ext4_get_dev_part();
#ifdef CONFIG_MMC
- if (!strcmp(CONFIG_ENV_EXT4_INTERFACE, "mmc"))
+ if (!strcmp(ifname, "mmc"))
mmc_initialize(NULL);
#endif
- part = blk_get_device_part_str(CONFIG_ENV_EXT4_INTERFACE,
- CONFIG_ENV_EXT4_DEVICE_AND_PART,
+ part = blk_get_device_part_str(ifname, dev_and_part,
&dev_desc, &info, 1);
if (part < 0)
goto err_env_relocate;
@@ -100,8 +110,7 @@ static int env_ext4_load(void)
if (!ext4fs_mount(info.size)) {
printf("\n** Unable to use %s %s for loading the env **\n",
- CONFIG_ENV_EXT4_INTERFACE,
- CONFIG_ENV_EXT4_DEVICE_AND_PART);
+ ifname, dev_and_part);
goto err_env_relocate;
}
@@ -111,8 +120,7 @@ static int env_ext4_load(void)
if (err == -1) {
printf("\n** Unable to read \"%s\" from %s%d:%d **\n",
- CONFIG_ENV_EXT4_FILE, CONFIG_ENV_EXT4_INTERFACE, dev,
- part);
+ CONFIG_ENV_EXT4_FILE, ifname, dev, part);
goto err_env_relocate;
}
--
1.9.1
next prev parent reply other threads:[~2019-05-10 16:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-10 16:11 [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 01/14] Prepare v2019.07-rc1 Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 02/14] stm32mp1: activate NAND and NOR support on EV1 Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 03/14] stm32mp1: support dynamic MTDPARTS Patrice Chotard
2019-05-10 16:11 ` Patrice Chotard [this message]
2019-05-10 16:11 ` [U-Boot] [PATCH 05/14] board: stm32mp1: Add env_ext4_get_dev_part() and env_ext4_get_intf() Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 06/14] env: allow ENV_IS_NOWHERE with other storage target Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 07/14] env: enable saveenv command when one CONFIG_ENV_IS_IN is activated Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 08/14] configs: stm32mp15: Enable ENV_IS_IN_EXT4 and all relative flags Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 09/14] stm32mp1: Add env_get_location() Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 10/14] mtd: Fix get_mtdparts() Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 11/14] stm32mp1: Move ENV_SIZE to Kconfig Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 12/14] configs: stm32mp15: Enable ENV_IS_IN_UBI Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 13/14] configs: stm32mp15: Enable ENV_IS_SPI_FLASH Patrice Chotard
2019-05-10 16:11 ` [U-Boot] [PATCH 14/14] stm32mp1: Update env_get_location for NOR support Patrice Chotard
2019-05-10 16:18 ` [U-Boot] [PATCH 00/14] Add saveenv support for STM32MP1 Patrice CHOTARD
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=1557504691-26188-5-git-send-email-patrice.chotard@st.com \
--to=patrice.chotard@st.com \
--cc=u-boot@lists.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