why use 'raw_spin_lock_irqsave' inf function 'of_find_node_with_property'
Tabi Timur-B04825
B04825 at freescale.com
Fri Mar 30 02:48:37 EST 2012
On Thu, Mar 29, 2012 at 5:01 AM, Huang Changming-R66093
<r66093 at freescale.com> wrote:
> Hi, all
>
> In function “of_find_node_with_property”, why use “raw_spin_lock_irqsave” to
> disable preemption and disable interrupt?
Where do you see raw_spin_lock_irqsave?
struct device_node *of_find_node_with_property(struct device_node *from,
const char *prop_name)
{
struct device_node *np;
struct property *pp;
read_lock(&devtree_lock);
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) {
of_node_get(np);
goto out;
}
}
}
out:
of_node_put(from);
read_unlock(&devtree_lock);
return np;
}
We need a lock so that we don't parse the tree while it's being
modified. That would cause the for-loop to fail in strange ways.
--
Timur Tabi
Linux kernel developer at Freescale
More information about the Linuxppc-dev
mailing list