Commit bfc4a589 authored by Grant Likely's avatar Grant Likely
parents 09495dda 1421954b
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
The Synopsis designware mobile storage host controller is used to interface The Synopsis designware mobile storage host controller is used to interface
a SoC with storage medium such as eMMC or SD/MMC cards. This file documents a SoC with storage medium such as eMMC or SD/MMC cards. This file documents
differences between the core Synopsis dw mshc controller properties described differences between the core Synopsis dw mshc controller properties described
by synposis-dw-mshc.txt and the properties used by the Samsung Exynos specific by synopsis-dw-mshc.txt and the properties used by the Samsung Exynos specific
extensions to the Synopsis Designware Mobile Storage Host Controller. extensions to the Synopsis Designware Mobile Storage Host Controller.
Required Properties: Required Properties:
......
...@@ -64,7 +64,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len ...@@ -64,7 +64,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
err = -ENODEV; err = -ENODEV;
mutex_lock(&of_set_property_mutex); mutex_lock(&of_set_property_mutex);
write_lock(&devtree_lock); raw_spin_lock(&devtree_lock);
prevp = &dp->properties; prevp = &dp->properties;
while (*prevp) { while (*prevp) {
struct property *prop = *prevp; struct property *prop = *prevp;
...@@ -91,7 +91,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len ...@@ -91,7 +91,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
} }
prevp = &(*prevp)->next; prevp = &(*prevp)->next;
} }
write_unlock(&devtree_lock); raw_spin_unlock(&devtree_lock);
mutex_unlock(&of_set_property_mutex); mutex_unlock(&of_set_property_mutex);
/* XXX Upate procfs if necessary... */ /* XXX Upate procfs if necessary... */
......
...@@ -38,7 +38,7 @@ DEFINE_MUTEX(of_aliases_mutex); ...@@ -38,7 +38,7 @@ DEFINE_MUTEX(of_aliases_mutex);
/* use when traversing tree through the allnext, child, sibling, /* use when traversing tree through the allnext, child, sibling,
* or parent members of struct device_node. * or parent members of struct device_node.
*/ */
DEFINE_RWLOCK(devtree_lock); DEFINE_RAW_SPINLOCK(devtree_lock);
int of_n_addr_cells(struct device_node *np) int of_n_addr_cells(struct device_node *np)
{ {
...@@ -171,10 +171,11 @@ struct property *of_find_property(const struct device_node *np, ...@@ -171,10 +171,11 @@ struct property *of_find_property(const struct device_node *np,
int *lenp) int *lenp)
{ {
struct property *pp; struct property *pp;
unsigned long flags;
read_lock(&devtree_lock); raw_spin_lock_irqsave(&devtree_lock, flags);
pp = __of_find_property(np, name, lenp); pp = __of_find_property(np, name, lenp);
read_unlock(&devtree_lock); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return pp; return pp;
} }
...@@ -192,13 +193,13 @@ struct device_node *of_find_all_nodes(struct device_node *prev) ...@@ -192,13 +193,13 @@ struct device_node *of_find_all_nodes(struct device_node *prev)
{ {
struct device_node *np; struct device_node *np;
read_lock(&devtree_lock); raw_spin_lock(&devtree_lock);
np = prev ? prev->allnext : of_allnodes; np = prev ? prev->allnext : of_allnodes;
for (; np != NULL; np = np->allnext) for (; np != NULL; np = np->allnext)
if (of_node_get(np)) if (of_node_get(np))
break; break;
of_node_put(prev); of_node_put(prev);
read_unlock(&devtree_lock); raw_spin_unlock(&devtree_lock);
return np; return np;
} }
EXPORT_SYMBOL(of_find_all_nodes); EXPORT_SYMBOL(of_find_all_nodes);
...@@ -257,11 +258,12 @@ static int __of_device_is_compatible(const struct device_node *device, ...@@ -257,11 +258,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;
read_lock(&devtree_lock); raw_spin_lock_irqsave(&devtree_lock, flags);
res = __of_device_is_compatible(device, compat); res = __of_device_is_compatible(device, compat);
read_unlock(&devtree_lock); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return res; return res;
} }
EXPORT_SYMBOL(of_device_is_compatible); EXPORT_SYMBOL(of_device_is_compatible);
...@@ -323,13 +325,14 @@ EXPORT_SYMBOL(of_device_is_available); ...@@ -323,13 +325,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;
read_lock(&devtree_lock); raw_spin_lock_irqsave(&devtree_lock, flags);
np = of_node_get(node->parent); np = of_node_get(node->parent);
read_unlock(&devtree_lock); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_get_parent); EXPORT_SYMBOL(of_get_parent);
...@@ -348,14 +351,15 @@ EXPORT_SYMBOL(of_get_parent); ...@@ -348,14 +351,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;
read_lock(&devtree_lock); raw_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);
read_unlock(&devtree_lock); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return parent; return parent;
} }
...@@ -371,14 +375,15 @@ struct device_node *of_get_next_child(const struct device_node *node, ...@@ -371,14 +375,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;
read_lock(&devtree_lock); raw_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);
read_unlock(&devtree_lock); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return next; return next;
} }
EXPORT_SYMBOL(of_get_next_child); EXPORT_SYMBOL(of_get_next_child);
...@@ -396,7 +401,7 @@ struct device_node *of_get_next_available_child(const struct device_node *node, ...@@ -396,7 +401,7 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
{ {
struct device_node *next; struct device_node *next;
read_lock(&devtree_lock); raw_spin_lock(&devtree_lock);
next = prev ? prev->sibling : node->child; next = prev ? prev->sibling : node->child;
for (; next; next = next->sibling) { for (; next; next = next->sibling) {
if (!of_device_is_available(next)) if (!of_device_is_available(next))
...@@ -405,7 +410,7 @@ struct device_node *of_get_next_available_child(const struct device_node *node, ...@@ -405,7 +410,7 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
break; break;
} }
of_node_put(prev); of_node_put(prev);
read_unlock(&devtree_lock); raw_spin_unlock(&devtree_lock);
return next; return next;
} }
EXPORT_SYMBOL(of_get_next_available_child); EXPORT_SYMBOL(of_get_next_available_child);
...@@ -443,14 +448,15 @@ EXPORT_SYMBOL(of_get_child_by_name); ...@@ -443,14 +448,15 @@ EXPORT_SYMBOL(of_get_child_by_name);
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 = of_allnodes; struct device_node *np = of_allnodes;
unsigned long flags;
read_lock(&devtree_lock); raw_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;
} }
read_unlock(&devtree_lock); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_find_node_by_path); EXPORT_SYMBOL(of_find_node_by_path);
...@@ -470,15 +476,16 @@ struct device_node *of_find_node_by_name(struct device_node *from, ...@@ -470,15 +476,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;
read_lock(&devtree_lock); raw_spin_lock_irqsave(&devtree_lock, flags);
np = from ? from->allnext : of_allnodes; np = from ? from->allnext : of_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);
read_unlock(&devtree_lock); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_find_node_by_name); EXPORT_SYMBOL(of_find_node_by_name);
...@@ -499,15 +506,16 @@ struct device_node *of_find_node_by_type(struct device_node *from, ...@@ -499,15 +506,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;
read_lock(&devtree_lock); raw_spin_lock_irqsave(&devtree_lock, flags);
np = from ? from->allnext : of_allnodes; np = from ? from->allnext : of_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);
read_unlock(&devtree_lock); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_find_node_by_type); EXPORT_SYMBOL(of_find_node_by_type);
...@@ -530,8 +538,9 @@ struct device_node *of_find_compatible_node(struct device_node *from, ...@@ -530,8 +538,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;
read_lock(&devtree_lock); raw_spin_lock_irqsave(&devtree_lock, flags);
np = from ? from->allnext : of_allnodes; np = from ? from->allnext : of_allnodes;
for (; np; np = np->allnext) { for (; np; np = np->allnext) {
if (type if (type
...@@ -542,7 +551,7 @@ struct device_node *of_find_compatible_node(struct device_node *from, ...@@ -542,7 +551,7 @@ struct device_node *of_find_compatible_node(struct device_node *from,
break; break;
} }
of_node_put(from); of_node_put(from);
read_unlock(&devtree_lock); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_find_compatible_node); EXPORT_SYMBOL(of_find_compatible_node);
...@@ -564,8 +573,9 @@ struct device_node *of_find_node_with_property(struct device_node *from, ...@@ -564,8 +573,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;
read_lock(&devtree_lock); raw_spin_lock_irqsave(&devtree_lock, flags);
np = from ? from->allnext : of_allnodes; np = from ? from->allnext : of_allnodes;
for (; np; np = np->allnext) { for (; np; np = np->allnext) {
for (pp = np->properties; pp; pp = pp->next) { for (pp = np->properties; pp; pp = pp->next) {
...@@ -577,7 +587,7 @@ struct device_node *of_find_node_with_property(struct device_node *from, ...@@ -577,7 +587,7 @@ struct device_node *of_find_node_with_property(struct device_node *from,
} }
out: out:
of_node_put(from); of_node_put(from);
read_unlock(&devtree_lock); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_find_node_with_property); EXPORT_SYMBOL(of_find_node_with_property);
...@@ -618,10 +628,11 @@ const struct of_device_id *of_match_node(const struct of_device_id *matches, ...@@ -618,10 +628,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;
read_lock(&devtree_lock); raw_spin_lock_irqsave(&devtree_lock, flags);
match = __of_match_node(matches, node); match = __of_match_node(matches, node);
read_unlock(&devtree_lock); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return match; return match;
} }
EXPORT_SYMBOL(of_match_node); EXPORT_SYMBOL(of_match_node);
...@@ -645,11 +656,12 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from, ...@@ -645,11 +656,12 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
{ {
struct device_node *np; struct device_node *np;
const struct of_device_id *m; const struct of_device_id *m;
unsigned long flags;
if (match) if (match)
*match = NULL; *match = NULL;
read_lock(&devtree_lock); raw_spin_lock_irqsave(&devtree_lock, flags);
np = from ? from->allnext : of_allnodes; np = from ? from->allnext : of_allnodes;
for (; np; np = np->allnext) { for (; np; np = np->allnext) {
m = __of_match_node(matches, np); m = __of_match_node(matches, np);
...@@ -660,7 +672,7 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from, ...@@ -660,7 +672,7 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
} }
} }
of_node_put(from); of_node_put(from);
read_unlock(&devtree_lock); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return np; return np;
} }
EXPORT_SYMBOL(of_find_matching_node_and_match); EXPORT_SYMBOL(of_find_matching_node_and_match);
...@@ -703,12 +715,12 @@ struct device_node *of_find_node_by_phandle(phandle handle) ...@@ -703,12 +715,12 @@ struct device_node *of_find_node_by_phandle(phandle handle)
{ {
struct device_node *np; struct device_node *np;
read_lock(&devtree_lock); raw_spin_lock(&devtree_lock);
for (np = of_allnodes; np; np = np->allnext) for (np = of_allnodes; np; np = np->allnext)
if (np->phandle == handle) if (np->phandle == handle)
break; break;
of_node_get(np); of_node_get(np);
read_unlock(&devtree_lock); raw_spin_unlock(&devtree_lock);
return np; return np;
} }
EXPORT_SYMBOL(of_find_node_by_phandle); EXPORT_SYMBOL(of_find_node_by_phandle);
...@@ -1180,18 +1192,18 @@ int of_add_property(struct device_node *np, struct property *prop) ...@@ -1180,18 +1192,18 @@ int of_add_property(struct device_node *np, struct property *prop)
return rc; return rc;
prop->next = NULL; prop->next = NULL;
write_lock_irqsave(&devtree_lock, flags); raw_spin_lock_irqsave(&devtree_lock, flags);
next = &np->properties; next = &np->properties;
while (*next) { while (*next) {
if (strcmp(prop->name, (*next)->name) == 0) { if (strcmp(prop->name, (*next)->name) == 0) {
/* duplicate ! don't insert it */ /* duplicate ! don't insert it */
write_unlock_irqrestore(&devtree_lock, flags); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return -1; return -1;
} }
next = &(*next)->next; next = &(*next)->next;
} }
*next = prop; *next = prop;
write_unlock_irqrestore(&devtree_lock, flags); raw_spin_unlock_irqrestore(&devtree_lock, flags);
#ifdef CONFIG_PROC_DEVICETREE #ifdef CONFIG_PROC_DEVICETREE
/* try to add to proc as well if it was initialized */ /* try to add to proc as well if it was initialized */
...@@ -1221,7 +1233,7 @@ int of_remove_property(struct device_node *np, struct property *prop) ...@@ -1221,7 +1233,7 @@ int of_remove_property(struct device_node *np, struct property *prop)
if (rc) if (rc)
return rc; return rc;
write_lock_irqsave(&devtree_lock, flags); raw_spin_lock_irqsave(&devtree_lock, flags);
next = &np->properties; next = &np->properties;
while (*next) { while (*next) {
if (*next == prop) { if (*next == prop) {
...@@ -1234,7 +1246,7 @@ int of_remove_property(struct device_node *np, struct property *prop) ...@@ -1234,7 +1246,7 @@ int of_remove_property(struct device_node *np, struct property *prop)
} }
next = &(*next)->next; next = &(*next)->next;
} }
write_unlock_irqrestore(&devtree_lock, flags); raw_spin_unlock_irqrestore(&devtree_lock, flags);
if (!found) if (!found)
return -ENODEV; return -ENODEV;
...@@ -1274,7 +1286,7 @@ int of_update_property(struct device_node *np, struct property *newprop) ...@@ -1274,7 +1286,7 @@ int of_update_property(struct device_node *np, struct property *newprop)
if (!oldprop) if (!oldprop)
return of_add_property(np, newprop); return of_add_property(np, newprop);
write_lock_irqsave(&devtree_lock, flags); raw_spin_lock_irqsave(&devtree_lock, flags);
next = &np->properties; next = &np->properties;
while (*next) { while (*next) {
if (*next == oldprop) { if (*next == oldprop) {
...@@ -1288,7 +1300,7 @@ int of_update_property(struct device_node *np, struct property *newprop) ...@@ -1288,7 +1300,7 @@ int of_update_property(struct device_node *np, struct property *newprop)
} }
next = &(*next)->next; next = &(*next)->next;
} }
write_unlock_irqrestore(&devtree_lock, flags); raw_spin_unlock_irqrestore(&devtree_lock, flags);
if (!found) if (!found)
return -ENODEV; return -ENODEV;
...@@ -1361,12 +1373,12 @@ int of_attach_node(struct device_node *np) ...@@ -1361,12 +1373,12 @@ int of_attach_node(struct device_node *np)
if (rc) if (rc)
return rc; return rc;
write_lock_irqsave(&devtree_lock, flags); raw_spin_lock_irqsave(&devtree_lock, flags);
np->sibling = np->parent->child; np->sibling = np->parent->child;
np->allnext = of_allnodes; np->allnext = of_allnodes;
np->parent->child = np; np->parent->child = np;
of_allnodes = np; of_allnodes = np;
write_unlock_irqrestore(&devtree_lock, flags); raw_spin_unlock_irqrestore(&devtree_lock, flags);
of_add_proc_dt_entry(np); of_add_proc_dt_entry(np);
return 0; return 0;
...@@ -1409,17 +1421,17 @@ int of_detach_node(struct device_node *np) ...@@ -1409,17 +1421,17 @@ int of_detach_node(struct device_node *np)
if (rc) if (rc)
return rc; return rc;
write_lock_irqsave(&devtree_lock, flags); raw_spin_lock_irqsave(&devtree_lock, flags);
if (of_node_check_flag(np, OF_DETACHED)) { if (of_node_check_flag(np, OF_DETACHED)) {
/* someone already detached it */ /* someone already detached it */
write_unlock_irqrestore(&devtree_lock, flags); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return rc; return rc;
} }
parent = np->parent; parent = np->parent;
if (!parent) { if (!parent) {
write_unlock_irqrestore(&devtree_lock, flags); raw_spin_unlock_irqrestore(&devtree_lock, flags);
return rc; return rc;
} }
...@@ -1446,7 +1458,7 @@ int of_detach_node(struct device_node *np) ...@@ -1446,7 +1458,7 @@ int of_detach_node(struct device_node *np)
} }
of_node_set_flag(np, OF_DETACHED); of_node_set_flag(np, OF_DETACHED);
write_unlock_irqrestore(&devtree_lock, flags); raw_spin_unlock_irqrestore(&devtree_lock, flags);
of_remove_proc_dt_entry(np); of_remove_proc_dt_entry(np);
return rc; return rc;
......
...@@ -92,7 +92,7 @@ static inline void of_node_put(struct device_node *node) { } ...@@ -92,7 +92,7 @@ static inline void of_node_put(struct device_node *node) { }
extern struct device_node *of_allnodes; extern struct device_node *of_allnodes;
extern struct device_node *of_chosen; extern struct device_node *of_chosen;
extern struct device_node *of_aliases; extern struct device_node *of_aliases;
extern rwlock_t devtree_lock; extern raw_spinlock_t devtree_lock;
static inline bool of_have_populated_dt(void) static inline bool of_have_populated_dt(void)
{ {
......
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