mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/6] fastboot: don't populate partition variables unconditionally
Date: Mon, 28 Apr 2025 14:52:15 +0200	[thread overview]
Message-ID: <20250428125217.1931365-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250428125217.1931365-1-a.fatoum@pengutronix.de>

If the client asks for max-download-size, there is no need to enumerate
all partitions, so reorder the code accordingly.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/fastboot.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/common/fastboot.c b/common/fastboot.c
index 3155ff2af92c..231f49c1a6c9 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -310,6 +310,16 @@ static void cb_getvar(struct fastboot *fb, const char *cmd)
 {
 	LIST_HEAD(partition_list);
 	struct file_list_entry *fentry;
+	bool all;
+
+	pr_debug("getvar: \"%s\"\n", cmd);
+
+	all = !strcmp(cmd, "all");
+	if (all)
+		cmd = NULL;
+
+	if (fastboot_tx_print_var(fb, &fb->variables, cmd))
+		goto out;
 
 	file_list_for_each_entry(fb->files, fentry) {
 		int ret;
@@ -325,19 +335,6 @@ static void cb_getvar(struct fastboot *fb, const char *cmd)
 		}
 	}
 
-	pr_debug("getvar: \"%s\"\n", cmd);
-
-	if (!strcmp(cmd, "all")) {
-		fastboot_tx_print_var(fb, &fb->variables, NULL);
-		fastboot_tx_print_var(fb, &partition_list, NULL);
-
-		fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, "");
-		goto out;
-	}
-
-	if (fastboot_tx_print_var(fb, &fb->variables, cmd))
-		goto out;
-
 	if (fastboot_tx_print_var(fb, &partition_list, cmd))
 		goto out;
 
-- 
2.39.5




  parent reply	other threads:[~2025-04-28 13:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-28 12:52 [PATCH 0/6] fastboot: fix handling of non-existent partitions Ahmad Fatoum
2025-04-28 12:52 ` [PATCH 1/6] fastboot: terminate request for non-file-backed partition properly Ahmad Fatoum
2025-04-28 12:52 ` [PATCH 2/6] fastboot: introduce fastboot_tx_print_var() helper Ahmad Fatoum
2025-04-28 12:52 ` Ahmad Fatoum [this message]
2025-04-28 12:52 ` [PATCH 4/6] fastboot: only populate variables explicitly asked for Ahmad Fatoum
2025-04-28 12:52 ` [PATCH 5/6] fastboot: factor out fb_file_getsize Ahmad Fatoum
2025-04-28 12:52 ` [PATCH 6/6] fastboot: check for file existence before flashing/erasing Ahmad Fatoum

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=20250428125217.1931365-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox