[PATCH v6 3/6] misc: fw_loader: implement generic get_fw_loader_from_node()

Simon Glass sjg at chromium.org
Sat Apr 11 16:56:42 CEST 2026


Hi Christian,

On 2026-04-09T13:32:56, Christian Marangi <ansuelsmth at gmail.com> wrote:
> misc: fw_loader: implement generic get_fw_loader_from_node()
>
> Implement a generic function to get a FW loader dev from a node.
>
> There is currently only get_fs_loader() but that is limited to chosen
> node and is limited only to FS loader.
>
> Introduce get_fw_loader_from_node() that will parse the
> "firmware-loader" from a specified node and will search and probe a
> matching FW loader device, if found.
>
> Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
>
> drivers/misc/fw_loader/fw_loader-uclass.c | 23 +++++++++++++++++++++++
>  include/fw_loader.h                       | 14 ++++++++++++++
>  2 files changed, 37 insertions(+)

> diff --git a/drivers/misc/fw_loader/fw_loader-uclass.c b/drivers/misc/fw_loader/fw_loader-uclass.c
> @@ -96,6 +98,27 @@ UCLASS_DRIVER(fw_loader) = {
> +int get_fw_loader_from_node(ofnode node, struct udevice **dev)
> +{
> +     struct udevice *fw_dev;
> +     int ret;
> +
> +     node = ofnode_parse_phandle(node, "firmware-loader", 0);
> +     if (!ofnode_valid(node))
> +             return -ENODEV;
> +
> +     ret = device_find_global_by_ofnode(node, &fw_dev);
> +     if (ret)
> +             return ret;
> +
> +     ret = device_probe(fw_dev);

Using device_find_global_by_ofnode() followed by device_probe() does
not verify that the device belongs to UCLASS_FIRMWARE_LOADER. If the
device tree contains an erroneous phandle pointing to some other
device type, this function would happily return it.

Please can you use uclass_get_device_by_ofnode(UCLASS_FIRMWARE_LOADER,
node, dev) instead? That is the standard pattern for obtaining a
device by ofnode within a specific uclass. See get_fs_loader() for an
example.

Regards,
Simon


More information about the U-Boot mailing list