[Concept,11/14] extlinux: Move pxe_context to new extlinux_priv struct

Message ID 20260322235719.1729267-12-sjg@u-boot.org
State New
Headers
Series bootstd: Infrastructure for multi-entry bootflow support |

Commit Message

Simon Glass March 22, 2026, 11:57 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

Move struct pxe_context from extlinux_plat (platform data) to a new
extlinux_priv (private runtime data), since the context is runtime state
rather than configuration. The info field stays in extlinux_plat as it
is only used temporarily during context setup.

Add priv_auto to the extlinux and pxe drivers. The VBE driver is not
changed here as it has its own priv struct (abrec_priv).

This is a preparatory step towards replacing the single context with an
alist of contexts for multi-entry support.

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

 boot/bootmeth_extlinux.c | 11 ++++++-----
 boot/bootmeth_pxe.c      | 11 ++++++-----
 boot/ext_pxe_common.c    |  4 ++--
 include/extlinux.h       | 13 ++++++++++---
 4 files changed, 24 insertions(+), 15 deletions(-)
  

Patch

diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c
index 1fd2547d2b3..ad2f32ca8a5 100644
--- a/boot/bootmeth_extlinux.c
+++ b/boot/bootmeth_extlinux.c
@@ -217,18 +217,18 @@  static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow)
 
 static int extlinux_local_boot(struct udevice *dev, struct bootflow *bflow)
 {
-	struct extlinux_plat *plat = dev_get_plat(dev);
+	struct extlinux_priv *priv = dev_get_priv(dev);
 
-	return extlinux_boot(dev, bflow, &plat->ctx, extlinux_getfile, true,
+	return extlinux_boot(dev, bflow, &priv->ctx, extlinux_getfile, true,
 			     bflow->fname, false);
 }
 
 #if CONFIG_IS_ENABLED(BOOTSTD_FULL)
 static int extlinux_local_read_all(struct udevice *dev, struct bootflow *bflow)
 {
-	struct extlinux_plat *plat = dev_get_plat(dev);
+	struct extlinux_priv *priv = dev_get_priv(dev);
 
-	return extlinux_read_all(dev, bflow, &plat->ctx, extlinux_getfile,
+	return extlinux_read_all(dev, bflow, &priv->ctx, extlinux_getfile,
 				 true, bflow->fname);
 }
 #endif
@@ -267,5 +267,6 @@  U_BOOT_DRIVER(bootmeth_1extlinux) = {
 	.of_match	= extlinux_bootmeth_ids,
 	.ops		= &extlinux_bootmeth_ops,
 	.bind		= extlinux_bootmeth_bind,
-	.plat_auto	= sizeof(struct extlinux_plat)
+	.plat_auto	= sizeof(struct extlinux_plat),
+	.priv_auto	= sizeof(struct extlinux_priv),
 };
diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c
index 91e05a44841..55e7f60c5cd 100644
--- a/boot/bootmeth_pxe.c
+++ b/boot/bootmeth_pxe.c
@@ -145,18 +145,18 @@  static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow,
 
 static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow)
 {
-	struct extlinux_plat *plat = dev_get_plat(dev);
+	struct extlinux_priv *priv = dev_get_priv(dev);
 
-	return extlinux_boot(dev, bflow, &plat->ctx, extlinux_pxe_getfile,
+	return extlinux_boot(dev, bflow, &priv->ctx, extlinux_pxe_getfile,
 			     false, bflow->subdir, false);
 }
 
 #if CONFIG_IS_ENABLED(BOOTSTD_FULL)
 static int extlinux_pxe_read_all(struct udevice *dev, struct bootflow *bflow)
 {
-	struct extlinux_plat *plat = dev_get_plat(dev);
+	struct extlinux_priv *priv = dev_get_priv(dev);
 
-	return extlinux_read_all(dev, bflow, &plat->ctx,
+	return extlinux_read_all(dev, bflow, &priv->ctx,
 				 extlinux_pxe_getfile, false, bflow->subdir);
 }
 #endif
@@ -193,5 +193,6 @@  U_BOOT_DRIVER(bootmeth_zpxe) = {
 	.of_match	= extlinux_bootmeth_pxe_ids,
 	.ops		= &extlinux_bootmeth_pxe_ops,
 	.bind		= extlinux_bootmeth_pxe_bind,
-	.plat_auto	= sizeof(struct extlinux_plat)
+	.plat_auto	= sizeof(struct extlinux_plat),
+	.priv_auto	= sizeof(struct extlinux_priv),
 };
diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c
index 46302d3e962..5a4b6455a53 100644
--- a/boot/ext_pxe_common.c
+++ b/boot/ext_pxe_common.c
@@ -85,8 +85,8 @@  static int extlinux_setup(struct udevice *dev, struct bootflow *bflow,
 	plat->info.dev = dev;
 	plat->info.bflow = bflow;
 
-	ret = pxe_setup_ctx(ctx, getfile, &plat->info, allow_abs_path, bootfile,
-			    false, plat->use_fallback, bflow);
+	ret = pxe_setup_ctx(ctx, getfile, &plat->info, allow_abs_path,
+			    bootfile, false, plat->use_fallback, bflow);
 	if (ret)
 		return log_msg_ret("ctx", ret);
 	log_debug("bootfl flags %x\n", bflow->flags);
diff --git a/include/extlinux.h b/include/extlinux.h
index cf9191874f0..66500f4c8cf 100644
--- a/include/extlinux.h
+++ b/include/extlinux.h
@@ -23,18 +23,25 @@  struct extlinux_info {
 };
 
 /**
- * struct extlinux_plat - locate state for this bootmeth
+ * struct extlinux_plat - platform data for this bootmeth
  *
  * @use_falllback: true to boot with the fallback option
- * @ctx: holds the PXE context, if it should be saved
  * @info: information used for the getfile() method
  */
 struct extlinux_plat {
 	bool use_fallback;
-	struct pxe_context ctx;
 	struct extlinux_info info;
 };
 
+/**
+ * struct extlinux_priv - private runtime data for this bootmeth
+ *
+ * @ctx: holds the PXE context
+ */
+struct extlinux_priv {
+	struct pxe_context ctx;
+};
+
 /**
  * extlinux_set_property() - set an extlinux property
  *