Consolidate of_find_property
The only change here is that a readlock is taken while the property list is being traversed on Sparc where it was not taken previously. Also, Sparc uses strcasecmp to compare property names while PowerPC uses strcmp. Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Acked-by: Paul Mackerras <paulus@samba.org> Acked-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
0081cbc373
Коммит
581b605a83
|
@ -80,10 +80,7 @@ struct boot_param_header *initial_boot_params;
|
||||||
|
|
||||||
static struct device_node *allnodes = NULL;
|
static struct device_node *allnodes = NULL;
|
||||||
|
|
||||||
/* use when traversing tree through the allnext, child, sibling,
|
extern rwlock_t devtree_lock; /* temporary while merging */
|
||||||
* or parent members of struct device_node.
|
|
||||||
*/
|
|
||||||
static DEFINE_RWLOCK(devtree_lock);
|
|
||||||
|
|
||||||
/* export that to outside world */
|
/* export that to outside world */
|
||||||
struct device_node *of_chosen;
|
struct device_node *of_chosen;
|
||||||
|
@ -1489,25 +1486,6 @@ static int __init prom_reconfig_setup(void)
|
||||||
__initcall(prom_reconfig_setup);
|
__initcall(prom_reconfig_setup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct property *of_find_property(const struct device_node *np,
|
|
||||||
const char *name,
|
|
||||||
int *lenp)
|
|
||||||
{
|
|
||||||
struct property *pp;
|
|
||||||
|
|
||||||
read_lock(&devtree_lock);
|
|
||||||
for (pp = np->properties; pp != 0; pp = pp->next)
|
|
||||||
if (strcmp(pp->name, name) == 0) {
|
|
||||||
if (lenp != 0)
|
|
||||||
*lenp = pp->length;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
read_unlock(&devtree_lock);
|
|
||||||
|
|
||||||
return pp;
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(of_find_property);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add a property to a node
|
* Add a property to a node
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -27,10 +27,7 @@
|
||||||
|
|
||||||
static struct device_node *allnodes;
|
static struct device_node *allnodes;
|
||||||
|
|
||||||
/* use when traversing tree through the allnext, child, sibling,
|
extern rwlock_t devtree_lock; /* temporary while merging */
|
||||||
* or parent members of struct device_node.
|
|
||||||
*/
|
|
||||||
static DEFINE_RWLOCK(devtree_lock);
|
|
||||||
|
|
||||||
struct device_node *of_get_parent(const struct device_node *node)
|
struct device_node *of_get_parent(const struct device_node *node)
|
||||||
{
|
{
|
||||||
|
@ -130,23 +127,6 @@ struct device_node *of_find_compatible_node(struct device_node *from,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(of_find_compatible_node);
|
EXPORT_SYMBOL(of_find_compatible_node);
|
||||||
|
|
||||||
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 (strcasecmp(pp->name, name) == 0) {
|
|
||||||
if (lenp != 0)
|
|
||||||
*lenp = pp->length;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pp;
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(of_find_property);
|
|
||||||
|
|
||||||
int of_getintprop_default(struct device_node *np, const char *name, int def)
|
int of_getintprop_default(struct device_node *np, const char *name, int def)
|
||||||
{
|
{
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
|
|
|
@ -32,10 +32,7 @@
|
||||||
|
|
||||||
static struct device_node *allnodes;
|
static struct device_node *allnodes;
|
||||||
|
|
||||||
/* use when traversing tree through the allnext, child, sibling,
|
extern rwlock_t devtree_lock; /* temporary while merging */
|
||||||
* or parent members of struct device_node.
|
|
||||||
*/
|
|
||||||
static DEFINE_RWLOCK(devtree_lock);
|
|
||||||
|
|
||||||
struct device_node *of_get_parent(const struct device_node *node)
|
struct device_node *of_get_parent(const struct device_node *node)
|
||||||
{
|
{
|
||||||
|
@ -135,23 +132,6 @@ struct device_node *of_find_compatible_node(struct device_node *from,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(of_find_compatible_node);
|
EXPORT_SYMBOL(of_find_compatible_node);
|
||||||
|
|
||||||
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 (strcasecmp(pp->name, name) == 0) {
|
|
||||||
if (lenp != 0)
|
|
||||||
*lenp = pp->length;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pp;
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(of_find_property);
|
|
||||||
|
|
||||||
int of_getintprop_default(struct device_node *np, const char *name, int def)
|
int of_getintprop_default(struct device_node *np, const char *name, int def)
|
||||||
{
|
{
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
|
|
|
@ -18,6 +18,12 @@
|
||||||
*/
|
*/
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
|
#include <linux/spinlock.h>
|
||||||
|
|
||||||
|
/* use when traversing tree through the allnext, child, sibling,
|
||||||
|
* or parent members of struct device_node.
|
||||||
|
*/
|
||||||
|
DEFINE_RWLOCK(devtree_lock);
|
||||||
|
|
||||||
int of_n_addr_cells(struct device_node *np)
|
int of_n_addr_cells(struct device_node *np)
|
||||||
{
|
{
|
||||||
|
@ -51,6 +57,26 @@ int of_n_size_cells(struct device_node *np)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(of_n_size_cells);
|
EXPORT_SYMBOL(of_n_size_cells);
|
||||||
|
|
||||||
|
struct property *of_find_property(const struct device_node *np,
|
||||||
|
const char *name,
|
||||||
|
int *lenp)
|
||||||
|
{
|
||||||
|
struct property *pp;
|
||||||
|
|
||||||
|
read_lock(&devtree_lock);
|
||||||
|
for (pp = np->properties; pp != 0; pp = pp->next) {
|
||||||
|
if (of_prop_cmp(pp->name, name) == 0) {
|
||||||
|
if (lenp != 0)
|
||||||
|
*lenp = pp->length;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
read_unlock(&devtree_lock);
|
||||||
|
|
||||||
|
return pp;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(of_find_property);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find a property with a given name for a given node
|
* Find a property with a given name for a given node
|
||||||
* and return the value.
|
* and return the value.
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
|
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
|
||||||
|
|
||||||
#define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l))
|
#define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l))
|
||||||
|
#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
|
||||||
|
|
||||||
/* Definitions used by the flattened device tree */
|
/* Definitions used by the flattened device tree */
|
||||||
#define OF_DT_HEADER 0xd00dfeed /* marker */
|
#define OF_DT_HEADER 0xd00dfeed /* marker */
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
|
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
|
||||||
|
|
||||||
#define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l))
|
#define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l))
|
||||||
|
#define of_prop_cmp(s1, s2) strcasecmp((s1), (s2))
|
||||||
|
|
||||||
typedef u32 phandle;
|
typedef u32 phandle;
|
||||||
typedef u32 ihandle;
|
typedef u32 ihandle;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
|
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
|
||||||
|
|
||||||
#define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l))
|
#define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l))
|
||||||
|
#define of_prop_cmp(s1, s2) strcasecmp((s1), (s2))
|
||||||
|
|
||||||
typedef u32 phandle;
|
typedef u32 phandle;
|
||||||
typedef u32 ihandle;
|
typedef u32 ihandle;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче