From 8f6e2e1ee17bb1ecce03518b8eceda6965617477 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 23 Jun 2015 15:38:26 -0600 Subject: fdt: Add a function to remove unused strings from a device tree Property names are stored in a string table. When a node property is removed, the string table is not updated since other nodes may have a property with the same name. Thus it is possible for the string table to build up a number of unused strings. Add a function to remove these. This works by building a new device tree from the old one, adding strings one by one as needed. Signed-off-by: Simon Glass --- include/libfdt.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/libfdt.h') diff --git a/include/libfdt.h b/include/libfdt.h index 421d64fd8b..d0017d8865 100644 --- a/include/libfdt.h +++ b/include/libfdt.h @@ -1646,6 +1646,23 @@ int fdt_del_node(void *fdt, int nodeoffset); const char *fdt_strerror(int errval); +/** + * fdt_remove_unused_strings() - Remove any unused strings from an FDT + * + * This creates a new device tree in @new with unused strings removed. The + * called can then use fdt_pack() to minimise the space consumed. + * + * @old: Old device tree blog + * @new: Place to put new device tree blob, which must be as large as + * @old + * @return + * 0, on success + * -FDT_ERR_BADOFFSET, corrupt device tree + * -FDT_ERR_NOSPACE, out of space, which should not happen unless there + * is something very wrong with the device tree input + */ +int fdt_remove_unused_strings(const void *old, void *new); + struct fdt_region { int offset; int size; -- cgit v1.2.1