| From 6612f21aa244a24ed3dc210b15d92fee5d1c98ad Mon Sep 17 00:00:00 2001 |
| From: Thomas Gleixner <tglx@linutronix.de> |
| Date: Wed, 29 Jul 2009 13:59:43 +0200 |
| Subject: [PATCH] powerpc: OF convert to raw lock |
| |
| commit 5b659531c96943c3eea21b3dbcb83e6320d0f46b in tip. |
| |
| Replaced the RW lock for now with raw_spinlock. We have no |
| raw_rwlocks in -rt right now and I doubt that the OF path is |
| performance critical. |
| |
| Signed-off-by: Thomas Gleixner <tglx@linutronix.de> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/of/base.c b/drivers/of/base.c |
| index cb96888..861c9d6 100644 |
| --- a/drivers/of/base.c |
| +++ b/drivers/of/base.c |
| @@ -28,7 +28,7 @@ struct device_node *of_chosen; |
| /* use when traversing tree through the allnext, child, sibling, |
| * 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) |
| { |
| @@ -146,7 +146,7 @@ struct property *of_find_property(const struct device_node *np, |
| if (!np) |
| return NULL; |
| |
| - read_lock(&devtree_lock); |
| + raw_spin_lock(&devtree_lock); |
| for (pp = np->properties; pp != 0; pp = pp->next) { |
| if (of_prop_cmp(pp->name, name) == 0) { |
| if (lenp != 0) |
| @@ -154,7 +154,7 @@ struct property *of_find_property(const struct device_node *np, |
| break; |
| } |
| } |
| - read_unlock(&devtree_lock); |
| + raw_spin_unlock(&devtree_lock); |
| |
| return pp; |
| } |
| @@ -172,13 +172,13 @@ struct device_node *of_find_all_nodes(struct device_node *prev) |
| { |
| struct device_node *np; |
| |
| - read_lock(&devtree_lock); |
| + raw_spin_lock(&devtree_lock); |
| np = prev ? prev->allnext : allnodes; |
| for (; np != NULL; np = np->allnext) |
| if (of_node_get(np)) |
| break; |
| of_node_put(prev); |
| - read_unlock(&devtree_lock); |
| + raw_spin_unlock(&devtree_lock); |
| return np; |
| } |
| EXPORT_SYMBOL(of_find_all_nodes); |
| @@ -281,9 +281,9 @@ struct device_node *of_get_parent(const struct device_node *node) |
| if (!node) |
| return NULL; |
| |
| - read_lock(&devtree_lock); |
| + raw_spin_lock(&devtree_lock); |
| np = of_node_get(node->parent); |
| - read_unlock(&devtree_lock); |
| + raw_spin_unlock(&devtree_lock); |
| return np; |
| } |
| EXPORT_SYMBOL(of_get_parent); |
| @@ -306,10 +306,10 @@ struct device_node *of_get_next_parent(struct device_node *node) |
| if (!node) |
| return NULL; |
| |
| - read_lock(&devtree_lock); |
| + raw_spin_lock(&devtree_lock); |
| parent = of_node_get(node->parent); |
| of_node_put(node); |
| - read_unlock(&devtree_lock); |
| + raw_spin_unlock(&devtree_lock); |
| return parent; |
| } |
| |
| @@ -326,13 +326,13 @@ struct device_node *of_get_next_child(const struct device_node *node, |
| { |
| struct device_node *next; |
| |
| - read_lock(&devtree_lock); |
| + raw_spin_lock(&devtree_lock); |
| next = prev ? prev->sibling : node->child; |
| for (; next; next = next->sibling) |
| if (of_node_get(next)) |
| break; |
| of_node_put(prev); |
| - read_unlock(&devtree_lock); |
| + raw_spin_unlock(&devtree_lock); |
| return next; |
| } |
| EXPORT_SYMBOL(of_get_next_child); |
| @@ -348,13 +348,13 @@ struct device_node *of_find_node_by_path(const char *path) |
| { |
| struct device_node *np = allnodes; |
| |
| - read_lock(&devtree_lock); |
| + raw_spin_lock(&devtree_lock); |
| for (; np; np = np->allnext) { |
| if (np->full_name && (of_node_cmp(np->full_name, path) == 0) |
| && of_node_get(np)) |
| break; |
| } |
| - read_unlock(&devtree_lock); |
| + raw_spin_unlock(&devtree_lock); |
| return np; |
| } |
| EXPORT_SYMBOL(of_find_node_by_path); |
| @@ -375,14 +375,14 @@ struct device_node *of_find_node_by_name(struct device_node *from, |
| { |
| struct device_node *np; |
| |
| - read_lock(&devtree_lock); |
| + raw_spin_lock(&devtree_lock); |
| np = from ? from->allnext : allnodes; |
| for (; np; np = np->allnext) |
| if (np->name && (of_node_cmp(np->name, name) == 0) |
| && of_node_get(np)) |
| break; |
| of_node_put(from); |
| - read_unlock(&devtree_lock); |
| + raw_spin_unlock(&devtree_lock); |
| return np; |
| } |
| EXPORT_SYMBOL(of_find_node_by_name); |
| @@ -404,14 +404,14 @@ struct device_node *of_find_node_by_type(struct device_node *from, |
| { |
| struct device_node *np; |
| |
| - read_lock(&devtree_lock); |
| + raw_spin_lock(&devtree_lock); |
| np = from ? from->allnext : allnodes; |
| for (; np; np = np->allnext) |
| if (np->type && (of_node_cmp(np->type, type) == 0) |
| && of_node_get(np)) |
| break; |
| of_node_put(from); |
| - read_unlock(&devtree_lock); |
| + raw_spin_unlock(&devtree_lock); |
| return np; |
| } |
| EXPORT_SYMBOL(of_find_node_by_type); |
| @@ -435,7 +435,7 @@ struct device_node *of_find_compatible_node(struct device_node *from, |
| { |
| struct device_node *np; |
| |
| - read_lock(&devtree_lock); |
| + raw_spin_lock(&devtree_lock); |
| np = from ? from->allnext : allnodes; |
| for (; np; np = np->allnext) { |
| if (type |
| @@ -445,7 +445,7 @@ struct device_node *of_find_compatible_node(struct device_node *from, |
| break; |
| } |
| of_node_put(from); |
| - read_unlock(&devtree_lock); |
| + raw_spin_unlock(&devtree_lock); |
| return np; |
| } |
| EXPORT_SYMBOL(of_find_compatible_node); |
| @@ -468,7 +468,7 @@ struct device_node *of_find_node_with_property(struct device_node *from, |
| struct device_node *np; |
| struct property *pp; |
| |
| - read_lock(&devtree_lock); |
| + raw_spin_lock(&devtree_lock); |
| np = from ? from->allnext : allnodes; |
| for (; np; np = np->allnext) { |
| for (pp = np->properties; pp != 0; pp = pp->next) { |
| @@ -480,7 +480,7 @@ struct device_node *of_find_node_with_property(struct device_node *from, |
| } |
| out: |
| of_node_put(from); |
| - read_unlock(&devtree_lock); |
| + raw_spin_unlock(&devtree_lock); |
| return np; |
| } |
| EXPORT_SYMBOL(of_find_node_with_property); |
| @@ -531,14 +531,14 @@ struct device_node *of_find_matching_node(struct device_node *from, |
| { |
| struct device_node *np; |
| |
| - read_lock(&devtree_lock); |
| + raw_spin_lock(&devtree_lock); |
| np = from ? from->allnext : allnodes; |
| for (; np; np = np->allnext) { |
| if (of_match_node(matches, np) && of_node_get(np)) |
| break; |
| } |
| of_node_put(from); |
| - read_unlock(&devtree_lock); |
| + raw_spin_unlock(&devtree_lock); |
| return np; |
| } |
| EXPORT_SYMBOL(of_find_matching_node); |
| @@ -627,12 +627,12 @@ struct device_node *of_find_node_by_phandle(phandle handle) |
| { |
| struct device_node *np; |
| |
| - read_lock(&devtree_lock); |
| + raw_spin_lock(&devtree_lock); |
| for (np = allnodes; np; np = np->allnext) |
| if (np->phandle == handle) |
| break; |
| of_node_get(np); |
| - read_unlock(&devtree_lock); |
| + raw_spin_unlock(&devtree_lock); |
| return np; |
| } |
| EXPORT_SYMBOL(of_find_node_by_phandle); |
| @@ -787,18 +787,18 @@ int prom_add_property(struct device_node *np, struct property *prop) |
| unsigned long flags; |
| |
| prop->next = NULL; |
| - write_lock_irqsave(&devtree_lock, flags); |
| + raw_spin_lock_irqsave(&devtree_lock, flags); |
| next = &np->properties; |
| while (*next) { |
| if (strcmp(prop->name, (*next)->name) == 0) { |
| /* duplicate ! don't insert it */ |
| - write_unlock_irqrestore(&devtree_lock, flags); |
| + raw_spin_unlock_irqrestore(&devtree_lock, flags); |
| return -1; |
| } |
| next = &(*next)->next; |
| } |
| *next = prop; |
| - write_unlock_irqrestore(&devtree_lock, flags); |
| + raw_spin_unlock_irqrestore(&devtree_lock, flags); |
| |
| #ifdef CONFIG_PROC_DEVICETREE |
| /* try to add to proc as well if it was initialized */ |
| @@ -823,7 +823,7 @@ int prom_remove_property(struct device_node *np, struct property *prop) |
| unsigned long flags; |
| int found = 0; |
| |
| - write_lock_irqsave(&devtree_lock, flags); |
| + raw_spin_lock_irqsave(&devtree_lock, flags); |
| next = &np->properties; |
| while (*next) { |
| if (*next == prop) { |
| @@ -836,7 +836,7 @@ int prom_remove_property(struct device_node *np, struct property *prop) |
| } |
| next = &(*next)->next; |
| } |
| - write_unlock_irqrestore(&devtree_lock, flags); |
| + raw_spin_unlock_irqrestore(&devtree_lock, flags); |
| |
| if (!found) |
| return -ENODEV; |
| @@ -866,7 +866,7 @@ int prom_update_property(struct device_node *np, |
| unsigned long flags; |
| int found = 0; |
| |
| - write_lock_irqsave(&devtree_lock, flags); |
| + raw_spin_lock_irqsave(&devtree_lock, flags); |
| next = &np->properties; |
| while (*next) { |
| if (*next == oldprop) { |
| @@ -880,7 +880,7 @@ int prom_update_property(struct device_node *np, |
| } |
| next = &(*next)->next; |
| } |
| - write_unlock_irqrestore(&devtree_lock, flags); |
| + raw_spin_unlock_irqrestore(&devtree_lock, flags); |
| |
| if (!found) |
| return -ENODEV; |
| @@ -910,12 +910,12 @@ void of_attach_node(struct device_node *np) |
| { |
| unsigned long flags; |
| |
| - write_lock_irqsave(&devtree_lock, flags); |
| + raw_spin_lock_irqsave(&devtree_lock, flags); |
| np->sibling = np->parent->child; |
| np->allnext = allnodes; |
| np->parent->child = np; |
| allnodes = np; |
| - write_unlock_irqrestore(&devtree_lock, flags); |
| + raw_spin_unlock_irqrestore(&devtree_lock, flags); |
| } |
| |
| /** |
| @@ -929,7 +929,7 @@ void of_detach_node(struct device_node *np) |
| struct device_node *parent; |
| unsigned long flags; |
| |
| - write_lock_irqsave(&devtree_lock, flags); |
| + raw_spin_lock_irqsave(&devtree_lock, flags); |
| |
| parent = np->parent; |
| if (!parent) |
| @@ -960,7 +960,7 @@ void of_detach_node(struct device_node *np) |
| of_node_set_flag(np, OF_DETACHED); |
| |
| out_unlock: |
| - write_unlock_irqrestore(&devtree_lock, flags); |
| + raw_spin_unlock_irqrestore(&devtree_lock, flags); |
| } |
| #endif /* defined(CONFIG_OF_DYNAMIC) */ |
| |
| diff --git a/include/linux/of.h b/include/linux/of.h |
| index f6d9cbc..d8869f7 100644 |
| --- a/include/linux/of.h |
| +++ b/include/linux/of.h |
| @@ -68,7 +68,7 @@ struct device_node { |
| /* Pointer for first entry in chain of all nodes. */ |
| extern struct device_node *allnodes; |
| extern struct device_node *of_chosen; |
| -extern rwlock_t devtree_lock; |
| +extern raw_spinlock_t devtree_lock; |
| |
| static inline int of_node_check_flag(struct device_node *n, unsigned long flag) |
| { |
| -- |
| 1.7.1.1 |
| |