diff options
author | Albert ARIBAUD <albert.u.boot@aribaud.net> | 2013-04-12 22:07:57 +0200 |
---|---|---|
committer | Albert ARIBAUD <albert.u.boot@aribaud.net> | 2013-04-12 22:07:57 +0200 |
commit | 18122019972ca639ee3b581257e3a63ff7c8efeb (patch) | |
tree | 52f7223e7c63f43322f3eee4722743e12190a19f /common/cmd_mtdparts.c | |
parent | 90639feaa0d66a204f9d03a325ab14e2f97f6cbb (diff) | |
parent | 785881f775252940185e10fbb2d5299c9ffa6bce (diff) | |
download | u-boot-imx-18122019972ca639ee3b581257e3a63ff7c8efeb.zip u-boot-imx-18122019972ca639ee3b581257e3a63ff7c8efeb.tar.gz u-boot-imx-18122019972ca639ee3b581257e3a63ff7c8efeb.tar.bz2 |
Merge branch 'u-boot/master' into 'u-boot-arm/master'
Conflicts:
drivers/video/exynos_fb.c
Diffstat (limited to 'common/cmd_mtdparts.c')
-rw-r--r-- | common/cmd_mtdparts.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c index 5192dee..1c35f9d 100644 --- a/common/cmd_mtdparts.c +++ b/common/cmd_mtdparts.c @@ -106,6 +106,8 @@ #include <onenand_uboot.h> #endif +DECLARE_GLOBAL_DATA_PTR; + /* special size referring to all the remaining space in a partition */ #define SIZE_REMAINING 0xFFFFFFFF @@ -1537,6 +1539,7 @@ static int parse_mtdparts(const char *const mtdparts) const char *p = mtdparts; struct mtd_device *dev; int err = 1; + char tmp_parts[MTDPARTS_MAXLEN]; debug("\n---parse_mtdparts---\nmtdparts = %s\n\n", p); @@ -1547,7 +1550,12 @@ static int parse_mtdparts(const char *const mtdparts) } /* re-read 'mtdparts' variable, mtd_devices_init may be updating env */ - p = getenv("mtdparts"); + if (gd->flags & GD_FLG_ENV_READY) { + p = getenv("mtdparts"); + } else { + p = tmp_parts; + getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN); + } if (strncmp(p, "mtdparts=", 9) != 0) { printf("mtdparts variable doesn't start with 'mtdparts='\n"); @@ -1705,6 +1713,7 @@ int mtdparts_init(void) const char *current_partition; int ids_changed; char tmp_ep[PARTITION_MAXLEN]; + char tmp_parts[MTDPARTS_MAXLEN]; debug("\n---mtdparts_init---\n"); if (!initialized) { @@ -1718,7 +1727,17 @@ int mtdparts_init(void) /* get variables */ ids = getenv("mtdids"); - parts = getenv("mtdparts"); + /* + * The mtdparts variable tends to be long. If we need to access it + * before the env is relocated, then we need to use our own stack + * buffer. gd->env_buf will be too small. + */ + if (gd->flags & GD_FLG_ENV_READY) { + parts = getenv("mtdparts"); + } else { + parts = tmp_parts; + getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN); + } current_partition = getenv("partition"); /* save it for later parsing, cannot rely on current partition pointer |