From: Nicolas Ferre <nicolas.ferre@microchip.com>
To: Claudiu Beznea - M18063 <Claudiu.Beznea@microchip.com>,
"sre@kernel.org" <sre@kernel.org>,
"alexandre.belloni@bootlin.com" <alexandre.belloni@bootlin.com>,
Ludovic Desroches - M43218 <Ludovic.Desroches@microchip.com>
Cc: "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
kernel test robot <lkp@intel.com>,
"Dan Carpenter" <dan.carpenter@oracle.com>
Subject: Re: [PATCH] power: reset: at91-reset: free resources on exit path
Date: Fri, 2 Apr 2021 09:32:01 +0200 [thread overview]
Message-ID: <f9519a82-4fce-13ac-f51e-8364bc5f8694@microchip.com> (raw)
In-Reply-To: <ee7f39b3-8f7a-deb4-b4b2-dfc8e2ba86f9@microchip.com>
On 01/04/2021 at 16:42, Claudiu Beznea - M18063 wrote:
>>> +unmap:
>>> + iounmap(reset->rstc_base);
>>> + for (idx = 0; idx < ARRAY_SIZE(reset->ramc_base); idx++)
>>> + iounmap(reset->ramc_base[idx]);
>> But if we keep this loop, I have the feeling that some kind of
>> "of_node_put()" is needed as well.
> No! In the loop:
>
> for_each_matching_node_and_match(np, at91_ramc_of_match, &match) {
> reset->ramc_lpr = (u32)match->data;
> reset->ramc_base[idx] = of_iomap(np, 0);
> if (!reset->ramc_base[idx]) {
> dev_err(&pdev->dev, "Could not map ram controller address\n");
> of_node_put(np);
> ret = -ENODEV;
> goto unmap;
> }
> idx++;
> }
>
> the of_node_put() is needed only if the loop is interrupted as the macro:
> for_each_matching_node_and_match() is defined as follows:
>
> #define for_each_matching_node_and_match(dn, matches, match) \
> for (dn = of_find_matching_node_and_match(NULL, matches, match); \
> dn; dn = of_find_matching_node_and_match(dn, matches, match))
>
> and of_find_matching_node_and_match() will return a np with refcount
> incremented but at the next loop step the of_find_matching_node_and_match()
> will be called with the same np pointer and the np refcount will be
> decremented.
>
> struct device_node *of_find_matching_node_and_match(
> struct device_node *from,
> const struct of_device_id *matches,
> const struct of_device_id **match)
> {
> // ...
> of_node_put(from);
> // ...
> }
Oh yes you're right Claudiu, I overlooked this one. Thanks for the
in-depth explanation.
Best regards,
Nicolas
--
Nicolas Ferre
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2021-04-02 7:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 11:01 [PATCH] power: reset: at91-reset: free resources on exit path Claudiu Beznea
2021-03-31 8:18 ` Nicolas Ferre
2021-04-01 14:42 ` Claudiu.Beznea
2021-04-01 14:50 ` Claudiu.Beznea
2021-04-02 7:32 ` Nicolas Ferre [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=f9519a82-4fce-13ac-f51e-8364bc5f8694@microchip.com \
--to=nicolas.ferre@microchip.com \
--cc=Claudiu.Beznea@microchip.com \
--cc=Ludovic.Desroches@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=dan.carpenter@oracle.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lkp@intel.com \
--cc=sre@kernel.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