Commit a87f354d authored by Thomas Gleixner's avatar Thomas Gleixner

OF: devtree_lock needs to be taken irqsave

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 925df9b3
...@@ -83,10 +83,11 @@ struct property *of_find_property(const struct device_node *np, ...@@ -83,10 +83,11 @@ struct property *of_find_property(const struct device_node *np,
int *lenp) int *lenp)
{ {
struct property *pp; struct property *pp;
unsigned long flags;
atomic_spin_lock(&devtree_lock); atomic_spin_lock_irqsave(&devtree_lock, flags);
pp = __of_find_property(np, name, lenp); pp = __of_find_property(np, name, lenp);
atomic_spin_unlock(&devtree_lock); atomic_spin_unlock_irqrestore(&devtree_lock, flags);
return pp; return pp;
} }
...@@ -146,11 +147,12 @@ static int __of_device_is_compatible(const struct device_node *device, ...@@ -146,11 +147,12 @@ static int __of_device_is_compatible(const struct device_node *device,
int of_device_is_compatible(const struct device_node *device, int of_device_is_compatible(const struct device_node *device,
const char *compat) const char *compat)
{ {
unsigned long flags;
int res; int res;
atomic_spin_lock(&devtree_lock); atomic_spin_lock_irqsave(&devtree_lock, flags);
res = __of_device_is_compatible(device, compat); res = __of_device_is_compatible(device, compat);
atomic_spin_unlock(&devtree_lock); atomic_spin_unlock_irqrestore(&devtree_lock, flags);
return res; return res;
} }
EXPORT_SYMBOL(of_device_is_compatible); EXPORT_SYMBOL(of_device_is_compatible);
...@@ -191,13 +193,14 @@ EXPORT_SYMBOL(of_device_is_available); ...@@ -191,13 +193,14 @@ EXPORT_SYMBOL(of_device_is_available);
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;
unsigned long flags;
if (!node) if (!node)
return NULL; return NULL;
atomic_spin_lock(&devtree_lock); atomic_spin_lock_irqsave(&devtree_lock, flags);
np = of_node_get(node->parent); np = of_node_get(node->parent);
atomic_spin_unlock(&devtree_lock); atomic_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_get_parent); EXPORT_SYMBOL(of_get_parent);
...@@ -216,14 +219,15 @@ EXPORT_SYMBOL(of_get_parent); ...@@ -216,14 +219,15 @@ EXPORT_SYMBOL(of_get_parent);
struct device_node *of_get_next_parent(struct device_node *node) struct device_node *of_get_next_parent(struct device_node *node)
{ {
struct device_node *parent; struct device_node *parent;
unsigned long flags;
if (!node) if (!node)
return NULL; return NULL;
atomic_spin_lock(&devtree_lock); atomic_spin_lock_irqsave(&devtree_lock, flags);
parent = of_node_get(node->parent); parent = of_node_get(node->parent);
of_node_put(node); of_node_put(node);
atomic_spin_unlock(&devtree_lock); atomic_spin_unlock_irqrestore(&devtree_lock, flags);
return parent; return parent;
} }
...@@ -239,14 +243,15 @@ struct device_node *of_get_next_child(const struct device_node *node, ...@@ -239,14 +243,15 @@ struct device_node *of_get_next_child(const struct device_node *node,
struct device_node *prev) struct device_node *prev)
{ {
struct device_node *next; struct device_node *next;
unsigned long flags;
atomic_spin_lock(&devtree_lock); atomic_spin_lock_irqsave(&devtree_lock, flags);
next = prev ? prev->sibling : node->child; next = prev ? prev->sibling : node->child;
for (; next; next = next->sibling) for (; next; next = next->sibling)
if (of_node_get(next)) if (of_node_get(next))
break; break;
of_node_put(prev); of_node_put(prev);
atomic_spin_unlock(&devtree_lock); atomic_spin_unlock_irqrestore(&devtree_lock, flags);
return next; return next;
} }
EXPORT_SYMBOL(of_get_next_child); EXPORT_SYMBOL(of_get_next_child);
...@@ -261,14 +266,15 @@ EXPORT_SYMBOL(of_get_next_child); ...@@ -261,14 +266,15 @@ 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)
{ {
struct device_node *np = allnodes; struct device_node *np = allnodes;
unsigned long flags;
atomic_spin_lock(&devtree_lock); atomic_spin_lock_irqsave(&devtree_lock, flags);
for (; np; np = np->allnext) { for (; np; np = np->allnext) {
if (np->full_name && (of_node_cmp(np->full_name, path) == 0) if (np->full_name && (of_node_cmp(np->full_name, path) == 0)
&& of_node_get(np)) && of_node_get(np))
break; break;
} }
atomic_spin_unlock(&devtree_lock); atomic_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_find_node_by_path); EXPORT_SYMBOL(of_find_node_by_path);
...@@ -288,15 +294,16 @@ struct device_node *of_find_node_by_name(struct device_node *from, ...@@ -288,15 +294,16 @@ struct device_node *of_find_node_by_name(struct device_node *from,
const char *name) const char *name)
{ {
struct device_node *np; struct device_node *np;
unsigned long flags;
atomic_spin_lock(&devtree_lock); atomic_spin_lock_irqsave(&devtree_lock, flags);
np = from ? from->allnext : allnodes; np = from ? from->allnext : allnodes;
for (; np; np = np->allnext) for (; np; np = np->allnext)
if (np->name && (of_node_cmp(np->name, name) == 0) if (np->name && (of_node_cmp(np->name, name) == 0)
&& of_node_get(np)) && of_node_get(np))
break; break;
of_node_put(from); of_node_put(from);
atomic_spin_unlock(&devtree_lock); atomic_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_find_node_by_name); EXPORT_SYMBOL(of_find_node_by_name);
...@@ -317,15 +324,16 @@ struct device_node *of_find_node_by_type(struct device_node *from, ...@@ -317,15 +324,16 @@ struct device_node *of_find_node_by_type(struct device_node *from,
const char *type) const char *type)
{ {
struct device_node *np; struct device_node *np;
unsigned long flags;
atomic_spin_lock(&devtree_lock); atomic_spin_lock_irqsave(&devtree_lock, flags);
np = from ? from->allnext : allnodes; np = from ? from->allnext : allnodes;
for (; np; np = np->allnext) for (; np; np = np->allnext)
if (np->type && (of_node_cmp(np->type, type) == 0) if (np->type && (of_node_cmp(np->type, type) == 0)
&& of_node_get(np)) && of_node_get(np))
break; break;
of_node_put(from); of_node_put(from);
atomic_spin_unlock(&devtree_lock); atomic_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_find_node_by_type); EXPORT_SYMBOL(of_find_node_by_type);
...@@ -348,8 +356,9 @@ struct device_node *of_find_compatible_node(struct device_node *from, ...@@ -348,8 +356,9 @@ struct device_node *of_find_compatible_node(struct device_node *from,
const char *type, const char *compatible) const char *type, const char *compatible)
{ {
struct device_node *np; struct device_node *np;
unsigned long flags;
atomic_spin_lock(&devtree_lock); atomic_spin_lock_irqsave(&devtree_lock, flags);
np = from ? from->allnext : allnodes; np = from ? from->allnext : allnodes;
for (; np; np = np->allnext) { for (; np; np = np->allnext) {
if (type if (type
...@@ -360,7 +369,7 @@ struct device_node *of_find_compatible_node(struct device_node *from, ...@@ -360,7 +369,7 @@ struct device_node *of_find_compatible_node(struct device_node *from,
break; break;
} }
of_node_put(from); of_node_put(from);
atomic_spin_unlock(&devtree_lock); atomic_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_find_compatible_node); EXPORT_SYMBOL(of_find_compatible_node);
...@@ -382,8 +391,9 @@ struct device_node *of_find_node_with_property(struct device_node *from, ...@@ -382,8 +391,9 @@ struct device_node *of_find_node_with_property(struct device_node *from,
{ {
struct device_node *np; struct device_node *np;
struct property *pp; struct property *pp;
unsigned long flags;
atomic_spin_lock(&devtree_lock); atomic_spin_lock_irqsave(&devtree_lock, flags);
np = from ? from->allnext : allnodes; np = from ? from->allnext : allnodes;
for (; np; np = np->allnext) { for (; np; np = np->allnext) {
for (pp = np->properties; pp != 0; pp = pp->next) { for (pp = np->properties; pp != 0; pp = pp->next) {
...@@ -395,7 +405,7 @@ struct device_node *of_find_node_with_property(struct device_node *from, ...@@ -395,7 +405,7 @@ struct device_node *of_find_node_with_property(struct device_node *from,
} }
out: out:
of_node_put(from); of_node_put(from);
atomic_spin_unlock(&devtree_lock); atomic_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_find_node_with_property); EXPORT_SYMBOL(of_find_node_with_property);
...@@ -433,10 +443,11 @@ const struct of_device_id *of_match_node(const struct of_device_id *matches, ...@@ -433,10 +443,11 @@ const struct of_device_id *of_match_node(const struct of_device_id *matches,
const struct device_node *node) const struct device_node *node)
{ {
const struct of_device_id *match; const struct of_device_id *match;
unsigned long flags;
atomic_spin_lock(&devtree_lock); atomic_spin_lock_irqsave(&devtree_lock, flags);
match = __of_match_node(matches, node); match = __of_match_node(matches, node);
atomic_spin_unlock(&devtree_lock); atomic_spin_unlock_irqrestore(&devtree_lock, flags);
return match; return match;
} }
EXPORT_SYMBOL(of_match_node); EXPORT_SYMBOL(of_match_node);
...@@ -457,15 +468,16 @@ struct device_node *of_find_matching_node(struct device_node *from, ...@@ -457,15 +468,16 @@ struct device_node *of_find_matching_node(struct device_node *from,
const struct of_device_id *matches) const struct of_device_id *matches)
{ {
struct device_node *np; struct device_node *np;
unsigned long flags;
atomic_spin_lock(&devtree_lock); atomic_spin_lock_irqsave(&devtree_lock, flags);
np = from ? from->allnext : allnodes; np = from ? from->allnext : allnodes;
for (; np; np = np->allnext) { for (; np; np = np->allnext) {
if (__of_match_node(matches, np) && of_node_get(np)) if (__of_match_node(matches, np) && of_node_get(np))
break; break;
} }
of_node_put(from); of_node_put(from);
atomic_spin_unlock(&devtree_lock); atomic_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_find_matching_node); EXPORT_SYMBOL(of_find_matching_node);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment