All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Alexandru Gagniuc <mr.nuke.me@gmail.com>,
	Andre Przywara <andre.przywara@arm.com>,
	Artem Lapkin <email2tema@gmail.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Joe Hershberger <joe.hershberger@ni.com>,
	Leo Yu-Chi Liang <ycliang@andestech.com>,
	Marek Vasut <marex@denx.de>, Michal Simek <michal.simek@amd.com>,
	Philippe Reynes <philippe.reynes@softathome.com>,
	U-Boot Mailing List <u-boot@lists.denx.de>
Subject: Re: [PATCH 8/8] image: Drop some other #ifdefs in image-board.c
Date: Wed, 14 Sep 2022 18:22:47 +0200	[thread overview]
Message-ID: <1cdc5b12-597b-1a7d-0708-81b23e0cc6dd@gmx.de> (raw)
In-Reply-To: <20220828183253.822815-9-sjg@chromium.org>

On 8/28/22 20:32, Simon Glass wrote:
> Remove all but a few that are difficult, relying on legacy CONFIG options
> or optional global_data fields.
>
> Drop the duplicate function name in the comment for boot_get_cmdline().
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   boot/image-board.c | 67 +++++++++++++++++++++++++---------------------
>   include/image.h    |  6 +++++
>   2 files changed, 42 insertions(+), 31 deletions(-)
>
> diff --git a/boot/image-board.c b/boot/image-board.c
> index 7a17ffb7f7f..1be0a359aba 100644
> --- a/boot/image-board.c
> +++ b/boot/image-board.c
> @@ -16,6 +16,7 @@
>   #include <fpga.h>
>   #include <image.h>
>   #include <init.h>
> +#include <log.h>

This looks like an unrelated change.

Best regards

Heinrich

