Re: [RFC PATCH 46/77] dtc: Introduce dti_get_marker_label()

David Gibson <[email protected]> Thu, 15 Jan 2026 17:51:30 +1100
Newsgroups org.kernel.vger.devicetree-spec,org.kernel.vger.devicetree-compiler,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel
Message-ID <aWiOcrj-1EB4cfO-@zatzit>
On Mon, Jan 12, 2026 at 03:19:36PM +0100, Herve Codina wrote:
> 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_marker_label().
> 
> dti_get_marker_label() retrieves a marker and its related node and
> property based on the label value. It behaves in the same way as
> get_marker_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.

For all of these functions, if the new one is basically replacing the
old one, don't change the name, just change the signature.

> 
> Signed-off-by: Herve Codina <[email protected]>
> ---
>  checks.c   |  5 ++---
>  dtc.h      |  4 ++--
>  livetree.c | 18 +++++++++++++++++-
>  3 files changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/checks.c b/checks.c
> index 75040c0..0a855f9 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -439,7 +439,6 @@ static void check_duplicate_label(struct check *c, struct dt_info *dti,
>  				  const char *label, struct node *node,
>  				  struct property *prop, struct marker *mark)
>  {
> -	struct node *dt = dti->dt;
>  	struct node *othernode = NULL;
>  	struct property *otherprop = NULL;
>  	struct marker *othermark = NULL;
> @@ -449,8 +448,8 @@ static void check_duplicate_label(struct check *c, struct dt_info *dti,
>  	if (!othernode)
>  		otherprop = dti_get_property_by_label(dti, label, &othernode);
>  	if (!othernode)
> -		othermark = get_marker_label(dt, label, &othernode,
> -					       &otherprop);
> +		othermark = dti_get_marker_label(dti, label, &othernode,
> +						 &otherprop);
>  
>  	if (!othernode)
>  		return;
> diff --git a/dtc.h b/dtc.h
> index 399e7fa..d45a84c 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 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);
>  
>  uint32_t guess_boot_cpuid(struct node *tree);
> @@ -358,6 +356,8 @@ 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);
> +struct marker *dti_get_marker_label(struct dt_info *dti, const char *label,
> +				    struct node **node, struct property **prop);
>  
>  /* DTS version flags definitions */
>  #define DTSF_V1		0x0001	/* /dts-v1/ */
> diff --git a/livetree.c b/livetree.c
> index d023075..79f7b55 100644
> --- a/livetree.c
> +++ b/livetree.c
> @@ -620,7 +620,7 @@ static struct property *get_property_by_label(struct node *tree, const char *lab
>  	return NULL;
>  }
>  
> -struct marker *get_marker_label(struct node *tree, const char *label,
> +static struct marker *get_marker_label(struct node *tree, const char *label,
>  				struct node **node, struct property **prop)
>  {
>  	struct marker *m;
> @@ -853,6 +853,22 @@ struct property *dti_get_property_by_label(struct dt_info *dti,
>  	return NULL;
>  }
>  
> +struct marker *dti_get_marker_label(struct dt_info *dti, const char *label,
> +				    struct node **node, struct property **prop)
> +{
> +	struct marker *marker;
> +
> +	if (dti->dt) {
> +		marker = get_marker_label(dti->dt, label, node, prop);
> +		if (marker)
> +			return marker;
> +	}
> +
> +	*prop = NULL;
> +	*node = NULL;
> +	return NULL;
> +}
> +
>  static void add_phandle_property(struct node *node,
>  				 const char *name, int format)
>  {
> -- 
> 2.52.0
> 
> 

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmlojnEACgkQzQJF27ox
2GfufA/7BXKqS2I2f1YeCZAelj2RY340mHR/KQ/blcqlwf9ip/CajXewC9bjoWh1
eBq7BOHECNREkjPUdkBvchI37FuEuuz3lmwMw8aEoog/GWevLjtlzyppFJaZmQXE
F9g6UbsMfjTwwluHfJbezU7sj+m9Nr4QgP/ZjrTbrvhc5tj03/XuiZcJT4wwqG0i
mhuwi2gORlCrylWYP0J4RfhJtTDvJuc7+DBOqKMJA4FlcxWx0NDENSPAfdhmbDKc
T7t+oSiloqJUqKT71BJdb+yWd7gdKOUR/y2IiZkjWvAwf5NrtZUd5IWoawim1+aJ
jW64o15K/JuBkTqSEqUsk0nBFAIZjJYCbA2NTG3qtlIf1lAoAj1lBYe8rgiLM5+M
RU+hQMLvCwlvIZm4b9fKX6rhEq4LCAuZniDFoz7qIAMmshSWiBnv0umeOjwPyswy
QWKjhgAWGoEHTL7OtOz376qLXm+vbuzyJKxQVRfkI3JBOMgo4GGwENciZAsoFv7s
vh1DJbMvRTew97iQP+9MoqtVZCxPACnZGQqZQscmXopzoxMXL2HeC4Bl6J91ZNe9
3EaJBnJeQIWtKFOhDnyDRW1DPuF7iQFPAZ8gKWPvfIISJ59EU3G2LJe1/VzvuU9T
i6viZlGtgRenAtteoo3bou4S4JIOiVOGxNKpKNZfrmkfrQk2vqY=
=R7ul
-----END PGP SIGNATURE-----