[SPARC64]: Expand of_*() interfaces some more.
Import some more stuff from powerpc. Add of_device_is_compatible(), and of_find_compatible_node(). Export some more of the other routines to modules. Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
92c4e22593
commit
8cd24ed4f8
2 changed files with 46 additions and 0 deletions
|
@ -27,6 +27,26 @@
|
||||||
|
|
||||||
static struct device_node *allnodes;
|
static struct device_node *allnodes;
|
||||||
|
|
||||||
|
int of_device_is_compatible(struct device_node *device, const char *compat)
|
||||||
|
{
|
||||||
|
const char* cp;
|
||||||
|
int cplen, l;
|
||||||
|
|
||||||
|
cp = (char *) of_get_property(device, "compatible", &cplen);
|
||||||
|
if (cp == NULL)
|
||||||
|
return 0;
|
||||||
|
while (cplen > 0) {
|
||||||
|
if (strncmp(cp, compat, strlen(compat)) == 0)
|
||||||
|
return 1;
|
||||||
|
l = strlen(cp) + 1;
|
||||||
|
cp += l;
|
||||||
|
cplen -= l;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(of_device_is_compatible);
|
||||||
|
|
||||||
struct device_node *of_get_parent(const struct device_node *node)
|
struct device_node *of_get_parent(const struct device_node *node)
|
||||||
{
|
{
|
||||||
struct device_node *np;
|
struct device_node *np;
|
||||||
|
@ -38,6 +58,7 @@ struct device_node *of_get_parent(const struct device_node *node)
|
||||||
|
|
||||||
return np;
|
return np;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(of_get_parent);
|
||||||
|
|
||||||
struct device_node *of_get_next_child(const struct device_node *node,
|
struct device_node *of_get_next_child(const struct device_node *node,
|
||||||
struct device_node *prev)
|
struct device_node *prev)
|
||||||
|
@ -51,6 +72,7 @@ struct device_node *of_get_next_child(const struct device_node *node,
|
||||||
|
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(of_get_next_child);
|
||||||
|
|
||||||
struct device_node *of_find_node_by_path(const char *path)
|
struct device_node *of_find_node_by_path(const char *path)
|
||||||
{
|
{
|
||||||
|
@ -75,6 +97,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
|
||||||
|
|
||||||
return np;
|
return np;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(of_find_node_by_phandle);
|
||||||
|
|
||||||
struct device_node *of_find_node_by_name(struct device_node *from,
|
struct device_node *of_find_node_by_name(struct device_node *from,
|
||||||
const char *name)
|
const char *name)
|
||||||
|
@ -88,6 +111,7 @@ struct device_node *of_find_node_by_name(struct device_node *from,
|
||||||
|
|
||||||
return np;
|
return np;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(of_find_node_by_name);
|
||||||
|
|
||||||
struct device_node *of_find_node_by_type(struct device_node *from,
|
struct device_node *of_find_node_by_type(struct device_node *from,
|
||||||
const char *type)
|
const char *type)
|
||||||
|
@ -101,6 +125,25 @@ struct device_node *of_find_node_by_type(struct device_node *from,
|
||||||
|
|
||||||
return np;
|
return np;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(of_find_node_by_type);
|
||||||
|
|
||||||
|
struct device_node *of_find_compatible_node(struct device_node *from,
|
||||||
|
const char *type, const char *compatible)
|
||||||
|
{
|
||||||
|
struct device_node *np;
|
||||||
|
|
||||||
|
np = from ? from->allnext : allnodes;
|
||||||
|
for (; np != 0; np = np->allnext) {
|
||||||
|
if (type != NULL
|
||||||
|
&& !(np->type != 0 && strcmp(np->type, type) == 0))
|
||||||
|
continue;
|
||||||
|
if (of_device_is_compatible(np, compatible))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return np;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(of_find_compatible_node);
|
||||||
|
|
||||||
struct property *of_find_property(struct device_node *np, const char *name,
|
struct property *of_find_property(struct device_node *np, const char *name,
|
||||||
int *lenp)
|
int *lenp)
|
||||||
|
|
|
@ -75,6 +75,8 @@ extern struct device_node *of_find_node_by_type(struct device_node *from,
|
||||||
#define for_each_node_by_type(dn, type) \
|
#define for_each_node_by_type(dn, type) \
|
||||||
for (dn = of_find_node_by_type(NULL, type); dn; \
|
for (dn = of_find_node_by_type(NULL, type); dn; \
|
||||||
dn = of_find_node_by_type(dn, type))
|
dn = of_find_node_by_type(dn, type))
|
||||||
|
extern struct device_node *of_find_compatible_node(struct device_node *from,
|
||||||
|
const char *type, const char *compat);
|
||||||
extern struct device_node *of_find_node_by_path(const char *path);
|
extern struct device_node *of_find_node_by_path(const char *path);
|
||||||
extern struct device_node *of_find_node_by_phandle(phandle handle);
|
extern struct device_node *of_find_node_by_phandle(phandle handle);
|
||||||
extern struct device_node *of_get_parent(const struct device_node *node);
|
extern struct device_node *of_get_parent(const struct device_node *node);
|
||||||
|
@ -83,6 +85,7 @@ extern struct device_node *of_get_next_child(const struct device_node *node,
|
||||||
extern struct property *of_find_property(struct device_node *np,
|
extern struct property *of_find_property(struct device_node *np,
|
||||||
const char *name,
|
const char *name,
|
||||||
int *lenp);
|
int *lenp);
|
||||||
|
extern int of_device_is_compatible(struct device_node *device, const char *);
|
||||||
extern void *of_get_property(struct device_node *node, const char *name,
|
extern void *of_get_property(struct device_node *node, const char *name,
|
||||||
int *lenp);
|
int *lenp);
|
||||||
extern int of_getintprop_default(struct device_node *np,
|
extern int of_getintprop_default(struct device_node *np,
|
||||||
|
|
Loading…
Add table
Reference in a new issue