From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Anup Patel <anup@brainfault.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: Re: [PATCH 2/4] cpuidle: riscv-sbi: Use scoped device node handling to simplify error paths
Date: Tue, 20 Aug 2024 11:36:32 +0200 [thread overview]
Message-ID: <e006aa3d-3ec1-415f-a8d2-8aee6847a698@linaro.org> (raw)
In-Reply-To: <20240819171954.0000600d@Huawei.com>
On 19/08/2024 18:19, Jonathan Cameron wrote:
> On Mon, 19 Aug 2024 17:13:13 +0100
> Jonathan Cameron <Jonathan.Cameron@Huawei.com> wrote:
>
>> On Fri, 16 Aug 2024 17:09:29 +0200
>> 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>
>> The original code looks suspect. See below.
>
> Whilst here... Why not do similar for state_node to avoid
> the delayed return check.
> Existing code
> {
> state_node = of_get_cpu_state_node(cpu_node, i - 1);
> if (!state_node)
> break;
I don't see how __free() helps here. You can return regardless of __free().
>
> ret = sbi_dt_parse_state_node(state_node, &states[i]);
> of_node_put(state_node);
... and this code is quite easy to read: you get reference and
immediately release it.
>
> if (ret)
> //another bug here on holding cpu_node btw.
> return ret;
> pr_debug("sbi-state %#x index %d\n", states[i], i);
> }
> //I think only path to this is is early break above.
> if (i != state_count) {
> ret = -ENODEV;
> goto fail;
> }
> Can be something like
>
> {
> struct device_node *state_node __free(device_node) =
> = of_get-cpu_State_nod(cpu_node, i - 1);
>
> if (!state_node)
> return -ENODEV;
>
> ret = sbi_dt_parse_state_node(state_node, &states[i]);
> if (ret)
> return ret;
>
> pr_debug("sbi-state %#x index %d\n", states[i], i);
> }
>
Maybe I miss something, but I do not see how the __free() simplifies
here anything.
Best regards,
Krzysztof
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2024-08-20 9:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-16 15:09 [PATCH 1/4] cpuidle: psci: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2024-08-16 15:09 ` [PATCH 2/4] cpuidle: riscv-sbi: Use scoped device node handling to simplify error paths Krzysztof Kozlowski
2024-08-19 16:13 ` Jonathan Cameron
2024-08-19 16:19 ` Jonathan Cameron
2024-08-20 9:36 ` Krzysztof Kozlowski [this message]
2024-08-21 11:48 ` Jonathan Cameron
2024-08-20 9:29 ` Krzysztof Kozlowski
2024-08-16 15:09 ` [PATCH 3/4] cpuidle: riscv-sbi: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2024-08-19 16:24 ` Jonathan Cameron
2024-08-16 15:09 ` [PATCH 4/4] cpuidle: dt_idle_genpd: " Krzysztof Kozlowski
2024-08-19 16:26 ` Jonathan Cameron
2024-08-20 9:34 ` Ulf Hansson
2024-08-19 16:11 ` [PATCH 1/4] cpuidle: psci: " Jonathan Cameron
2024-08-20 9:33 ` 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=e006aa3d-3ec1-415f-a8d2-8aee6847a698@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=Jonathan.Cameron@Huawei.com \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=daniel.lezcano@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=rafael@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