Re: [RFC PATCH 2/6] of: reserved-memory: Add of_reserved_mem_lookup_by_name

From: Krzysztof Kozlowski
Date: Wed Jul 30 2025 - 07:24:16 EST


On 30/07/2025 12:57, Viresh Kumar wrote:
> On 30-07-25, 11:46, Krzysztof Kozlowski wrote:
>> On 30/07/2025 11:29, Viresh Kumar wrote:
>>> + struct device_node *child __free(device_node) = NULL;
>>
>> This should not be NULL or this should not be cleanup. Follow coding
>> style for cleanup - constructor must be real here.
>
> I may have misunderstood how cleanup works, but this is what I
> thought:
>
> The cleanup is defined in of.h as:
>
> DEFINE_FREE(device_node, struct device_node *, if (_T) of_node_put(_T))
>
>
> Doesn't this mean that it handles the case where `child` is NULL, by
> not calling of_node_put() ? So it should either be a valid constructor
> or NULL and not some stale value.

I am speaking about coding style. It's explicitly requested to use only
the full constructor syntax (see long time Linus' remark or just read
cleanup.h docs).

NULL is allowed in certain cases, but the code here does not look like
needing it in the first place.


Best regards,
Krzysztof