[PATCH v2 07/19] bootstd: Use the bootargs env var for changing the cmdline

Bin Meng bmeng.cn at gmail.com
Wed Jul 12 13:47:54 CEST 2023


Hi Simon,

On Tue, Jun 20, 2023 at 4:24 PM Simon Glass <sjg at chromium.org> wrote:
>
> The "bootargs" environment variable is used to set the command-line
> arguments to pass to the OS. Use this same mechanism with bootstd as well.
> When the variable is updated, it is written to the current bootflow. When
> the current bootflow is updated, the environment variable is updated too.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> (no changes since v1)
>
>  boot/bootflow.c        | 59 ++++++++++++++++++++++++++++++++++++++++++
>  cmd/bootflow.c         |  6 +++++
>  include/env_callback.h |  6 +++--
>  3 files changed, 69 insertions(+), 2 deletions(-)
>
> diff --git a/boot/bootflow.c b/boot/bootflow.c
> index 487552fa28c0..62b7f45ab278 100644
> --- a/boot/bootflow.c
> +++ b/boot/bootflow.c
> @@ -12,6 +12,7 @@
>  #include <bootmeth.h>
>  #include <bootstd.h>
>  #include <dm.h>
> +#include <env_internal.h>
>  #include <malloc.h>
>  #include <dm/device-internal.h>
>  #include <dm/uclass-internal.h>
> @@ -552,3 +553,61 @@ int bootflow_iter_check_system(const struct bootflow_iter *iter)
>
>         return -ENOTSUPP;
>  }
> +
> +/**
> + * bootflow_cmdline_set() - Set the command line for a bootflow
> + *
> + * @value: New command-line string
> + * Returns 0 if OK, -ENOENT if no current bootflow, -ENOMEM if out of memory
> + */
> +int bootflow_cmdline_set(struct bootflow *bflow, const char *value)
> +{
> +       char *cmdline = NULL;
> +
> +       if (value) {
> +               cmdline = strdup(value);
> +               if (!cmdline)
> +                       return -ENOMEM;
> +       }
> +
> +       free(bflow->cmdline);

v1 comment was not addressed. But I assume bflow->cmdline is zero for
the very first time so there will be no issue.

> +       bflow->cmdline = cmdline;
> +
> +       return 0;
> +}

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>

Regards,
Bin


More information about the U-Boot mailing list