Re: [dtc RFC PATCH] Enforce node name unit-address presence/absence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Wed, Sep 18, 2013 at 02:23:56PM -0600, Stephen Warren wrote:
> From: Stephen Warren <swarren@xxxxxxxxxx>
> 
> ePAPR 1.1 section 2.2.1.1 "Node Name Requirements" specifies that any
> node that has a reg property must include a unit address in its name
> with value matching the first entry in its reg property. Conversely, if
> a node does not have a reg property, the node name must not include a
> unit address.
> 
> Implement a check for this. The code doesn't validate the format of the
> unit address; ePAPR implies this may vary from binding to binding, so
> I'm not sure that it's possible to validate the value itself.
> 
> Signed-off-by: Stephen Warren <swarren@xxxxxxxxxx>
> ---
> This depends on my previous patch "Ensure all tests have matching reg
> and unit address".
> 
> Note that this patch should not yet be applied; it will cause many real-
> world *.dts files to fail to compile. Those need to be fixed first.
> However, if/when that happens, this patch may be useful.
> ---
>  checks.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/checks.c b/checks.c
> index ee96a25..c80a055 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -287,9 +287,25 @@ NODE_ERROR(node_name_chars, PROPNODECHARS "@");
>  static void check_node_name_format(struct check *c, struct node *dt,
>  				   struct node *node)
>  {
> -	if (strchr(get_unitname(node), '@'))
> +	const char *unitname;
> +	struct property *prop;
> +
> +	unitname = get_unitname(node);
> +
> +	if (strchr(unitname, '@'))
>  		FAIL(c, "Node %s has multiple '@' characters in name",
>  		     node->fullpath);
> +
> +	prop = get_property(node, "reg");
> +	if (prop) {
> +		if (!unitname[0])
> +			FAIL(c, "Node %s has a reg property, but no unit name",
> +			    node->fullpath);
> +	} else {
> +		if (unitname[0])
> +			FAIL(c, "Node %s has a unit name, but no reg property",
> +			    node->fullpath);
> +	}
>  }
>  NODE_ERROR(node_name_format, NULL, &node_name_chars);

I'd prefer to see this implemented as a new check, rather than
extending node_name_format.  It will be a bit more verbose, but it
keeps the low-level syntactic check seperate from the higher-level
semantic / linting check.

It also allows it to be configured as a warning seperately from the
simpler check.

-- 
David Gibson			| 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

Attachment: pgpu5WyytGrtI.pgp
Description: PGP signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux