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

Simon Glass sjg at chromium.org
Sat Apr 11 16:57:05 CEST 2026


Hi Christian,

On 2026-04-09T13:32:56, 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>
>
> drivers/misc/fw_loader/fs_loader.c        | 68 +++++++++++++++++++++++++------
>  drivers/misc/fw_loader/fw_loader-uclass.c | 19 +++++++++
>  drivers/misc/fw_loader/internal.h         |  7 ++++
>  include/fw_loader.h                       |  9 ++++
>  4 files changed, 91 insertions(+), 12 deletions(-)

The 'int' thing I mentioned in the last version is not that important,
so this is fine.

> diff --git a/drivers/misc/fw_loader/internal.h b/drivers/misc/fw_loader/internal.h
> @@ -32,6 +32,13 @@ struct fw_loader_ops {
> +     /**
> +      * get_size() - get firmware size from Firmware Loader driver
> +      *
> +      * @dev:        Firmware Loader device to get firmware size from
> +      */
> +     int (*get_size)(struct udevice *dev);

The kerneldoc is missing the Return: line documenting the return value
(size of firmware or negative errno).

Regards,
Simon


More information about the U-Boot mailing list