9
0
Fork 0

OF: base: rename of_node_disabled to of_device_is_available

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@gmail.com>
This commit is contained in:
Sebastian Hesselbarth 2013-06-13 18:25:54 +02:00 committed by Sascha Hauer
parent 0b79c3bb64
commit 80fc31dac3
2 changed files with 26 additions and 6 deletions

View File

@ -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;
p = of_find_property(node, "status", NULL);
if (p) {
if (!strcmp("disabled", p->value))
status = of_get_property(device, "status", &statlen);
if (status == NULL)
return 1;
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);

View File

@ -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)
{
}