[U-Boot] [PATCH 084/126] x86: Tidy up error handling in mrccache_save()
Simon Glass
sjg at chromium.org
Wed Sep 25 14:57:08 UTC 2019
This function is a bit confusing at present due to the error handling.
Update it to remove the goto, returning errors as they happen.
While we are here, use hex for the data size since this is the norm in
U-Boot.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
arch/x86/lib/mrccache.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/arch/x86/lib/mrccache.c b/arch/x86/lib/mrccache.c
index 9a3e5fffa45..0208696c834 100644
--- a/arch/x86/lib/mrccache.c
+++ b/arch/x86/lib/mrccache.c
@@ -248,28 +248,23 @@ int mrccache_save(void)
if (!gd->arch.mrc_output_len)
return 0;
- debug("Saving %d bytes of MRC output data to SPI flash\n",
+ debug("Saving %#x bytes of MRC output data to SPI flash\n",
gd->arch.mrc_output_len);
ret = mrccache_get_region(&sf, &entry);
if (ret)
- goto err_entry;
+ return log_msg_ret("Cannot get region", ret);
ret = device_probe(sf);
if (ret)
- goto err_entry;
+ return log_msg_ret("Cannot probe device", ret);
cache = gd->arch.mrc_cache;
ret = mrccache_update(sf, &entry, cache);
- if (!ret) {
+ if (!ret)
debug("Saved MRC data with checksum %04x\n", cache->checksum);
- } else if (ret == -EEXIST) {
+ else if (ret == -EEXIST)
debug("MRC data is the same as last time, skipping save\n");
- ret = 0;
- }
-err_entry:
- if (ret)
- debug("%s: Failed: %d\n", __func__, ret);
- return ret;
+ return 0;
}
int mrccache_spl_save(void)
--
2.23.0.444.g18eeb5a265-goog
More information about the U-Boot
mailing list