[RFC PATCH 45/77] dtc: Introduce dti_get_property_by_label()
Herve Codina <[email protected]> Mon, 12 Jan 2026 15:19:35 +0100
| Newsgroups | org.kernel.vger.devicetree-spec,org.kernel.vger.devicetree-compiler,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
The future introduction of orphan nodes for addons device-tree will lead to more than one tree in the addons data. Those trees will be: - the classical root tree starting at the root node - trees related to orphan nodes Also, an addon device-tree can have only trees based on orphan nodes. In other words an addon device-tree is valid without having the classical 'root' tree. To prepare this change, introduce and use dti_get_property_by_label(). dti_get_property_by_label() retrieves a property (and the related node) by its label like get_property_by_label() but it works at the struct dt_info level. It handles the case where a 'root' device-tree is not present and will handle orphan nodes trees as soon as they will be introduced. This introduction doesn't lead to any functional changes. Signed-off-by: Herve Codina <[email protected]> --- checks.c | 2 +- dtc.h | 5 +++-- livetree.c | 18 +++++++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/checks.c b/checks.c index 7dd5032..75040c0 100644 --- a/checks.c +++ b/checks.c @@ -447,7 +447,7 @@ static void check_duplicate_label(struct check *c, struct dt_info *dti, othernode = dti_get_node_by_label(dti, label); if (!othernode) - otherprop = get_property_by_label(dt, label, &othernode); + otherprop = dti_get_property_by_label(dti, label, &othernode); if (!othernode) othermark = get_marker_label(dt, label, &othernode, &otherprop); diff --git a/dtc.h b/dtc.h index f7b0b23..399e7fa 100644 --- a/dtc.h +++ b/dtc.h @@ -318,8 +318,6 @@ const char *get_unitname(struct node *node); struct property *get_property(struct node *node, const char *propname); cell_t propval_cell(struct property *prop); cell_t propval_cell_n(struct property *prop, unsigned int n); -struct property *get_property_by_label(struct node *tree, const char *label, - struct node **node); struct marker *get_marker_label(struct node *tree, const char *label, struct node **node, struct property **prop); struct node *get_subnode(struct node *node, const char *nodename); @@ -357,6 +355,9 @@ struct node *dti_get_node_by_label(struct dt_info *dti, const char *label); struct node *dti_get_node_by_phandle(struct dt_info *dti, cell_t phandle); struct node *dti_get_node_by_ref(struct dt_info *dti, const char *ref); cell_t dti_get_node_phandle(struct dt_info *dti, struct node *node); +struct property *dti_get_property_by_label(struct dt_info *dti, + const char *label, + struct node **node); /* DTS version flags definitions */ #define DTSF_V1 0x0001 /* /dts-v1/ */ diff --git a/livetree.c b/livetree.c index a4917d1..d023075 100644 --- a/livetree.c +++ b/livetree.c @@ -594,7 +594,7 @@ cell_t propval_cell_n(struct property *prop, unsigned int n) return fdt32_to_cpu(*((fdt32_t *)prop->val.val + n)); } -struct property *get_property_by_label(struct node *tree, const char *label, +static struct property *get_property_by_label(struct node *tree, const char *label, struct node **node) { struct property *prop; @@ -837,6 +837,22 @@ struct node *dti_get_node_by_ref(struct dt_info *dti, const char *ref) return NULL; } +struct property *dti_get_property_by_label(struct dt_info *dti, + const char *label, + struct node **node) +{ + struct property *property; + + if (dti->dt) { + property = get_property_by_label(dti->dt, label, node); + if (property) + return property; + } + + *node = NULL; + return NULL; +} + static void add_phandle_property(struct node *node, const char *name, int format) { -- 2.52.0