[PATCH 1/4] Add helpers for finding a device node which as a certain property
David Miller
davem at davemloft.net
Thu Nov 13 17:46:48 EST 2008
From: Michael Ellerman <michael at ellerman.id.au>
Date: Thu, 13 Nov 2008 15:20:35 +1100 (EST)
> + np = from ? from->allnext : allnodes;
> + for (; np; np = np->allnext) {
> + for (pp = np->properties; pp != 0; pp = pp->next) {
> + if (of_prop_cmp(pp->name, prop_name) == 0) {
> + goto out;
> + }
> + }
> + }
We're starting to duplicate a lot of code in this file.
Perhaps split out the locked section of of_find_proeprty() into
a __of_find_property() and use that here and in of_find_property()
as well?
staitc struct property *__of_find_property(const struct device_node *np,
const char *name,
int *lenp)
{
struct property *pp;
for (pp = np->properties; pp != 0; pp = pp->next) {
if (of_prop_cmp(pp->name, name) == 0) {
if (lenp != 0)
*lenp = pp->length;
break;
}
}
return pp;
}
struct property *of_find_property(const struct device_node *np,
const char *name,
int *lenp)
{
struct property *pp;
if (!np)
return NULL;
read_lock(&devtree_lock);
pp = __of_find_property(np, name, lenp);
read_unlock(&devtree_lock);
return pp;
}
EXPORT_SYMBOL(of_find_property);
More information about the Linuxppc-dev
mailing list