[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e006aa3d-3ec1-415f-a8d2-8aee6847a698@linaro.org>
Date: Tue, 20 Aug 2024 11:36:32 +0200
From: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: Ulf Hansson <ulf.hansson@...aro.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>, Anup Patel
<anup@...infault.org>, Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
linux-pm@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org
Subject: Re: [PATCH 2/4] cpuidle: riscv-sbi: Use scoped device node handling
to simplify error paths
On 19/08/2024 18:19, Jonathan Cameron wrote:
> On Mon, 19 Aug 2024 17:13:13 +0100
> Jonathan Cameron <Jonathan.Cameron@...wei.com> wrote:
>
>> On Fri, 16 Aug 2024 17:09:29 +0200
>> Krzysztof Kozlowski <krzysztof.kozlowski@...aro.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@...aro.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
Powered by blists - more mailing lists