scripts/dtc: Support delete unused nodes
Delete nodes in case of: * node is null, without any property and children node * node with 'status' property but not "okay" or "ok" Change-Id: Ic7d2ba1cb60350c21fa6a46222c20870c74359d4 Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
This commit is contained in:
@@ -12,6 +12,18 @@ menuconfig OF
|
||||
|
||||
if OF
|
||||
|
||||
config DTC_OMIT_DISABLED
|
||||
bool "Fixup dtb by removing nodes with disabled status"
|
||||
depends on DTC
|
||||
help
|
||||
This option used for dtc to delete nodes with disabled status.
|
||||
|
||||
config DTC_OMIT_EMPTY
|
||||
bool "Fixup dtb by removing empty nodes"
|
||||
depends on DTC
|
||||
help
|
||||
This option used for dtc to delete empty nodes.
|
||||
|
||||
config OF_UNITTEST
|
||||
bool "Device Tree runtime unit tests"
|
||||
depends on !SPARC
|
||||
|
||||
@@ -249,6 +249,14 @@ ifeq ($(CONFIG_ANDROID),y)
|
||||
DTC_FLAGS += -@
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DTC_OMIT_DISABLED),y)
|
||||
DTC_FLAGS += -Wnode_disabled
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DTC_OMIT_EMPTY),y)
|
||||
DTC_FLAGS += -Wnode_empty
|
||||
endif
|
||||
|
||||
# Disable noisy checks by default
|
||||
ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
|
||||
DTC_FLAGS += -Wno-unit_address_vs_reg \
|
||||
|
||||
@@ -623,6 +623,28 @@ static void fixup_path_references(struct check *c, struct dt_info *dti,
|
||||
}
|
||||
ERROR(path_references, fixup_path_references, NULL, &duplicate_node_names);
|
||||
|
||||
static void fixup_node_disabled(struct check *c, struct dt_info *dti,
|
||||
struct node *node)
|
||||
{
|
||||
struct property *prop = get_property(node, "status");
|
||||
|
||||
if (prop) {
|
||||
const char *status = prop->val.val;
|
||||
|
||||
if (strcmp(status, "ok") && strcmp(status, "okay"))
|
||||
omit_node_if_unused(node);
|
||||
}
|
||||
}
|
||||
CHECK(node_disabled, fixup_node_disabled, NULL);
|
||||
|
||||
static void fixup_node_empty(struct check *c, struct dt_info *dti,
|
||||
struct node *node)
|
||||
{
|
||||
if (!node->proplist && !node->children)
|
||||
omit_node_if_unused(node);
|
||||
}
|
||||
CHECK(node_empty, fixup_node_empty, NULL);
|
||||
|
||||
static void fixup_omit_unused_nodes(struct check *c, struct dt_info *dti,
|
||||
struct node *node)
|
||||
{
|
||||
@@ -1559,6 +1581,7 @@ static struct check *check_table[] = {
|
||||
|
||||
&explicit_phandles,
|
||||
&phandle_references, &path_references,
|
||||
&node_disabled, &node_empty,
|
||||
&omit_unused_nodes,
|
||||
|
||||
&address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell,
|
||||
|
||||
Reference in New Issue
Block a user