>   #include <mapmem.h>
>   #include <rtc.h>
>   #include <watchdog.h>
> @@ -172,29 +173,29 @@ void memmove_wd(void *to, void *from, size_t len, ulong chunksz)
>   	if (to == from)
>   		return;
>
> -#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
> -	if (to > from) {
> -		from += len;
> -		to += len;
> -	}
> -	while (len > 0) {
> -		size_t tail = (len > chunksz) ? chunksz : len;
> -
> -		WATCHDOG_RESET();
> +	if (IS_ENABLED(CONFIG_HW_WATCHDOG) || IS_ENABLED(CONFIG_WATCHDOG)) {
>   		if (to > from) {
> -			to -= tail;
> -			from -= tail;
> +			from += len;
> +			to += len;
>   		}
> -		memmove(to, from, tail);
> -		if (to < from) {
> -			to += tail;
> -			from += tail;
> +		while (len > 0) {
> +			size_t tail = (len > chunksz) ? chunksz : len;
> +
> +			WATCHDOG_RESET();
> +			if (to > from) {
> +				to -= tail;
> +				from -= tail;
> +			}
> +			memmove(to, from, tail);
> +			if (to < from) {
> +				to += tail;
> +				from += tail;
> +			}
> +			len -= tail;
>   		}
> -		len -= tail;
> +	} else {
> +		memmove(to, from, len);
>   	}
> -#else	/* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
> -	memmove(to, from, len);
> -#endif	/* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
>   }
>
>   /**
> @@ -551,7 +552,6 @@ int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images,
>   	return 0;
>   }
>
> -#if defined(CONFIG_LMB)
>   /**
>    * boot_ramdisk_high - relocate init ramdisk
>    * @lmb: pointer to lmb handle, will be used for memory mgmt
> @@ -645,7 +645,6 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
>   error:
>   	return -1;
>   }
> -#endif
>
>   int boot_get_setup(bootm_headers_t *images, u8 arch,
>   		   ulong *setup_start, ulong *setup_len)
> @@ -839,15 +838,13 @@ int boot_get_loadable(int argc, char *const argv[], bootm_headers_t *images,
>   	return 0;
>   }
>
> -#if defined(CONFIG_LMB)
> -#ifdef CONFIG_SYS_BOOT_GET_CMDLINE
>   /**
>    * boot_get_cmdline - allocate and initialize kernel cmdline
>    * @lmb: pointer to lmb handle, will be used for memory mgmt
>    * @cmd_start: pointer to a ulong variable, will hold cmdline start
>    * @cmd_end: pointer to a ulong variable, will hold cmdline end
>    *
> - * boot_get_cmdline() allocates space for kernel command line below
> + * This allocates space for kernel command line below
>    * BOOTMAPSZ + env_get_bootm_low() address. If "bootargs" U-Boot environment
>    * variable is present its contents is copied to allocated kernel
>    * command line.
> @@ -858,10 +855,19 @@ int boot_get_loadable(int argc, char *const argv[], bootm_headers_t *images,
>    */
>   int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end)
>   {
> +	int barg;
>   	char *cmdline;
>   	char *s;
>
> -	cmdline = (char *)(ulong)lmb_alloc_base(lmb, CONFIG_SYS_BARGSIZE, 0xf,
> +	/*
> +	 * Help the compiler detect that this function is only called when
> +	 * CONFIG_SYS_BOOT_GET_CMDLINE is enabled
> +	 */
> +	if (!IS_ENABLED(CONFIG_SYS_BOOT_GET_CMDLINE))
> +		return 0;
> +
> +	barg = IF_ENABLED_INT(CONFIG_SYS_BOOT_GET_CMDLINE, CONFIG_SYS_BARGSIZE);
> +	cmdline = (char *)(ulong)lmb_alloc_base(lmb, barg, 0xf,
>   				env_get_bootm_mapsize() + env_get_bootm_low());
>   	if (!cmdline)
>   		return -1;
> @@ -907,22 +913,22 @@ int boot_get_kbd(struct lmb *lmb, struct bd_info **kbd)
>
>   	debug("## kernel board info at 0x%08lx\n", (ulong)*kbd);
>
> -#if defined(DEBUG)
> -	if (IS_ENABLED(CONFIG_CMD_BDI))
> +	if (_DEBUG && IS_ENABLED(CONFIG_CMD_BDI))
>   		do_bdinfo(NULL, 0, 0, NULL);
> -#endif
>
>   	return 0;
>   }
> -#endif
>
>   int image_setup_linux(bootm_headers_t *images)
>   {
>   	ulong of_size = images->ft_len;
>   	char **of_flat_tree = &images->ft_addr;
> -	struct lmb *lmb = &images->lmb;
> +	struct lmb *lmb = images_lmb(images);
>   	int ret;
>
> +	/* This function cannot be called without lmb support */
> +	if (!CONFIG_IS_ENABLED(LMB))
> +		return -EFAULT;
>   	if (CONFIG_IS_ENABLED(OF_LIBFDT))
>   		boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree);
>
> @@ -949,7 +955,6 @@ int image_setup_linux(bootm_headers_t *images)
>
>   	return 0;
>   }
> -#endif
>
>   void genimg_print_size(uint32_t size)
>   {
> diff --git a/include/image.h b/include/image.h
> index e4c6a50b885..a148073113a 100644
> --- a/include/image.h
> +++ b/include/image.h
> @@ -360,6 +360,12 @@ typedef struct bootm_headers {
>   #endif
>   } bootm_headers_t;
>
> +#ifdef CONFIG_LMB
> +#define images_lmb(_images)	(&(_images)->lmb)
> +#else
> +#define images_lmb(_images)	NULL
> +#endif
> +
>   extern bootm_headers_t images;
>
>   /*


  reply	other threads:[~2022-09-14 16:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-28 18:32 [PATCH 0/8] image: Refactor ramdisk code to avoid #ifdef Simon Glass
2022-08-28 18:32 ` [PATCH 1/8] image: Fix up ANDROID_BOOT_IMAGE ramdisk code Simon Glass
2022-08-28 18:32 ` [PATCH 2/8] image: Track when ramdisk processing is completed Simon Glass
2022-08-28 18:32 ` [PATCH 3/8] image: Drop #ifdefs for LEGACY_IMAGE_FORMAT Simon Glass
2022-08-28 18:32 ` [PATCH 4/8] image: Drop one #ifdef for FIT Simon Glass
2022-08-28 18:32 ` [PATCH 5/8] image: Drop another " Simon Glass
2022-08-28 18:32 ` [PATCH 6/8] image: Drop remaining FIT #ifdef Simon Glass
2022-08-28 18:32 ` [PATCH 7/8] image: Correct indentation in select_ramdisk() Simon Glass
2022-08-28 18:32 ` [PATCH 8/8] image: Drop some other #ifdefs in image-board.c Simon Glass
2022-09-14 16:22   ` Heinrich Schuchardt [this message]
2022-09-14 17:10     ` Simon Glass
2022-09-14 15:53 ` [PATCH 0/8] image: Refactor ramdisk code to avoid #ifdef Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1cdc5b12-597b-1a7d-0708-81b23e0cc6dd@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=andre.przywara@arm.com \
    --cc=email2tema@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=joe.hershberger@ni.com \
    --cc=marex@denx.de \
    --cc=michal.simek@amd.com \
    --cc=mr.nuke.me@gmail.com \
    --cc=narmstrong@baylibre.com \
    --cc=philippe.reynes@softathome.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=ycliang@andestech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.