[PATCH v5 4/6] misc: fw_loader: implement request_firmware_size() OP

Simon Glass sjg at chromium.org
Mon Apr 6 19:13:35 CEST 2026


Hi Christian,

On 2026-04-03T13:51:57, Christian Marangi <ansuelsmth at gmail.com> wrote:
> misc: fw_loader: implement request_firmware_size() OP
>
> It might be useful to get the firmware size before reading it to allocate
> the correct size. This is needed for case where the firmware size change
> across different firmware version and is not always the same. In such case
> the only way to handle this scenario is to allocate a big-enough buffer to
> read the firmware.
>
> To better handle this, introduce the request_firmware_size() OP to get the
> firmware size before reading it. This way proper buffer can be allocated
> and dynamic firmware size can be better supported.
>
> FS loader is updated to handle the new .get_size() handler.
>
> Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>

> diff --git a/drivers/misc/fw_loader/fs_loader.c b/drivers/misc/fw_loader/fs_loader.c
> @@ -122,6 +115,28 @@ static int fw_get_filesystem_firmware(struct udevice *dev)
> +static int __fw_get_filesystem_firmware_prepare(struct udevice *dev)

Please can you avoid double-underscore prefix for static functions?
Something like fw_fs_prepare() would be cleaner.

> diff --git a/drivers/misc/fw_loader/fs_loader.c b/drivers/misc/fw_loader/fs_loader.c
> @@ -143,9 +158,43 @@ static int fw_get_filesystem_firmware(struct udevice *dev)
> +     firmwarep = dev_get_priv(dev);
> +     if (!firmwarep) {
> +             ret = -ENOMEM;
> +             goto out;
> +     }

This cannot happen, since driver model ensures the priv data exists.

Also how about using 'priv' as the variable name? We normally use a
'p' suffix to indicate a parameter which returns a value.

> diff --git a/drivers/misc/fw_loader/fw_loader.c b/drivers/misc/fw_loader/fw_loader.c
> @@ -174,3 +174,23 @@ int request_firmware_into_buf(struct udevice *dev,
> +int request_firmware_size(struct udevice *dev, const char *name)
> +{

The function needs a kerneldoc comment in the implementation.

Regards,
Simon


More information about the U-Boot mailing list