From: Andreas Fenkart <andreas.fenkart@digitalstrom.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/4] env_sf: re-order error handling in single-buffer env_relocate_spec
Date: Mon, 28 Nov 2016 11:01:16 +0100 [thread overview]
Message-ID: <20161128100117.5237-4-andreas.fenkart@digitalstrom.com> (raw)
In-Reply-To: <20161128100117.5237-1-andreas.fenkart@digitalstrom.com>
this makes it easier comparable to the double-buffered version
Signed-off-by: Andreas Fenkart <andreas.fenkart@digitalstrom.com>
---
common/env_sf.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/common/env_sf.c b/common/env_sf.c
index ba9ac8a..8a3de63 100644
--- a/common/env_sf.c
+++ b/common/env_sf.c
@@ -312,29 +312,31 @@ void env_relocate_spec(void)
char *buf = NULL;
buf = (char *)memalign(ARCH_DMA_MINALIGN, CONFIG_ENV_SIZE);
-
- ret = setup_flash_device();
- if (ret) {
- if (buf)
- free(buf);
+ if (!buf) {
+ set_default_env("!malloc() failed");
return;
}
+ ret = setup_flash_device();
+ if (ret)
+ goto out;
+
ret = spi_flash_read(env_flash,
CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, buf);
if (ret) {
set_default_env("!spi_flash_read() failed");
- goto out;
+ goto err_read;
}
ret = env_import(buf, 1);
if (ret)
gd->env_valid = 1;
-out:
+
+err_read:
spi_flash_free(env_flash);
- if (buf)
- free(buf);
env_flash = NULL;
+out:
+ free(buf);
}
#endif
--
2.10.1
next prev parent reply other threads:[~2016-11-28 10:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-28 10:01 [U-Boot] [PATCH 0/4] env_sf: minor cleanup Andreas Fenkart
2016-11-28 10:01 ` [U-Boot] [PATCH 1/4] env_sf: factor out prepare_flash_device Andreas Fenkart
2016-11-30 0:34 ` Simon Glass
2016-12-02 20:03 ` [U-Boot] [U-Boot,1/4] " Tom Rini
2016-11-28 10:01 ` [U-Boot] [PATCH 2/4] enf_sf: reuse setup_flash_device instead of open coding it Andreas Fenkart
2016-11-28 10:01 ` Andreas Fenkart [this message]
2016-11-30 0:34 ` [U-Boot] [PATCH 3/4] env_sf: re-order error handling in single-buffer env_relocate_spec Simon Glass
2016-11-28 10:01 ` [U-Boot] [PATCH 4/4] env_sf: use DIV_ROUND_UP to calculate number of sectors to erase Andreas Fenkart
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=20161128100117.5237-4-andreas.fenkart@digitalstrom.com \
--to=andreas.fenkart@digitalstrom.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