[U-Boot] [PATCH PATCH v4 13/15] drivers: board: Add get_fit_loadable()
Simon Glass
sjg at chromium.org
Tue Aug 13 09:34:00 UTC 2019
Hi Jean-Jacques,
On Mon, 5 Aug 2019 at 03:44, Jean-Jacques Hiblot <jjhiblot at ti.com> wrote:
>
> This function will be used by the SPL to get the names of images to load
> from the FIT. This allows to load different images based on runtime HW
> detection.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
> ---
>
> Changes in v4: New
>
> drivers/board/board-uclass.c | 11 +++++++++++
> include/board.h | 35 +++++++++++++++++++++++++++++++++++
> 2 files changed, 46 insertions(+)
>
> diff --git a/drivers/board/board-uclass.c b/drivers/board/board-uclass.c
> index a516ba4962..4af991e176 100644
> --- a/drivers/board/board-uclass.c
> +++ b/drivers/board/board-uclass.c
> @@ -23,6 +23,17 @@ int board_detect(struct udevice *dev)
> return ops->detect(dev);
> }
>
> +const char *board_get_fit_loadable(struct udevice *dev, int index,
> + const char *type)
> +{
> + struct board_ops *ops = board_get_ops(dev);
> +
> + if (!ops->get_fit_loadable)
> + return NULL;
Please make the function return an int error code - here it should be -ENOSYS.
> +
> + return ops->get_fit_loadable(dev, index, type);
> +}
> +
> int board_get_bool(struct udevice *dev, int id, bool *val)
> {
> struct board_ops *ops = board_get_ops(dev);
> diff --git a/include/board.h b/include/board.h
> index 9dc78684f8..0f4f1aadeb 100644
> --- a/include/board.h
> +++ b/include/board.h
> @@ -79,6 +79,24 @@ struct board_ops {
> * Return: 0 if OK, -ve on error.
> */
> int (*get_str)(struct udevice *dev, int id, size_t size, char *val);
> +
> + /**
> + * get_fit_loadable - Get the name of an image to load from FIT
> + * This function can be used to provide the image names based on runtime
> + * detection. A classic use-case would when DTBOs are used to describe
> + * additionnal daughter cards.
> + *
> + * @dev: The board instance to gather the data.
> + * @index: Index of the image. Starts at 0 and gets incremented
> + * after each call to this function.
You mean that the caller should do this? And then stop when it sees
-ENOENT for that index?
> + * @type: The type of image. For example, "fdt" for DTBs
> + *
> + * return: The name of the node describing the image. NULL
> + * indicates that there no more image to get from this
> + * function.
> + */
> + const char *(*get_fit_loadable)(struct udevice *dev, int index,
> + const char *type);
The return value should move to an argument so you can return an error.
-ENOENT - no loadable for this type for the given index
> };
>
> #define board_get_ops(dev) ((struct board_ops *)(dev)->driver->ops)
> @@ -137,3 +155,20 @@ int board_get_str(struct udevice *dev, int id, size_t size, char *val);
> * Return: 0 if OK, -ve on error.
> */
> int board_get(struct udevice **devp);
> +
> +/**
> + * board_get_fit_loadable - Get the name of an image to load from FIT
> + * This function can be used to provide the image names based on runtime
> + * detection. A classic use-case would when DTBOs are used to describe
> + * additionnal daughter cards.
> + *
> + * @dev: The board instance to gather the data.
> + * @index: Index of the image. Starts at 0 and gets incremented
> + * after each call to this function.
> + * @type: The type of image. For example, "fdt" for DTBs
> + *
> + * return: The name of the node describing the image. NULL indicates
> + * that there no more images to get from this function.
> + */
> +const char *board_get_fit_loadable(struct udevice *dev, int index,
> + const char *type);
> --
> 2.17.1
>
Regards,
Simon
More information about the U-Boot
mailing list