[Skiboot] [PATCH 11/33] devicetree: Add dt_node_is_enabled()

Michael Neuling mikey at neuling.org
Wed Jul 6 16:47:13 AEST 2016


On Sat, 2016-06-25 at 08:47 +1000, Benjamin Herrenschmidt wrote:
> This accessor tests the "status" property allowing us to represent
> disabled devices in the device-tree. It will be used by PHB4 initially
> but its usage could be made more widespread.
> 
> Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
> ---
>  core/device.c    | 10 ++++++++++
>  include/device.h |  2 ++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/core/device.c b/core/device.c
> index 4818d40..9e7ef0d 100644
> --- a/core/device.c
> +++ b/core/device.c
> @@ -910,3 +910,13 @@ u64 dt_translate_address(const struct dt_node *node, unsigned int index,
>  	/* XXX TODO */
>  	return dt_get_address(node, index, out_size);
>  }
> +
> +bool dt_node_is_enabled(struct dt_node *node)
> +{
> +	const struct dt_property *p = dt_find_property(node, "status");
> +
> +	if (!p)
> +		return true;
> +
> +	return p->len > 1 && p->prop[0] == 'o' && p->prop[1] == 'k';

Minor nit... Should this just be p->len == 2 rather than > 1 ?  Otherwise
we could match on 'ok_everyone_dont_use_this_really_broken_node'.

Some braces would be nice too.

Mikey

> +}
> diff --git a/include/device.h b/include/device.h
> index 28dbd5d..ed4fc46 100644
> --- a/include/device.h
> +++ b/include/device.h
> @@ -161,6 +161,8 @@ struct dt_node *dt_find_compatible_node_on_chip(struct dt_node *root,
>  	for (node = NULL; 			        \
>  	     (node = dt_find_compatible_node_on_chip(root, node,\
>  						     compat, chip_id)) != NULL;)
> +/* Check status property */
> +bool dt_node_is_enabled(struct dt_node *node);
>  
>  /* Build the full path for a node. Return a new block of memory, caller
>   * shall free() it


More information about the Skiboot mailing list