From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Shawn Guo <shawn.guo-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: Re: Unbalanced of_node_put{get} on initial 'from' node?
Date: Thu, 14 Jul 2011 20:54:15 -0600 [thread overview]
Message-ID: <20110715025415.GK2927@ponder.secretlab.ca> (raw)
In-Reply-To: <20110714163956.GA1534-+NayF8gZjK2ctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
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.
prev parent reply other threads:[~2011-07-15 2:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110715025415.GK2927@ponder.secretlab.ca \
--to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=shawn.guo-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).