All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
	Caleb Connolly <caleb.connolly@linaro.org>,
	Dragan Simic <dsimic@manjaro.org>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Nam Cao <namcao@linutronix.de>,
	Peter Robinson <pbrobinson@gmail.com>,
	Tony Dinh <mibodhi@gmail.com>
Subject: [PATCH 10/34] bootstd: Move bootflow-adding to bootstd
Date: Thu, 17 Oct 2024 17:23:49 -0600	[thread overview]
Message-ID: <20241017232413.724808-11-sjg@chromium.org> (raw)
In-Reply-To: <20241017232413.724808-1-sjg@chromium.org>

This relates to more than just the bootdev, since there is a global list
of bootflows. Move the function to the bootstd file and rename it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 boot/bootdev-uclass.c | 25 -------------------------
 boot/bootstd-uclass.c | 25 +++++++++++++++++++++++++
 cmd/bootflow.c        |  2 +-
 include/bootdev.h     | 15 ---------------
 include/bootstd.h     | 17 +++++++++++++++++
 5 files changed, 43 insertions(+), 41 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 807f8dfb064..f40bf0a6979 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -32,31 +32,6 @@ enum {
 	BOOT_TARGETS_MAX_LEN	= 100,
 };
 
-int bootdev_add_bootflow(struct bootflow *bflow)
-{
-	struct bootstd_priv *std;
-	struct bootflow *new;
-	int ret;
-
-	ret = bootstd_get_priv(&std);
-	if (ret)
-		return ret;
-
-	new = malloc(sizeof(*bflow));
-	if (!new)
-		return log_msg_ret("bflow", -ENOMEM);
-	memcpy(new, bflow, sizeof(*bflow));
-
-	list_add_tail(&new->glob_node, &std->glob_head);
-	if (bflow->dev) {
-		struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev);
-
-		list_add_tail(&new->bm_node, &ucp->bootflow_head);
-	}
-
-	return 0;
-}
-
 int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp)
 {
 	struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c
index fdb8d69e320..bf6e49ad97a 100644
--- a/boot/bootstd-uclass.c
+++ b/boot/bootstd-uclass.c
@@ -61,6 +61,31 @@ void bootstd_clear_glob(void)
 	bootstd_clear_glob_(std);
 }
 
