diff options
author | Simon Glass <sjg@chromium.org> | 2022-10-20 18:22:51 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-10-31 11:02:44 -0400 |
commit | b190deb8955f1043817faf84a69dd63d5a53f959 (patch) | |
tree | 50687f22dcd1e3654e0b1d33e2f2038cdb92cc98 | |
parent | cbd71fad6d468018727ab04b2bb912989aec0785 (diff) |
bootstd: Add a way to set up a bootflow
Add a function to init a bootflow, to reduce code duplication.
Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | boot/bootdev-uclass.c | 5 | ||||
-rw-r--r-- | boot/bootflow.c | 9 | ||||
-rw-r--r-- | boot/bootmeth-uclass.c | 5 | ||||
-rw-r--r-- | include/bootflow.h | 12 |
4 files changed, 23 insertions, 8 deletions
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 9d98bee4549..affe0d3e04e 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -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); } diff --git a/boot/bootflow.c b/boot/bootflow.c index 5d94a27ff84..f9ad4099244 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -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); diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 2d7652edeab..25552dd96f6 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -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); } diff --git a/include/bootflow.h b/include/bootflow.h index 6aa3d1fff8d..32dbbbbe261 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -145,6 +145,18 @@ struct bootflow_iter { }; /** + * 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 * * This sets everything to the starting point, ready for use. |