libfdt: Add fdt_header_size()

We have a couple of places within libfdt and its tests where we need to
find the size of the header, based on the version.  Add a helper function
for it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
This commit is contained in:
David Gibson
2018-03-16 22:40:26 +11:00
parent 6473a21d8b
commit 0112fda03b
3 changed files with 29 additions and 10 deletions

View File

@@ -44,13 +44,9 @@ static void expand_buf(struct bufstate *buf, int newsize)
static void new_header(struct bufstate *buf, int version, const void *fdt)
{
int hdrsize;
int hdrsize = fdt_header_size_(version);
if (version == 16)
hdrsize = FDT_V16_SIZE;
else if (version == 17)
hdrsize = FDT_V17_SIZE;
else
if ((version != 16) && (version != 17))
CONFIG("Bad version %d", version);
expand_buf(buf, hdrsize);