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 27910C4167B for ; Mon, 4 Dec 2023 00:30:37 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A0548786E; Mon, 4 Dec 2023 01:28:08 +0100 (CET) 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="I4Gafsn6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E90218786E; Mon, 4 Dec 2023 01:28:07 +0100 (CET) Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) (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 CA3808787E for ; Mon, 4 Dec 2023 01:28:03 +0100 (CET) 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-pl1-x62b.google.com with SMTP id d9443c01a7336-1cf7a8ab047so10339595ad.1 for ; Sun, 03 Dec 2023 16:28:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701649682; x=1702254482; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eK35CQalW7MnpKH6mPPnTIV7JJHS3ueLB43Cx4cqA28=; b=I4Gafsn68eFViaqviYFWsNbtOLbNS8zjx09HXdI0G+WE/PX0JWEaA5+SbIrJGG8APc IfiPJGAw4m4/wiI9T+SI43aCuCBizLRc5azTNTpInKSDGp6HvIzeN3v/y0Xw7NP7/gdM Dv0LDeyTIheZSO4ohEo2fl1mTXpzm18qKGPoc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701649682; x=1702254482; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eK35CQalW7MnpKH6mPPnTIV7JJHS3ueLB43Cx4cqA28=; b=pnY6wnHxAPzJnxEx3lkrIPMCI92H/tNowJ85woRANVX2GMwRcDe/ZgVe1jR8APYtwh OMYonB3g9bUXkqr8llug7tbxsCrjIz3dqRUvyh0hBLRwx8DHfyr0g6iDS3N3qBmbWkeW qL5EPnfgcGRFSfNVQ70OB0oq+gXnRDydglkxLpiuobbWxYHj034L+fZnxDWmlpE4BnaS 2HOLFAxu5PGg2d2/SdeAE7kpEgop2bpjtBbG92Q9WaXPizgXB+lFsQHH0+QjEQ82NRwn drxdfHSG2dJIqgFNCAYUXrRuRtPK5IgPIASRCJLHKvbrOY062wQtxszs5G9LVaKwsnLy WuBQ== X-Gm-Message-State: AOJu0Yy03wtMW2AjTU1GqnCrMr3f7z/8fcQ54qSygTXhHP/fPZQ6eeRI 624bTstcHlAhOpjvlaRH8NTgGiCfPgaPr7UV5CwfAQ== X-Google-Smtp-Source: AGHT+IG7xy5xCf5TDpw3+AAPTbsWLsDcfncZlh8LyR0uteGHLEcDe3++KBg7xk8fVM4JraLM2pohdA== X-Received: by 2002:a17:903:2308:b0:1ce:6312:5373 with SMTP id d8-20020a170903230800b001ce63125373mr837085plh.0.1701649682145; Sun, 03 Dec 2023 16:28:02 -0800 (PST) Received: from sjg1.roam.corp.google.com ([202.144.206.254]) by smtp.gmail.com with ESMTPSA id w5-20020a170902904500b001cfb971edfasm7097227plz.205.2023.12.03.16.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 16:28:01 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Patrice Chotard , Patrick Delaunay , Sean Anderson , uboot-stm32@st-md-mailman.stormreply.com Subject: [PATCH 15/18] stm32: Use local vars in stm32prog for initrd and fdt Date: Sun, 3 Dec 2023 17:26:31 -0700 Message-ID: <20231204002642.895926-9-sjg@chromium.org> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog In-Reply-To: <20231204002642.895926-1-sjg@chromium.org> References: <20231204002642.895926-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.8 at phobos.denx.de X-Virus-Status: Clean Rather than assigning to the bootm_argv[] array multiple times, use local variables for the two things that can change and assign them at the end. This makes it easier to drop the array eventually. Tidu up an overly short line while we are here. Signed-off-by: Simon Glass --- .../cmd_stm32prog/cmd_stm32prog.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c index 2411bcf06d8f..8670535844d3 100644 --- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c @@ -124,30 +124,35 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc, char boot_addr_start[20]; char dtb_addr[20]; char initrd_addr[40]; + char *fdt_arg, *initrd_arg; char *bootm_argv[5] = { - "bootm", boot_addr_start, "-", dtb_addr, NULL + "bootm", boot_addr_start, }; const void *uimage = (void *)data->uimage; const void *dtb = (void *)data->dtb; const void *initrd = (void *)data->initrd; + fdt_arg = dtb_addr; if (!dtb) - bootm_argv[3] = env_get("fdtcontroladdr"); + fdt_arg = env_get("fdtcontroladdr"); else - snprintf(dtb_addr, sizeof(dtb_addr) - 1, - "0x%p", dtb); + snprintf(dtb_addr, sizeof(dtb_addr) - 1, "0x%p", dtb); snprintf(boot_addr_start, sizeof(boot_addr_start) - 1, "0x%p", uimage); + initrd_arg = "-"; if (initrd) { - snprintf(initrd_addr, sizeof(initrd_addr) - 1, "0x%p:0x%zx", - initrd, data->initrd_size); - bootm_argv[2] = initrd_addr; + snprintf(initrd_addr, sizeof(initrd_addr) - 1, + "0x%p:0x%zx", initrd, data->initrd_size); + initrd_arg = initrd_addr; } - printf("Booting kernel at %s %s %s...\n\n\n", - boot_addr_start, bootm_argv[2], bootm_argv[3]); + printf("Booting kernel at %s %s %s...\n\n\n", boot_addr_start, + initrd_arg, fdt_arg); + bootm_argv[2] = initrd_arg; + bootm_argv[3] = fdt_arg; + /* Try bootm for legacy and FIT format image */ if (genimg_get_format(uimage) != IMAGE_FORMAT_INVALID) do_bootm(cmdtp, 0, 4, bootm_argv); -- 2.43.0.rc2.451.g8631bc7472-goog