[PATCH v5 03/12] dm: core: Add a helper to retrieve devices through graph endpoints

Miquel Raynal miquel.raynal at bootlin.com
Thu Apr 3 09:45:00 CEST 2025


>> +int uclass_get_device_by_endpoint(enum uclass_id class_id, struct udevice *dev,
>> +                                 int port_idx, int ep_idx, struct udevice **devp)
>> +{
>> +       ofnode node_source = dev_ofnode(dev);
>> +       ofnode node_dest = ofnode_graph_get_remote_node(node_source, port_idx, ep_idx);
>
> You may use dev_ofnode(dev) directly instead of node_source if you
> wish, but that is up to you.

I prefer the organization as is it, because it makes it clear what is
the source and what is the dest.

>> +       struct udevice *target = NULL;
>> +       int ret;
>> +
>> +       if (!ofnode_valid(node_dest))
>> +               return -EINVAL;
>> +
>> +       ret = uclass_find_device_by_ofnode(class_id, node_dest, &target);
>
> You can use uclass_get_device_by_ofnode here and avoid using
> uclass_get_device_tail later.

Crap, I forgot I had this one to handle as well, this is an interesting
change. I will send a followup patch.

Thanks,
Miquèl


More information about the U-Boot mailing list