From: "Liang He" <windhl@126.com>
To: "Tony Lindgren" <tony@atomide.com>
Cc: andre.przywara@arm.com, thierry.reding@gmail.com,
jonathanh@nvidia.com, linux-arm-kernel@lists.infradead.org,
linux-omap@vger.kernel.org, linux-tegra@vger.kernel.org,
"Krzysztof Kozlowski" <krzk@kernel.org>
Subject: Re:Re: [PATCH] arm/mach: Hold reference returned by of_find_xxx APIs
Date: Tue, 28 Jun 2022 12:05:45 +0800 (CST) [thread overview]
Message-ID: <45bb4c11.34fc.181a87c93dd.Coremail.windhl@126.com> (raw)
In-Reply-To: <Yrp8sUMdmfYsiUsD@atomide.com>
At 2022-06-28 11:59:45, "Tony Lindgren" <tony@atomide.com> wrote:
>* Liang He <windhl@126.com> [220621 12:14]:
>> diff --git a/arch/arm/mach-omap2/pmic-cpcap.c b/arch/arm/mach-omap2/pmic-cpcap.c
>> index 668dc84fd31e..a7368d657aa8 100644
>> --- a/arch/arm/mach-omap2/pmic-cpcap.c
>> +++ b/arch/arm/mach-omap2/pmic-cpcap.c
>> @@ -238,8 +238,11 @@ static struct omap_voltdm_pmic omap4_fan_iva = {
>> int __init omap4_cpcap_init(void)
>> {
>> struct voltagedomain *voltdm;
>> + struct device_node *np;
>>
>> - if (!of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
>> + np = of_find_compatible_node(NULL, NULL, "motorola,cpcap");
>> + of_node_put(np);
>> + if (!np)
>> return -ENODEV;
>
>Hmm so here you are checking for !np after of_node_put()?
Hi, Tony.
Thanks very much for your effort to review my code.
I just wanted to use this 'check-after-put' coding style to keep consistent with
existing style.
But based on the disccussion with Greg KH, yesterday, I am now preparing 'check-then-put'
coding style patch.
Link:
https://lore.kernel.org/all/1bed06e5.43da.181a5bac7e5.Coremail.windhl@126.com/
>
>> diff --git a/arch/arm/mach-tegra/irq.c b/arch/arm/mach-tegra/irq.c
>> index 4e1ee70b2a3f..2aeac041bcb9 100644
>> --- a/arch/arm/mach-tegra/irq.c
>> +++ b/arch/arm/mach-tegra/irq.c
>> @@ -88,7 +88,11 @@ static const struct of_device_id tegra_ictlr_match[] __initconst = {
>>
>> void __init tegra_init_irq(void)
>> {
>> - if (WARN_ON(!of_find_matching_node(NULL, tegra_ictlr_match)))
>> + struct device_node *np;
>> +
>> + np = of_find_matching_node(NULL, tegra_ictlr_match);
>> + of_node_put(np);
>> + if (WARN_ON(!np))
>> pr_warn("Outdated DT detected, suspend/resume will NOT work\n");
>>
>> tegra114_gic_cpu_pm_registration();
>
>Here too.
>
>Regards,
>
>Tony
Thanks again, Tony.
I will send a new 'check-and-put' patch soon.
Liang
WARNING: multiple messages have this Message-ID (diff)
From: "Liang He" <windhl@126.com>
To: "Tony Lindgren" <tony@atomide.com>
Cc: andre.przywara@arm.com, thierry.reding@gmail.com,
jonathanh@nvidia.com, linux-arm-kernel@lists.infradead.org,
linux-omap@vger.kernel.org, linux-tegra@vger.kernel.org,
"Krzysztof Kozlowski" <krzk@kernel.org>
Subject: Re:Re: [PATCH] arm/mach: Hold reference returned by of_find_xxx APIs
Date: Tue, 28 Jun 2022 12:05:45 +0800 (CST) [thread overview]
Message-ID: <45bb4c11.34fc.181a87c93dd.Coremail.windhl@126.com> (raw)
In-Reply-To: <Yrp8sUMdmfYsiUsD@atomide.com>
At 2022-06-28 11:59:45, "Tony Lindgren" <tony@atomide.com> wrote:
>* Liang He <windhl@126.com> [220621 12:14]:
>> diff --git a/arch/arm/mach-omap2/pmic-cpcap.c b/arch/arm/mach-omap2/pmic-cpcap.c
>> index 668dc84fd31e..a7368d657aa8 100644
>> --- a/arch/arm/mach-omap2/pmic-cpcap.c
>> +++ b/arch/arm/mach-omap2/pmic-cpcap.c
>> @@ -238,8 +238,11 @@ static struct omap_voltdm_pmic omap4_fan_iva = {
>> int __init omap4_cpcap_init(void)
>> {
>> struct voltagedomain *voltdm;
>> + struct device_node *np;
>>
>> - if (!of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
>> + np = of_find_compatible_node(NULL, NULL, "motorola,cpcap");
>> + of_node_put(np);
>> + if (!np)
>> return -ENODEV;
>
>Hmm so here you are checking for !np after of_node_put()?
Hi, Tony.
Thanks very much for your effort to review my code.
I just wanted to use this 'check-after-put' coding style to keep consistent with
existing style.
But based on the disccussion with Greg KH, yesterday, I am now preparing 'check-then-put'
coding style patch.
Link:
https://lore.kernel.org/all/1bed06e5.43da.181a5bac7e5.Coremail.windhl@126.com/
>
>> diff --git a/arch/arm/mach-tegra/irq.c b/arch/arm/mach-tegra/irq.c
>> index 4e1ee70b2a3f..2aeac041bcb9 100644
>> --- a/arch/arm/mach-tegra/irq.c
>> +++ b/arch/arm/mach-tegra/irq.c
>> @@ -88,7 +88,11 @@ static const struct of_device_id tegra_ictlr_match[] __initconst = {
>>
>> void __init tegra_init_irq(void)
>> {
>> - if (WARN_ON(!of_find_matching_node(NULL, tegra_ictlr_match)))
>> + struct device_node *np;
>> +
>> + np = of_find_matching_node(NULL, tegra_ictlr_match);
>> + of_node_put(np);
>> + if (WARN_ON(!np))
>> pr_warn("Outdated DT detected, suspend/resume will NOT work\n");
>>
>> tegra114_gic_cpu_pm_registration();
>
>Here too.
>
>Regards,
>
>Tony
Thanks again, Tony.
I will send a new 'check-and-put' patch soon.
Liang
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-06-28 4:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 9:19 [PATCH] arm/mach: Hold reference returned by of_find_xxx APIs Liang He
2022-06-21 9:19 ` Liang He
2022-06-22 8:51 ` Krzysztof Kozlowski
2022-06-22 8:51 ` Krzysztof Kozlowski
2022-06-28 3:59 ` Tony Lindgren
2022-06-28 3:59 ` Tony Lindgren
2022-06-28 4:05 ` Liang He [this message]
2022-06-28 4:05 ` Liang He
2022-06-28 16:16 ` Russell King (Oracle)
2022-06-28 16:16 ` Russell King (Oracle)
2022-06-29 8:37 ` Tony Lindgren
2022-06-29 8:37 ` Tony Lindgren
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=45bb4c11.34fc.181a87c93dd.Coremail.windhl@126.com \
--to=windhl@126.com \
--cc=andre.przywara@arm.com \
--cc=jonathanh@nvidia.com \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@gmail.com \
--cc=tony@atomide.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.