]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
bootstd: Add a way to set up a bootflow
authorSimon Glass <sjg@chromium.org>
Fri, 21 Oct 2022 00:22:51 +0000 (18:22 -0600)
committerTom Rini <trini@konsulko.com>
Mon, 31 Oct 2022 15:02:44 +0000 (11:02 -0400)
Add a function to init a bootflow, to reduce code duplication.

Signed-off-by: Simon Glass <sjg@chromium.org>
boot/bootdev-uclass.c
boot/bootflow.c
boot/bootmeth-uclass.c
include/bootflow.h

index 9d98bee454919ee1e147b29818424f36c002bae4..affe0d3e04e75e5852f8b64e702760f8078e21b9 100644 (file)
@@ -440,10 +440,7 @@ int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
 
        if (!ops->get_bootflow)
                return -ENOSYS;
-       memset(bflow, '\0', sizeof(*bflow));
-       bflow->dev = dev;
-       bflow->method = iter->method;
-       bflow->state = BOOTFLOWST_BASE;
+       bootflow_init(bflow, dev, iter->method);
 
        return ops->get_bootflow(dev, iter, bflow);
 }
index 5d94a27ff841e14a53388f412240f1cd17db2d71..f9ad40992442b211adc04a7b208fbf39744b6e8e 100644 (file)
@@ -339,6 +339,15 @@ int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow)
        } while (1);
 }
 
+void bootflow_init(struct bootflow *bflow, struct udevice *bootdev,
+                  struct udevice *meth)
+{
+       memset(bflow, '\0', sizeof(*bflow));
+       bflow->dev = bootdev;
+       bflow->method = meth;
+       bflow->state = BOOTFLOWST_BASE;
+}
+
 void bootflow_free(struct bootflow *bflow)
 {
        free(bflow->name);
index 2d7652edeaba96bafe6f7d59731f81eb67cea2bf..25552dd96f676a1764cb021b0ae4f1cba54b32bc 100644 (file)
@@ -77,10 +77,7 @@ int bootmeth_get_bootflow(struct udevice *dev, struct bootflow *bflow)
 
        if (!ops->read_bootflow)
                return -ENOSYS;
-       memset(bflow, '\0', sizeof(*bflow));
-       bflow->dev = NULL;
-       bflow->method = dev;
-       bflow->state = BOOTFLOWST_BASE;
+       bootflow_init(bflow, NULL, dev);
 
        return ops->read_bootflow(dev, bflow);
 }
index 6aa3d1fff8d30c6a55af97234a0d209309c1d364..32dbbbbe26133a8ce758b7c4ccbaf3e891672f79 100644 (file)
@@ -144,6 +144,18 @@ struct bootflow_iter {
        bool doing_global;
 };
 
+/**
+ * bootflow_init() - Set up a bootflow struct
+ *
+ * The bootflow is zeroed and set to state BOOTFLOWST_BASE
+ *
+ * @bflow: Struct to set up
+ * @bootdev: Bootdev to use
+ * @meth: Bootmeth to use
+ */
+void bootflow_init(struct bootflow *bflow, struct udevice *bootdev,
+                  struct udevice *meth);
+
 /**
  * bootflow_iter_init() - Reset a bootflow iterator
  *