Skip to content

Commit

Permalink
of: merge of_find_all_nodes() implementations
Browse files Browse the repository at this point in the history
Merge common code between Microblaze and PowerPC, and make it available
to Sparc

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Acked-by: Michal Simek <monstr@monstr.eu>
Acked-by: Stephen Neuendorffer <stephen.neuendorffer@xilinx.com>
Acked-by: Stephen Rothwell <sfr@canb.auug.org.au>
  • Loading branch information
Grant Likely committed Oct 15, 2009
1 parent 82b2928 commit e91edcf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 48 deletions.
23 changes: 0 additions & 23 deletions arch/microblaze/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,29 +859,6 @@ struct device_node *of_find_node_by_phandle(phandle handle)
}
EXPORT_SYMBOL(of_find_node_by_phandle);

/**
* of_find_all_nodes - Get next node in global list
* @prev: Previous node or NULL to start iteration
* of_node_put() will be called on it
*
* Returns a node pointer with refcount incremented, use
* of_node_put() on it when done.
*/
struct device_node *of_find_all_nodes(struct device_node *prev)
{
struct device_node *np;

read_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);
return np;
}
EXPORT_SYMBOL(of_find_all_nodes);

/**
* of_node_get - Increment refcount of a node
* @node: Node to inc refcount, NULL is supported to
Expand Down
23 changes: 0 additions & 23 deletions arch/powerpc/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1316,29 +1316,6 @@ struct device_node *of_find_next_cache_node(struct device_node *np)
return NULL;
}

/**
* of_find_all_nodes - Get next node in global list
* @prev: Previous node or NULL to start iteration
* of_node_put() will be called on it
*
* Returns a node pointer with refcount incremented, use
* of_node_put() on it when done.
*/
struct device_node *of_find_all_nodes(struct device_node *prev)
{
struct device_node *np;

read_lock(&devtree_lock);
np = prev ? prev->allnext : allnodes;
for (; np != 0; np = np->allnext)
if (of_node_get(np))
break;
of_node_put(prev);
read_unlock(&devtree_lock);
return np;
}
EXPORT_SYMBOL(of_find_all_nodes);

/**
* of_node_get - Increment refcount of a node
* @node: Node to inc refcount, NULL is supported to
Expand Down
26 changes: 25 additions & 1 deletion drivers/of/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
*
* Adapted for sparc and sparc64 by David S. Miller davem@davemloft.net
*
* Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell.
* Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell and
* Grant Likely.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -82,6 +83,29 @@ struct property *of_find_property(const struct device_node *np,
}
EXPORT_SYMBOL(of_find_property);

/**
* of_find_all_nodes - Get next node in global list
* @prev: Previous node or NULL to start iteration
* of_node_put() will be called on it
*
* Returns a node pointer with refcount incremented, use
* of_node_put() on it when done.
*/
struct device_node *of_find_all_nodes(struct device_node *prev)
{
struct device_node *np;

read_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);
return np;
}
EXPORT_SYMBOL(of_find_all_nodes);

/*
* Find a property with a given name for a given node
* and return the value.
Expand Down
3 changes: 2 additions & 1 deletion include/linux/of.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
dn->pde = de;
}

extern struct device_node *of_find_all_nodes(struct device_node *prev);

#if defined(CONFIG_SPARC)
/* Dummy ref counting routines - to be implemented later */
static inline struct device_node *of_node_get(struct device_node *node)
Expand All @@ -90,7 +92,6 @@ static inline void of_node_put(struct device_node *node)
}

#else
extern struct device_node *of_find_all_nodes(struct device_node *prev);
extern struct device_node *of_node_get(struct device_node *node);
extern void of_node_put(struct device_node *node);
#endif
Expand Down

0 comments on commit e91edcf

Please sign in to comment.