Re: [PATCH v4 1/2] device property: Add scoped fwnode child node iterators

Danilo Krummrich
2025-09-04T08:51:20Z

On Thu Sep 4, 2025 at 9:43 AM CEST, Sakari Ailus wrote:
> Hi Danilo,
>
> On Thu, Sep 04, 2025 at 09:03:44AM +0200, Danilo Krummrich wrote:
>> On Thu Sep 4, 2025 at 7:56 AM CEST, Sakari Ailus wrote:
>> > Hi Danilo,
>> >
>> > On Wed, Sep 03, 2025 at 07:22:29PM +0200, Danilo Krummrich wrote:
>> >> (Cc: Javier)
>> >>
>> >> On Wed Sep 3, 2025 at 3:18 PM CEST, Sakari Ailus wrote:
>> >> > Do we really need the available variant?
>> >> >
>> >> > Please see
>> >> > <URL:https://lore.kernel.org/linux-acpi/Zwj12J5bTNUEnxA0@kekkonen.localdomain/>.
>> >> >
>> >> > I'll post a patch to remove fwnode_get_next_available_child_node(), too.
>> >>
>> >> Either I'm missing something substantial or the link does indeed not provide an
>> >> obvious justification of why you want to send a patch to remove
>> >> fwnode_get_next_available_child_node().
>> >>
>> >> Do you mean to say that all fwnode backends always return true for
>> >> device_is_available() and hence the fwnode API should not make this distinction?
>> >>
>> >> I.e. are you referring to the fact that of_fwnode_get_next_child_node() always
>> >> calls of_get_next_available_child() and swnode has no device_is_available()
>> >> callback and hence is always available? What about ACPI?
>> >
>> > On ACPI there's no such concept on ACPI data nodes so all data nodes are
>> > considered to be available. So effectively the fwnode_*available*() is
>> > always the same as the variant without _available().
>>
>> What about acpi_fwnode_device_is_available()? Is it guaranteed to always
>> evaluate to true?
>
> acpi_fwnode_device_is_available() is different as it works on ACPI device
> nodes having availability information.

Well, it works on both data and device nodes, so considering data nodes only
isn't enough, no?

So, we can't just say fwnode_get_next_available_child_node() and
fwnode_get_next_child_node() can be used interchangeably.

>> If so, to you plan to remove device_is_available() from struct
>> fwnode_operations and fixup all users of fwnode_get_next_available_child_node()
>> and fwnode_for_each_available_child_node() as well?
>
> The device_is_available() callback needs to stay; it has valid uses
> elsewhere.
>
> Technically it is possible that fwnode_*child_node() functions could return
> device nodes that aren't available, but it is unlikely any caller would
> want to enumerate device nodes this way. Even so, I think it'd be the best
> to add an explicit availability check on ACPI side as well so only
> available nodes would be returned.

Fair enough, but that's an entirely different rationale than the one you gave
above. I.e. "all iterators should only ever provide available ones" vs. the
"they're all available anyways" argument above.

(Quote: "So effectively the fwnode_*available*() is always the same as the
variant without _available().")

I see quite some drivers using fwnode_for_each_child_node() without any
availability check. However, they may just rely on implementation details, such
as knowing it's an OF node or ACPI data node, etc.

So, before you remove fwnode_get_next_available_child_node(), do you plan to
change the semantics of the get_next_child_node() callback accordingly,
including adding the availability check on the ACPI side?

How do we ensure there are no existing drivers relying on iterating also
unavailble nodes? Above you say it's unlikely anyone actually wants this, but
are we sure?