summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2025-10-12 00:43:56 -0600
committerTom Rini <[email protected]>2025-10-14 16:12:50 -0600
commit996ded5463fd48497b6aa904a5647c2533d73ab3 (patch)
treed9fab1b23dae8bb2449932ec491abd6804025577 /boot
parentf6cd0a36cee32e89449f71ce495dc8f4cd175ad8 (diff)
boot: Move preparing bootdev into a function
We will want to use this same logic in another place within iter_inc(), so split it out into its own function. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Tom Rini <[email protected]>
Diffstat (limited to 'boot')
-rw-r--r--boot/bootflow.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/boot/bootflow.c b/boot/bootflow.c
index 15df7069209..7ed076c898f 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -178,6 +178,32 @@ static void scan_next_in_uclass(struct udevice **devp)
}
/**
+ * prepare_bootdev() - Get ready to use a bootdev
+ *
+ * @iter: Bootflow iterator being used
+ * @dev: UCLASS_BOOTDEV device to use
+ * @method_flags: Method flag for the bootdev
+ * Return 0 if OK, -ve if the bootdev failed to probe
+ */
+static int prepare_bootdev(struct bootflow_iter *iter, struct udevice *dev,
+ int method_flags)
+{
+ int ret;
+
+ /*
+ * Probe the bootdev. This does not probe any attached block device,
+ * since they are siblings
+ */
+ ret = device_probe(dev);
+ log_debug("probe %s %d\n", dev->name, ret);
+ if (ret)
+ return log_msg_ret("probe", ret);
+ bootflow_iter_set_dev(iter, dev, method_flags);
+
+ return 0;
+}
+
+/**
* iter_incr() - Move to the next item (method, part, bootdev)
*
* Return: 0 if OK, BF_NO_MORE_DEVICES if there are no more bootdevs
@@ -310,18 +336,10 @@ static int iter_incr(struct bootflow_iter *iter)
}
log_debug("ret=%d, dev=%p %s\n", ret, dev,
dev ? dev->name : "none");
- if (ret) {
+ if (ret)
bootflow_iter_set_dev(iter, NULL, 0);
- } else {
- /*
- * Probe the bootdev. This does not probe any attached
- * block device, since they are siblings
- */
- ret = device_probe(dev);
- log_debug("probe %s %d\n", dev->name, ret);
- if (!log_msg_ret("probe", ret))
- bootflow_iter_set_dev(iter, dev, method_flags);
- }
+ else
+ ret = prepare_bootdev(iter, dev, method_flags);
}
/* if there are no more bootdevs, give up */