summaryrefslogtreecommitdiffstats
path: root/common/state/backend_format_dtb.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-03-23 09:16:14 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-31 18:43:53 +0200
commit9948003da46c27b45d4479124407ed7805d84a02 (patch)
tree8eaca5b4873abd1b957b3cfe729b066b3ec9a60e /common/state/backend_format_dtb.c
parentb7d9863dae31d7d4d3d4a9d671c4595287243b98 (diff)
downloadbarebox-9948003da46c27b45d4479124407ed7805d84a02.tar.gz
state: replace len_hint logic
The len_hint mechanism is rather hard to understand as it's not clear from where to where the hint is passed and also it's not clear what happens if the hint is empty or wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/state/backend_format_dtb.c')
-rw-r--r--common/state/backend_format_dtb.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/common/state/backend_format_dtb.c b/common/state/backend_format_dtb.c
index dc19c88..abf8921 100644
--- a/common/state/backend_format_dtb.c
+++ b/common/state/backend_format_dtb.c
@@ -40,12 +40,13 @@ static inline struct state_backend_format_dtb *get_format_dtb(struct
static int state_backend_format_dtb_verify(struct state_backend_format *format,
uint32_t magic, const uint8_t * buf,
- ssize_t len)
+ ssize_t *lenp)
{
struct state_backend_format_dtb *fdtb = get_format_dtb(format);
struct device_node *root;
struct fdt_header *fdt = (struct fdt_header *)buf;
size_t dtb_len = fdt32_to_cpu(fdt->totalsize);
+ size_t len = *lenp;
if (dtb_len > len) {
dev_err(fdtb->dev, "Error, stored DTB length (%d) longer than read buffer (%d)\n",
@@ -67,6 +68,8 @@ static int state_backend_format_dtb_verify(struct state_backend_format *format,
fdtb->root = root;
+ *lenp = be32_to_cpu(fdt->totalsize);
+
return 0;
}
@@ -78,7 +81,7 @@ static int state_backend_format_dtb_unpack(struct state_backend_format *format,
int ret;
if (!fdtb->root) {
- state_backend_format_dtb_verify(format, 0, buf, len);
+ state_backend_format_dtb_verify(format, 0, buf, &len);
}
ret = state_from_node(state, fdtb->root, 0);