bootstd: Move bootflow-clearing to bootstd
authorSimon Glass <sjg@chromium.org>
Fri, 15 Nov 2024 23:19:09 +0000 (16:19 -0700)
committerTom Rini <trini@konsulko.com>
Wed, 15 Jan 2025 14:48:42 +0000 (08:48 -0600)
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>
Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
boot/bootdev-uclass.c
boot/bootstd-uclass.c
cmd/bootflow.c
include/bootdev.h
include/bootstd.h

index eddbf60..26b0034 100644 (file)
@@ -557,19 +557,6 @@ int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
        return ops->get_bootflow(dev, iter, bflow);
 }
 
-void bootdev_clear_bootflows(struct udevice *dev)
-{
-       struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
-
-       while (!list_empty(&ucp->bootflow_head)) {
-               struct bootflow *bflow;
-
-               bflow = list_first_entry(&ucp->bootflow_head, struct bootflow,
-                                        bm_node);
-               bootflow_remove(bflow);
-       }
-}
-
 int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp,
                       int *method_flagsp)
 {
@@ -935,7 +922,11 @@ static int bootdev_post_bind(struct udevice *dev)
 
 static int bootdev_pre_unbind(struct udevice *dev)
 {
-       bootdev_clear_bootflows(dev);
+       int ret;
+
+       ret = bootstd_clear_bootflows_for_bootdev(dev);
+       if (ret)
+               return log_msg_ret("bun", ret);
 
        return 0;
 }
index bf6e49a..596d3e5 100644 (file)
@@ -86,6 +86,21 @@ int bootstd_add_bootflow(struct bootflow *bflow)
        return 0;
 }
 
+int bootstd_clear_bootflows_for_bootdev(struct udevice *dev)
+{
+       struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+
+       while (!list_empty(&ucp->bootflow_head)) {
+               struct bootflow *bflow;
+
+               bflow = list_first_entry(&ucp->bootflow_head, struct bootflow,
+                                        bm_node);
+               bootflow_remove(bflow);
+       }
+
+       return 0;
+}
+
 static int bootstd_remove(struct udevice *dev)
 {
        struct bootstd_priv *priv = dev_get_priv(dev);
index 8962464..1c1146c 100644 (file)
@@ -197,7 +197,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc,
                show_header();
        }
        if (dev)
-               bootdev_clear_bootflows(dev);
+               bootstd_clear_bootflows_for_bootdev(dev);
        else
                bootstd_clear_glob();
        for (i = 0,
index 8db198d..f9cae2f 100644 (file)
@@ -185,16 +185,6 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
  */
 void bootdev_list(bool probe);
 
-/**
- * bootdev_clear_bootflows() - Clear bootflows from a bootdev
- *
- * Each bootdev maintains a list of discovered bootflows. This provides a
- * way to clear it. These bootflows are removed from the global list too.
- *
- * @dev: bootdev device to update
- */
-void bootdev_clear_bootflows(struct udevice *dev);
-
 /**
  * bootdev_first_bootflow() - Get the first bootflow from a bootdev
  *
index 3fc93a4..4220ece 100644 (file)
@@ -122,4 +122,14 @@ int bootstd_prog_boot(void);
  */
 int bootstd_add_bootflow(struct bootflow *bflow);
 
+/**
+ * bootstd_clear_bootflows_for_bootdev() - Clear bootflows from a bootdev
+ *
+ * Each bootdev maintains a list of discovered bootflows. This provides a
+ * way to clear it. These bootflows are removed from the global list too.
+ *
+ * @dev: bootdev device to update
+ */
+int bootstd_clear_bootflows_for_bootdev(struct udevice *dev);
+
 #endif