From 57c92c0734cc21580b7408d0eb3659e52aff82d9 Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Mon, 30 Nov 2020 16:29:24 +0800 Subject: [PATCH] scripts: dtc: delete empty node after omit_unused_nodes A node is empty node if its proplist/label/child both null or both set as deleted. Change-Id: Ia934c58df3305dc9531cc912322eb2728f7af689 Signed-off-by: Jianqun Xu --- scripts/dtc/checks.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c index 17cb6890d45a..913fb08af475 100644 --- a/scripts/dtc/checks.c +++ b/scripts/dtc/checks.c @@ -649,6 +649,24 @@ static void fixup_omit_unused_nodes(struct check *c, struct dt_info *dti, return; if (node->omit_if_unused && !node->is_referenced) delete_node(node); + + if (node->deleted) { + struct node *parent = node->parent; + struct node *child; + struct label *label; + struct property *prop; + + for_each_label(parent->labels, label) + return; + + for_each_property(parent, prop) + return; + + for_each_child(parent, child) + return; + + delete_node(parent); + } } ERROR(omit_unused_nodes, fixup_omit_unused_nodes, NULL, &phandle_references, &path_references);