summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-01-17 10:47:26 -0700
committerTom Rini <trini@konsulko.com>2023-01-23 18:11:39 -0500
commitb85fc8dbabd7c027ad7ad6133578a0d679dbe2ba (patch)
tree6aae549dcbc09ceff6dcbef7c88f84853b0e288b /boot
parent3a2cb96e5dde427ccb670640a6a5fa1d61519a9b (diff)
downloadu-boot-b85fc8dbabd7c027ad7ad6133578a0d679dbe2ba.tar.gz
u-boot-b85fc8dbabd7c027ad7ad6133578a0d679dbe2ba.tar.bz2
u-boot-b85fc8dbabd7c027ad7ad6133578a0d679dbe2ba.zip
bootstd: Add a default method to get bootflows
The code in these functions turns out to often be the same. Add a default get_bootflow() function and allow the drivers to select it by setting the method to NULL. This saves a little code space. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot')
-rw-r--r--boot/bootdev-uclass.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 97f75cba49..0ef3daf24c 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -450,14 +450,37 @@ int bootdev_find_by_any(const char *name, struct udevice **devp)
return 0;
}
+static int default_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow)
+{
+ struct udevice *blk;
+ int ret;
+
+ ret = bootdev_get_sibling_blk(dev, &blk);
+ /*
+ * If there is no media, indicate that no more partitions should be
+ * checked
+ */
+ if (ret == -EOPNOTSUPP)
+ ret = -ESHUTDOWN;
+ if (ret)
+ return log_msg_ret("blk", ret);
+ assert(blk);
+ ret = bootdev_find_in_blk(dev, blk, iter, bflow);
+ if (ret)
+ return log_msg_ret("find", ret);
+
+ return 0;
+}
+
int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
struct bootflow *bflow)
{
const struct bootdev_ops *ops = bootdev_get_ops(dev);
- if (!ops->get_bootflow)
- return -ENOSYS;
bootflow_init(bflow, dev, iter->method);
+ if (!ops->get_bootflow)
+ return default_get_bootflow(dev, iter, bflow);
return ops->get_bootflow(dev, iter, bflow);
}