From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
Heiko Stuebner <heiko@sntech.de>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-msm@vger.kernel.org,
linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 09/10] pmdomain: renesas: rcar-gen4-sysc: Use scoped device node handling to simplify error paths
Date: Tue, 27 Aug 2024 11:39:30 +0200 [thread overview]
Message-ID: <58f5d332-2f2a-4607-9662-e71fd23b1316@linaro.org> (raw)
In-Reply-To: <a48f1a0b-0e20-4782-bf6b-c430da9ae391@linaro.org>
On 27/08/2024 11:33, Krzysztof Kozlowski wrote:
> On 27/08/2024 09:48, Geert Uytterhoeven wrote:
>> Hi Krzysztof,
>>
>> On Fri, Aug 23, 2024 at 2:51 PM Krzysztof Kozlowski
>> <krzysztof.kozlowski@linaro.org> wrote:
>>> Obtain the device node reference with scoped/cleanup.h to reduce error
>>> handling and make the code a bit simpler.
>>>
>>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>>
>> Thanks for your patch!
>>
>>> --- a/drivers/pmdomain/renesas/rcar-gen4-sysc.c
>>> +++ b/drivers/pmdomain/renesas/rcar-gen4-sysc.c
>>> @@ -303,12 +304,12 @@ static int __init rcar_gen4_sysc_pd_init(void)
>>> const struct rcar_gen4_sysc_info *info;
>>> const struct of_device_id *match;
>>> struct rcar_gen4_pm_domains *domains;
>>> - struct device_node *np;
>>> void __iomem *base;
>>> unsigned int i;
>>> int error;
>>>
>>> - np = of_find_matching_node_and_match(NULL, rcar_gen4_sysc_matches, &match);
>>> + struct device_node *np __free(device_node) =
>>> + of_find_matching_node_and_match(NULL, rcar_gen4_sysc_matches, &match);
>>
>> This breaks the declarations/blank-line/code structure, so please move
>> this up.
>
> What do you mean "declaration structure"? That's the way how variables
> with constructors are expected to be declared - within the code.
Continuing thoughts, so you prefer:
struct rcar_gen4_pm_domains *domains;
void __iomem *base;
struct device_node *np __free(device_node) =
of_find_matching_node_and_match(NULL, rcar_gen4_sysc_matches, &match);
(assuming I will put it at the end of declarations).
Are you sure this is more readable? It's really long line so it
obfuscates a bit the declarations. The point of the scoped assignment is that
you declare it at point of need/first use.
>
>>
>> If you insist on keeping assignment to and validation of np together,
>> the line should be split in declaration and assignment.
>
> No, that would be inconsistent with cleanup/constructor coding style.
> Maybe this is something new, so let me bring previous discussions:
>
> https://lore.kernel.org/all/CAHk-=wicfvWPuRVDG5R1mZSxD8Xg=-0nLOiHay2T_UJ0yDX42g@mail.gmail.com/
>
> https://lore.kernel.org/all/CAHk-=wgRHiV5VSxtfXA4S6aLUmcQYEuB67u3BJPJPtuESs1JyA@mail.gmail.com/
>
> https://lore.kernel.org/all/CAHk-=whvOGL3aNhtps0YksGtzvaob_bvZpbaTcVEqGwNMxB6xg@mail.gmail.com/
>
> and finally it will reach documentation (although it focuses on
> unwinding process to be specific - "When the unwind order ..."):
> https://lore.kernel.org/all/171175585714.2192972.12661675876300167762.stgit@dwillia2-xfh.jf.intel.com/
>
>>
>>> if (!np)
>>> return -ENODEV;
>>>
>>
>>> @@ -369,14 +365,12 @@ static int __init rcar_gen4_sysc_pd_init(void)
>>> if (error) {
>>> pr_warn("Failed to add PM subdomain %s to parent %u\n",
>>> area->name, area->parent);
>>> - goto out_put;
>>> + return error;
>>> }
>>> }
>>>
>>> error = of_genpd_add_provider_onecell(np, &domains->onecell_data);
>>>
>>> -out_put:
>>> - of_node_put(np);
>>> return error;
>>
>> return of_genpd_add_provider_onecell(...);
>
> Ack.
>
> Best regards,
> Krzysztof
>
Best regards,
Krzysztof
next prev parent reply other threads:[~2024-08-27 9:39 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 12:51 [PATCH 00/10] pmdomain: Simplify with cleanup.h Krzysztof Kozlowski
2024-08-23 12:51 ` [PATCH 01/10] pmdomain: rockchip: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2024-08-27 9:53 ` Jonathan Cameron
2024-08-23 12:51 ` [PATCH 02/10] pmdomain: rockchip: Simplify locking with guard() Krzysztof Kozlowski
2024-08-27 9:59 ` Jonathan Cameron
2024-08-27 10:30 ` Krzysztof Kozlowski
2024-08-23 12:51 ` [PATCH 03/10] pmdomain: imx: gpc: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2024-08-23 12:51 ` [PATCH 04/10] pmdomain: imx: gpcv2: " Krzysztof Kozlowski
2024-08-23 12:51 ` [PATCH 05/10] pmdomain: qcom: cpr: Simplify with dev_err_probe() Krzysztof Kozlowski
2024-08-27 9:45 ` Konrad Dybcio
2024-08-23 12:51 ` [PATCH 06/10] pmdomain: qcom: cpr: Simplify locking with guard() Krzysztof Kozlowski
2024-08-27 9:47 ` Konrad Dybcio
2024-08-23 12:51 ` [PATCH 07/10] pmdomain: qcom: rpmhpd: " Krzysztof Kozlowski
2024-08-27 9:48 ` Konrad Dybcio
2024-08-23 12:51 ` [PATCH 08/10] pmdomain: qcom: rpmpd: " Krzysztof Kozlowski
2024-08-27 9:49 ` Konrad Dybcio
2024-08-23 12:51 ` [PATCH 09/10] pmdomain: renesas: rcar-gen4-sysc: Use scoped device node handling to simplify error paths Krzysztof Kozlowski
2024-08-27 7:48 ` Geert Uytterhoeven
2024-08-27 9:33 ` Krzysztof Kozlowski
2024-08-27 9:39 ` Krzysztof Kozlowski [this message]
2024-08-27 10:55 ` Geert Uytterhoeven
2024-08-27 11:12 ` Krzysztof Kozlowski
2024-11-27 13:14 ` Geert Uytterhoeven
2024-08-23 12:51 ` [PATCH 10/10] pmdomain: renesas: rcar-sysc: " Krzysztof Kozlowski
2024-08-27 7:55 ` Geert Uytterhoeven
2024-09-13 12:01 ` [PATCH 00/10] pmdomain: Simplify with cleanup.h Ulf Hansson
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=58f5d332-2f2a-4607-9662-e71fd23b1316@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=andersson@kernel.org \
--cc=festevam@gmail.com \
--cc=geert+renesas@glider.be \
--cc=geert@linux-m68k.org \
--cc=heiko@sntech.de \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=konradybcio@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=magnus.damm@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=ulf.hansson@linaro.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