From 9a7de8e2d05aade58020f10d48a69db4111ee5ac Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 16 Mar 2018 22:40:26 +1100 Subject: 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 Reviewed-by: Simon Glass Tested-by: Alexey Kardashevskiy Reviewed-by: Alexey Kardashevskiy --- cpukit/include/libfdt.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cpukit/include/libfdt.h') diff --git a/cpukit/include/libfdt.h b/cpukit/include/libfdt.h index b50af54296..b81d046e54 100644 --- a/cpukit/include/libfdt.h +++ b/cpukit/include/libfdt.h @@ -244,8 +244,19 @@ fdt_set_hdr_(size_dt_strings); fdt_set_hdr_(size_dt_struct); #undef fdt_set_hdr_ +/** + * fdt_header_size - return the size of the tree's header + * @fdt: pointer to a flattened device tree + */ +size_t fdt_header_size_(uint32_t version); +static inline size_t fdt_header_size(const void *fdt) +{ + return fdt_header_size_(fdt_version(fdt)); +} + /** * fdt_check_header - sanity check a device tree header + * @fdt: pointer to data which might be a flattened device tree * * fdt_check_header() checks that the given buffer contains what -- cgit v1.2.3