According to ePAPR 1.1 spec, device tree nodes status can be either "okay", "disabled", "fail", or "fail-sss". Barebox already has a function to check for "disabled" nodes, while Linux checks for "okay" or "ok". To synchronize Barebox and Linux OF APIs, rename of_node_disabled to of_device_is_available and check for "okay" instead of "disabled" as it also makes "fail"ed devices unavailable. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@xxxxxxxxx> --- Cc: barebox@xxxxxxxxxxxxxxxxxxx --- drivers/of/base.c | 26 ++++++++++++++++++++------ include/of.h | 6 ++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index f822f8d..2176251 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -730,17 +730,31 @@ int of_set_root_node(struct device_node *node) return 0; } -static int of_node_disabled(struct device_node *node) +/** + * of_device_is_available - check if a device is available for use + * + * @device: Node to check for availability + * + * Returns 1 if the status property is absent or set to "okay" or "ok", + * 0 otherwise + */ +int of_device_is_available(const struct device_node *device) { - struct property *p; + const char *status; + int statlen; + + status = of_get_property(device, "status", &statlen); + if (status == NULL) + return 1; - p = of_find_property(node, "status", NULL); - if (p) { - if (!strcmp("disabled", p->value)) + if (statlen > 0) { + if (!strcmp(status, "okay") || !strcmp(status, "ok")) return 1; } + return 0; } +EXPORT_SYMBOL(of_device_is_available); void of_print_nodes(struct device_node *node, int indent) { @@ -934,7 +948,7 @@ static struct device_d *add_of_device(struct device_node *node, { const struct property *cp; - if (of_node_disabled(node)) + if (!of_device_is_available(node)) return NULL; cp = of_get_property(node, "compatible", NULL); diff --git a/include/of.h b/include/of.h index a56587f..56b7be1 100644 --- a/include/of.h +++ b/include/of.h @@ -185,6 +185,7 @@ extern struct property *of_find_property(const struct device_node *np, extern struct device_node *of_find_node_by_path_from(struct device_node *from, const char *path); extern struct device_node *of_find_node_by_path(const char *path); +extern int of_device_is_available(const struct device_node *device); extern void of_alias_scan(void); extern int of_alias_get_id(struct device_node *np, const char *stem); @@ -248,6 +249,11 @@ static inline struct device_node *of_find_node_by_path(const char *path) return NULL; } +static inline int of_device_is_available(const struct device_node *device) +{ + return 0; +} + static inline void of_alias_scan(void) { } -- 1.7.2.5 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox