diff --git a/src/commonlib/device_tree.c b/src/commonlib/device_tree.c index d244ad9954..595c3cbb5d 100644 --- a/src/commonlib/device_tree.c +++ b/src/commonlib/device_tree.c @@ -2149,3 +2149,19 @@ int dt_apply_overlay(struct device_tree *tree, struct device_tree *overlay) return 0; } + +bool dt_is_overlay(struct device_tree *tree) +{ + /* The actual overlaid nodes/props are in an __overlay__ child node. */ + const char * const overlay_path[] = { "__overlay__", NULL }; + struct device_tree_node *fragment; + + if (!tree) + return false; + + list_for_each(fragment, tree->root->children, list_node) + if (dt_find_node(fragment, overlay_path, NULL, NULL, 0)) + return true; + + return false; +} diff --git a/src/commonlib/include/commonlib/device_tree.h b/src/commonlib/include/commonlib/device_tree.h index be945d93da..b6004fe8c4 100644 --- a/src/commonlib/include/commonlib/device_tree.h +++ b/src/commonlib/include/commonlib/device_tree.h @@ -234,4 +234,7 @@ int dt_apply_fixups(struct device_tree *tree); */ struct device_tree_node *dt_init_reserved_memory_node(struct device_tree *tree); +/* Check whether a devicetree is an overlay device tree */ +bool dt_is_overlay(struct device_tree *tree); + #endif /* __COMMONLIB_DEVICE_TREE_H__ */