From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7ADEDECAAD5 for ; Sun, 28 Aug 2022 18:34:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 17F3884928; Sun, 28 Aug 2022 20:33:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bFlJHsok"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E3149845BE; Sun, 28 Aug 2022 20:33:24 +0200 (CEST) Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2785783FB0 for ; Sun, 28 Aug 2022 20:33:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x32f.google.com with SMTP id h20-20020a056830165400b00638ac7ddba5so4558455otr.4 for ; Sun, 28 Aug 2022 11:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=TY7MifH/Hjf7It1v2d9Jk4cqH4igOy/eQVR6zkoukno=; b=bFlJHsokzpnZUqd/T6N1EAYvI9+fNF253aRovosB+mSbTdjViklaOPPGhNn1RLBufX RGm2auMWr/ZG6NHXuag9nx+ghlB7tZwwFaA24ta+KCVCld1J092RAC/kP/O5Q+for4EZ 8/NkdHwM9jZA5y2RSRhStHBxU97xF244jgffU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=TY7MifH/Hjf7It1v2d9Jk4cqH4igOy/eQVR6zkoukno=; b=DWBv6gIoKET03aPGd+XYv3EeqwRms7M/HOHx0Z93Y8yzZEd9w6nLH6DIhx4a5gRigO Rbvs/gRpwSel7kxaf8A92sSNVvgMLmYKmBxZE7VGoIWCUW3oibLM3vnGjVn5kDN0mT5Y R8g+scSvwEVlomQ4THogDrkA1O7dXIDrKDpwqSfbXN6r7t8Pf9XBvTys8Ln+6kj/vPmD PZarrurxRmEYJf1c5vyH6N77QHw6EkQ92gsB23Q02kosdb3C7v1yOhNxueGBTnx4l4YJ sCTlfQvVf/z0fpwMXJDa86Thyf3j9XG85yF8AvotBCUDPyDWpXS0TNJs3VP1YUHj+QPl v1OQ== X-Gm-Message-State: ACgBeo2Zh4QwWTOAUM047rznD4Xq+7zbqw9Mz6n04x/W70QdnbEz/Vj7 fNXIwobMKVmiUkl5vLPZuaW1YwYt9ypVEw== X-Google-Smtp-Source: AA6agR7NZ7Tn+Z8zxklv5V9RtD1Nh4ZkTI5R4dMy1R8a5OQUPVDtxJp/iVDby5pzlrd8UdWnK3FkBQ== X-Received: by 2002:a05:6830:2b12:b0:638:9266:56c3 with SMTP id l18-20020a0568302b1200b00638926656c3mr5313309otv.51.1661711596525; Sun, 28 Aug 2022 11:33:16 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id 91-20020a9d0de4000000b006339b36127dsm4299771ots.3.2022.08.28.11.33.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Aug 2022 11:33:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Neil Armstrong , Simon Glass , Alexandru Gagniuc , Andre Przywara , Artem Lapkin , Heinrich Schuchardt , Jan Kiszka , Joe Hershberger , Leo Yu-Chi Liang , Marek Vasut , Michal Simek , Philippe Reynes Subject: [PATCH 8/8] image: Drop some other #ifdefs in image-board.c Date: Sun, 28 Aug 2022 12:32:53 -0600 Message-Id: <20220828183253.822815-9-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog In-Reply-To: <20220828183253.822815-1-sjg@chromium.org> References: <20220828183253.822815-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 --- 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 #include #include +#include #include #include #include @@ -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; /* -- 2.37.2.672.g94769d06f0-goog