+int bootstd_add_bootflow(struct bootflow *bflow)
+{
+	struct bootstd_priv *std;
+	struct bootflow *new;
+	int ret;
+
+	ret = bootstd_get_priv(&std);
+	if (ret)
+		return ret;
+
+	new = malloc(sizeof(*bflow));
+	if (!new)
+		return log_msg_ret("bflow", -ENOMEM);
+	memcpy(new, bflow, sizeof(*bflow));
+
+	list_add_tail(&new->glob_node, &std->glob_head);
+	if (bflow->dev) {
+		struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev);
+
+		list_add_tail(&new->bm_node, &ucp->bootflow_head);
+	}
+
+	return 0;
+}
+
 static int bootstd_remove(struct udevice *dev)
 {
 	struct bootstd_priv *priv = dev_get_priv(dev);
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 1588f277a4a..ff06ac3eb9f 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -207,7 +207,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc,
 		bflow.err = ret;
 		if (!ret)
 			num_valid++;
-		ret = bootdev_add_bootflow(&bflow);
+		ret = bootstd_add_bootflow(&bflow);
 		if (ret) {
 			printf("Out of memory\n");
 			return CMD_RET_FAILURE;
diff --git a/include/bootdev.h b/include/bootdev.h
index ad4af0d1310..8db198dd56b 100644
--- a/include/bootdev.h
+++ b/include/bootdev.h
@@ -195,21 +195,6 @@ void bootdev_list(bool probe);
  */
 void bootdev_clear_bootflows(struct udevice *dev);
 
-/**
- * bootdev_add_bootflow() - Add a bootflow to the bootdev's list
- *
- * All fields in @bflow must be set up. Note that @bflow->dev is used to add the
- * bootflow to that device.
- *
- * @dev: Bootdev device to add to
- * @bflow: Bootflow to add. Note that fields within bflow must be allocated
- *	since this function takes over ownership of these. This functions makes
- *	a copy of @bflow itself (without allocating its fields again), so the
- *	caller must dispose of the memory used by the @bflow pointer itself
- * Return: 0 if OK, -ENOMEM if out of memory
- */
-int bootdev_add_bootflow(struct bootflow *bflow);
-
 /**
  * bootdev_first_bootflow() - Get the first bootflow from a bootdev
  *
diff --git a/include/bootstd.h b/include/bootstd.h
index ac756e98d84..3fc93a4ec2e 100644
--- a/include/bootstd.h
+++ b/include/bootstd.h
@@ -105,4 +105,21 @@ void bootstd_clear_glob(void);
  */
 int bootstd_prog_boot(void);
 
+/**
+ * bootstd_add_bootflow() - Add a bootflow to the bootdev's and global list
+ *
+ * All fields in @bflow must be set up. Note that @bflow->dev is used to add the
+ * bootflow to that device.
+ *
+ * The bootflow is also added to the global list of all bootflows
+ *
+ * @dev: Bootdev device to add to
+ * @bflow: Bootflow to add. Note that fields within bflow must be allocated
+ *	since this function takes over ownership of these. This functions makes
+ *	a copy of @bflow itself (without allocating its fields again), so the
+ *	caller must dispose of the memory used by the @bflow pointer itself
+ * Return: 0 if OK, -ENOMEM if out of memory
+ */
+int bootstd_add_bootflow(struct bootflow *bflow);
+
 #endif
-- 
2.34.1


  parent reply	other threads:[~2024-10-17 23:26 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-17 23:23 [PATCH 00/34] bootstd: Support recording images Simon Glass
2024-10-17 23:23 ` [PATCH 01/34] alist: Mention the error condition in alist_add_placeholder() Simon Glass
2024-10-17 23:23 ` [PATCH 02/34] alist: Add a comment for alist_init_struct() Simon Glass
2024-10-17 23:23 ` [PATCH 03/34] alist: Expand the comment for alist_get() Simon Glass
2024-10-17 23:23 ` [PATCH 04/34] alist: Add a way to get the next element Simon Glass
2024-10-17 23:23 ` [PATCH 05/34] alist: Add for-loop helpers Simon Glass
2024-10-17 23:23 ` [PATCH 06/34] alist: Add a function to empty the list Simon Glass
2024-10-17 23:23 ` [PATCH 07/34] alist: Add a way to efficiently filter an alist Simon Glass
2024-10-17 23:23 ` [PATCH 08/34] dm: core: Add a function to see if a device exists Simon Glass
2024-10-17 23:23 ` [PATCH 09/34] test: boot: Use a consistent name for the script bootmeth Simon Glass
2024-10-17 23:23 ` Simon Glass [this message]
2024-10-17 23:23 ` [PATCH 11/34] bootstd: Move bootflow-clearing to bootstd Simon Glass
2024-10-17 23:23 ` [PATCH 12/34] bootstd: Add a function to get bootstd only if available Simon Glass
2024-10-17 23:23 ` [PATCH 13/34] bootstd: Drop the bootdev-specific list of bootflows Simon Glass
2024-10-17 23:23 ` [PATCH 14/34] bootstd: Move the bootflow list into an alist Simon Glass
2024-10-17 23:23 ` [PATCH 15/34] image: Add a new type for extlinux Simon Glass
2024-10-18  3:14   ` Tom Rini
2024-10-18 14:57     ` Simon Glass
2024-10-18 15:17       ` Tom Rini
2024-10-18 17:20         ` Simon Glass
2024-10-18 17:54           ` Tom Rini
2024-10-18 18:19             ` Simon Glass
2024-10-18 18:31               ` Tom Rini
2024-10-17 23:23 ` [PATCH 16/34] image: Add a new type for EFI apps Simon Glass
2024-10-18  9:03   ` Mark Kettenis
2024-10-18 14:55     ` Simon Glass
2024-10-17 23:23 ` [PATCH 17/34] image: Add a new type for logo images Simon Glass
2024-10-17 23:23 ` [PATCH 18/34] image: Add a new type for a command-line string Simon Glass
2024-10-17 23:23 ` [PATCH 19/34] test: Expand implementation of ut_list_has_dm_tests() Simon Glass
2024-10-17 23:23 ` [PATCH 20/34] test: Drop the duplicate line in setup_bootmenu_image() Simon Glass
2024-10-17 23:24 ` [PATCH 21/34] test: boot: Update bootflow_iter() for console checking Simon Glass
2024-10-17 23:24 ` [PATCH 22/34] bootstd: cros: Correct the x86-setup address Simon Glass
2024-10-17 23:24 ` [PATCH 23/34] bootstd: Maintain a list of images Simon Glass
2024-10-18  3:14   ` Tom Rini
2024-10-18  4:01   ` Heinrich Schuchardt
2024-10-18 15:01     ` Simon Glass
2024-10-18 16:33       ` Tom Rini
2024-10-18 17:20         ` Simon Glass
2024-10-18 18:04           ` Tom Rini
2024-10-18 18:48             ` Simon Glass
2024-10-18 21:30               ` Tom Rini
2024-10-19 11:49                 ` Simon Glass
2024-10-19 16:30                   ` Tom Rini
2024-10-22 12:16                     ` Simon Glass
2024-10-22 15:01                       ` Tom Rini
2024-10-22 17:00                         ` Simon Glass
2024-10-23 18:41                           ` Tom Rini
2024-10-31 18:04                             ` Simon Glass
2024-10-17 23:24 ` [PATCH 24/34] bootstd: Update bootmeth_alloc_file() to record images Simon Glass
2024-10-17 23:24 ` [PATCH 25/34] boot: pxe: Drop the duplicate comment on get_pxe_file() Simon Glass
2024-10-17 23:24 ` [PATCH 26/34] efi: Simplify reading files by using the common function Simon Glass
2024-10-18  3:14   ` Tom Rini
2024-10-17 23:24 ` [PATCH 27/34] bootmeth: Update the read_file() method to include a type Simon Glass
2024-10-17 23:24 ` [PATCH 28/34] efi: Check the filename-allocation in the network path Simon Glass
2024-10-17 23:24 ` [PATCH 29/34] boot: Update extlinux pxe_getfile_func() to include type Simon Glass
2024-10-17 23:24 ` [PATCH 30/34] boot: Update pxe bootmeth to record images Simon Glass
2024-10-17 23:24 ` [PATCH 31/34] Update bootmeth_alloc_other() " Simon Glass
2024-10-17 23:24 ` [PATCH 32/34] bootstd: Avoid showing an invalid buffer address Simon Glass
2024-10-17 23:24 ` [PATCH 33/34] bootstd: Update cros bootmeth to record images Simon Glass
2024-10-17 23:24 ` [PATCH 34/34] bootstd: Add a simple command to list images Simon Glass

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=20241017232413.724808-11-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=caleb.connolly@linaro.org \
    --cc=dsimic@manjaro.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=mibodhi@gmail.com \
    --cc=namcao@linutronix.de \
    --cc=pbrobinson@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /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.