* Unbalanced of_node_put{get} on initial 'from' node?
@ 2011-07-14 16:39 Shawn Guo
[not found] ` <20110714163956.GA1534-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Shawn Guo @ 2011-07-14 16:39 UTC (permalink / raw)
To: Grant Likely; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
Hi Grant,
I'm running into some problem when using of_find_matching_node().
Here is the pseudo code.
void foo(struct platform_device *pdev)
{
struct device_node *from = pdev->dev.parent->of_node;
struct device_node *np;
np = of_find_matching_node(from, matches); /* matches is a global of_match */
while (np) {
...... /* do stuff with the node */
np = of_find_matching_node(np, matches);
}
}
I found with above function executed that the node 'from'
gets an unbalanced 'of_node_put' call in of_find_matching_node(). Was
of_find_matching_node() designed in this way? Or should it get
of_node_put{get} on 'from' node balanced?
Using helper macro for_each_matching_node does not run into this
problem, because the initial 'from' node is NULL, which will get
bypassed by of_node_put.
--
Regards,
Shawn
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Unbalanced of_node_put{get} on initial 'from' node?
[not found] ` <20110714163956.GA1534-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
@ 2011-07-15 2:54 ` Grant Likely
0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2011-07-15 2:54 UTC (permalink / raw)
To: Shawn Guo; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
On Fri, Jul 15, 2011 at 12:39:58AM +0800, Shawn Guo wrote:
> Hi Grant,
>
> I'm running into some problem when using of_find_matching_node().
> Here is the pseudo code.
>
> void foo(struct platform_device *pdev)
> {
> struct device_node *from = pdev->dev.parent->of_node;
> struct device_node *np;
>
> np = of_find_matching_node(from, matches); /* matches is a global of_match */
> while (np) {
> ...... /* do stuff with the node */
> np = of_find_matching_node(np, matches);
> }
> }
>
> I found with above function executed that the node 'from'
> gets an unbalanced 'of_node_put' call in of_find_matching_node(). Was
> of_find_matching_node() designed in this way? Or should it get
> of_node_put{get} on 'from' node balanced?
Yes it is. The node returned from of_find_matching node has already
had "of_node_get()" called on it, and the caller is expected to
release it. So, any node passed into of_find_matching_node() instead
of NULL as the starting point must have already had of_node_get()
called on it.
g.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-15 2:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-14 16:39 Unbalanced of_node_put{get} on initial 'from' node? Shawn Guo
[not found] ` <20110714163956.GA1534-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2011-07-15 2:54 ` Grant Likely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).