lkml.org 
[lkml]   [2014]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] OF: Add [__]of_find_node_by_full_name
On Wed, Mar 19, 2014 at 12:26 PM, Rob Herring <robherring2@gmail.com> wrote:
> On Tue, Mar 18, 2014 at 4:52 PM, Pantelis Antoniou
> <pantelis.antoniou@konsulko.com> wrote:
>> __of_find_node_by_full_name recursively searches for a matching node
>> with the given full name without taking any locks.
>>
>> of_find_node_by_full_name takes locks and takes a reference on the
>> matching node.
>>
>> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
>> ---
>> drivers/of/base.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> include/linux/of.h | 4 ++++
>> 2 files changed, 62 insertions(+)
>>
>> diff --git a/drivers/of/base.c b/drivers/of/base.c
>> index 19bcdb4..08156e6 100644
>> --- a/drivers/of/base.c
>> +++ b/drivers/of/base.c
>> @@ -1142,6 +1142,64 @@ static void *of_find_property_value_of_size(const struct device_node *np,
>> }
>>
>> /**
>> + * __of_find_node_by_full_name - Find a node with the full name recursively
>> + * @node: Root of the tree to perform the search
>> + * @full_name: Full name of the node to find.
>> + *
>> + * Find a node with the give full name by recursively following any of
>> + * the child node links.
>> + * Returns the matching node, or NULL if not found.
>> + * Note that the devtree lock is not taken, so this function is only
>> + * safe to call on either detached trees, or when devtree lock is already
>> + * taken.
>> + */
>> +struct device_node *__of_find_node_by_full_name(struct device_node *node,
>> + const char *full_name)
>> +{
>> + struct device_node *child, *found;
>> +
>> + if (node == NULL)
>
> Just !node is preferred.
>
>> + return NULL;
>> +
>> + /* check */
>> + if (of_node_cmp(node->full_name, full_name) == 0)
>> + return node;
>> +
>> + __for_each_child_of_node(node, child) {
>> + found = __of_find_node_by_full_name(child, full_name);
>> + if (found != NULL)
>
> "if (found)" is preferred.
>
>> + return found;
>> + }
>> +
>> + return NULL;
>> +}
>> +EXPORT_SYMBOL(__of_find_node_by_full_name);
>
> Does this need to be exported?
>
> In any case, use EXPORT_SYMBOL_GPL.
>
>> +
>> +/**
>> + * of_find_node_by_full_name - Find a node with the full name recursively
>> + * @node: Root of the tree to perform the search
>> + * @full_name: Full name of the node to find.
>> + *
>> + * Find a node with the give full name by recursively following any of
>> + * the child node links.
>> + * Returns the matching node (with a ref taken), or NULL if not found.
>> + */
>> +struct device_node *of_find_node_by_full_name(struct device_node *node,
>> + const char *full_name)
>> +{
>> + unsigned long flags;
>> + struct device_node *np;
>> +
>> + raw_spin_lock_irqsave(&devtree_lock, flags);
>> + np = of_find_node_by_full_name(node, full_name);
>
> Don't you need __of_find_node_by_full_name here.

!?! Did this code get tested?

g.


\
 
 \ /
  Last update: 2014-03-19 22:41    [W:0.064 / U:3.600 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site