mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 15:14:43 +00:00
bootflow: Rename bootflow_flags_t
These flags actually relate to the iterator, not the bootflow struct itself. Rename them. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
fe7e9245c5
commit
4f806f31fc
7 changed files with 60 additions and 59 deletions
|
@ -629,11 +629,11 @@ int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp)
|
|||
if (++iter->cur_prio == BOOTDEVP_COUNT)
|
||||
return log_msg_ret("fin", -ENODEV);
|
||||
|
||||
if (iter->flags & BOOTFLOWF_HUNT) {
|
||||
if (iter->flags & BOOTFLOWIF_HUNT) {
|
||||
/* hunt to find new bootdevs */
|
||||
ret = bootdev_hunt_prio(iter->cur_prio,
|
||||
iter->flags &
|
||||
BOOTFLOWF_SHOW);
|
||||
BOOTFLOWIF_SHOW);
|
||||
log_debug("- hunt ret %d\n", ret);
|
||||
if (ret)
|
||||
return log_msg_ret("hun", ret);
|
||||
|
@ -657,7 +657,7 @@ int bootdev_setup_iter(struct bootflow_iter *iter, const char *label,
|
|||
struct udevice **devp, int *method_flagsp)
|
||||
{
|
||||
struct udevice *bootstd, *dev = NULL;
|
||||
bool show = iter->flags & BOOTFLOWF_SHOW;
|
||||
bool show = iter->flags & BOOTFLOWIF_SHOW;
|
||||
int method_flags;
|
||||
int ret;
|
||||
|
||||
|
@ -668,7 +668,7 @@ int bootdev_setup_iter(struct bootflow_iter *iter, const char *label,
|
|||
}
|
||||
|
||||
/* hunt for any pre-scan devices */
|
||||
if (iter->flags & BOOTFLOWF_HUNT) {
|
||||
if (iter->flags & BOOTFLOWIF_HUNT) {
|
||||
ret = bootdev_hunt_prio(BOOTDEVP_1_PRE_SCAN, show);
|
||||
if (ret)
|
||||
return log_msg_ret("pre", ret);
|
||||
|
@ -676,7 +676,7 @@ int bootdev_setup_iter(struct bootflow_iter *iter, const char *label,
|
|||
|
||||
/* Handle scanning a single device */
|
||||
if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && label) {
|
||||
if (iter->flags & BOOTFLOWF_HUNT) {
|
||||
if (iter->flags & BOOTFLOWIF_HUNT) {
|
||||
ret = bootdev_hunt(label, show);
|
||||
if (ret)
|
||||
return log_msg_ret("hun", ret);
|
||||
|
@ -687,11 +687,11 @@ int bootdev_setup_iter(struct bootflow_iter *iter, const char *label,
|
|||
|
||||
log_debug("method_flags: %x\n", method_flags);
|
||||
if (method_flags & BOOTFLOW_METHF_SINGLE_UCLASS)
|
||||
iter->flags |= BOOTFLOWF_SINGLE_UCLASS;
|
||||
iter->flags |= BOOTFLOWIF_SINGLE_UCLASS;
|
||||
else if (method_flags & BOOTFLOW_METHF_SINGLE_DEV)
|
||||
iter->flags |= BOOTFLOWF_SINGLE_DEV;
|
||||
iter->flags |= BOOTFLOWIF_SINGLE_DEV;
|
||||
else
|
||||
iter->flags |= BOOTFLOWF_SINGLE_MEDIA;
|
||||
iter->flags |= BOOTFLOWIF_SINGLE_MEDIA;
|
||||
log_debug("Selected label: %s, flags %x\n", label, iter->flags);
|
||||
} else {
|
||||
bool ok;
|
||||
|
|
|
@ -139,8 +139,8 @@ static void bootflow_iter_set_dev(struct bootflow_iter *iter,
|
|||
if (dev && iter->num_devs < iter->max_devs)
|
||||
iter->dev_used[iter->num_devs++] = dev;
|
||||
|
||||
if ((iter->flags & (BOOTFLOWF_SHOW | BOOTFLOWF_SINGLE_DEV)) ==
|
||||
BOOTFLOWF_SHOW) {
|
||||
if ((iter->flags & (BOOTFLOWIF_SHOW | BOOTFLOWIF_SINGLE_DEV)) ==
|
||||
BOOTFLOWIF_SHOW) {
|
||||
if (dev)
|
||||
printf("Scanning bootdev '%s':\n", dev->name);
|
||||
else if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) &&
|
||||
|
@ -215,7 +215,7 @@ static int iter_incr(struct bootflow_iter *iter)
|
|||
iter->max_part = 0;
|
||||
|
||||
/* ...select next bootdev */
|
||||
if (iter->flags & BOOTFLOWF_SINGLE_DEV) {
|
||||
if (iter->flags & BOOTFLOWIF_SINGLE_DEV) {
|
||||
ret = -ENOENT;
|
||||
} else {
|
||||
int method_flags;
|
||||
|
@ -227,7 +227,7 @@ static int iter_incr(struct bootflow_iter *iter)
|
|||
ret = bootdev_setup_iter(iter, NULL, &dev,
|
||||
&method_flags);
|
||||
} else if (IS_ENABLED(CONFIG_BOOTSTD_FULL) &&
|
||||
(iter->flags & BOOTFLOWF_SINGLE_UCLASS)) {
|
||||
(iter->flags & BOOTFLOWIF_SINGLE_UCLASS)) {
|
||||
/* Move to the next bootdev in this uclass */
|
||||
uclass_find_next_device(&dev);
|
||||
if (!dev) {
|
||||
|
@ -236,7 +236,7 @@ static int iter_incr(struct bootflow_iter *iter)
|
|||
ret = -ENODEV;
|
||||
}
|
||||
} else if (IS_ENABLED(CONFIG_BOOTSTD_FULL) &&
|
||||
iter->flags & BOOTFLOWF_SINGLE_MEDIA) {
|
||||
iter->flags & BOOTFLOWIF_SINGLE_MEDIA) {
|
||||
log_debug("next in single\n");
|
||||
method_flags = 0;
|
||||
do {
|
||||
|
@ -328,7 +328,7 @@ static int bootflow_check(struct bootflow_iter *iter, struct bootflow *bflow)
|
|||
* For 'all' we return all bootflows, even
|
||||
* those with errors
|
||||
*/
|
||||
if (iter->flags & BOOTFLOWF_ALL)
|
||||
if (iter->flags & BOOTFLOWIF_ALL)
|
||||
return log_msg_ret("all", ret);
|
||||
}
|
||||
if (ret)
|
||||
|
@ -344,14 +344,14 @@ int bootflow_scan_first(struct udevice *dev, const char *label,
|
|||
int ret;
|
||||
|
||||
if (dev || label)
|
||||
flags |= BOOTFLOWF_SKIP_GLOBAL;
|
||||
flags |= BOOTFLOWIF_SKIP_GLOBAL;
|
||||
bootflow_iter_init(iter, flags);
|
||||
|
||||
/*
|
||||
* Set up the ordering of bootmeths. This sets iter->doing_global and
|
||||
* iter->first_glob_method if we are starting with the global bootmeths
|
||||
*/
|
||||
ret = bootmeth_setup_iter_order(iter, !(flags & BOOTFLOWF_SKIP_GLOBAL));
|
||||
ret = bootmeth_setup_iter_order(iter, !(flags & BOOTFLOWIF_SKIP_GLOBAL));
|
||||
if (ret)
|
||||
return log_msg_ret("obmeth", -ENODEV);
|
||||
|
||||
|
@ -373,7 +373,7 @@ int bootflow_scan_first(struct udevice *dev, const char *label,
|
|||
if (ret) {
|
||||
log_debug("check - ret=%d\n", ret);
|
||||
if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) {
|
||||
if (iter->flags & BOOTFLOWF_ALL)
|
||||
if (iter->flags & BOOTFLOWIF_ALL)
|
||||
return log_msg_ret("all", ret);
|
||||
}
|
||||
iter->err = ret;
|
||||
|
@ -402,7 +402,7 @@ int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow)
|
|||
return 0;
|
||||
iter->err = ret;
|
||||
if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) {
|
||||
if (iter->flags & BOOTFLOWF_ALL)
|
||||
if (iter->flags & BOOTFLOWIF_ALL)
|
||||
return log_msg_ret("all", ret);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -135,13 +135,13 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||
|
||||
flags = 0;
|
||||
if (list)
|
||||
flags |= BOOTFLOWF_SHOW;
|
||||
flags |= BOOTFLOWIF_SHOW;
|
||||
if (all)
|
||||
flags |= BOOTFLOWF_ALL;
|
||||
flags |= BOOTFLOWIF_ALL;
|
||||
if (no_global)
|
||||
flags |= BOOTFLOWF_SKIP_GLOBAL;
|
||||
flags |= BOOTFLOWIF_SKIP_GLOBAL;
|
||||
if (!no_hunter)
|
||||
flags |= BOOTFLOWF_HUNT;
|
||||
flags |= BOOTFLOWIF_HUNT;
|
||||
|
||||
/*
|
||||
* If we have a device, just scan for bootflows attached to that device
|
||||
|
|
|
@ -489,22 +489,22 @@ in a valid bootflow, whether to iterate through just a single bootdev, etc.
|
|||
Then the iterator is set up to according to the parameters given:
|
||||
|
||||
- When `dev` is provided, then a single bootdev is scanned. In this case,
|
||||
`BOOTFLOWF_SKIP_GLOBAL` and `BOOTFLOWF_SINGLE_DEV` are set. No hunters are
|
||||
`BOOTFLOWIF_SKIP_GLOBAL` and `BOOTFLOWIF_SINGLE_DEV` are set. No hunters are
|
||||
used in this case
|
||||
|
||||
- Otherwise, when `label` is provided, then a single label or named bootdev is
|
||||
scanned. In this case `BOOTFLOWF_SKIP_GLOBAL` is set and there are three
|
||||
scanned. In this case `BOOTFLOWIF_SKIP_GLOBAL` is set and there are three
|
||||
options (with an effect on the `iter_incr()` function described later):
|
||||
|
||||
- If `label` indicates a numeric bootdev number (e.g. "2") then
|
||||
`BOOTFLOW_METHF_SINGLE_DEV` is set. In this case, moving to the next bootdev
|
||||
simple stops, since there is only one. No hunters are used.
|
||||
- If `label` indicates a particular media device (e.g. "mmc1") then
|
||||
`BOOTFLOWF_SINGLE_MEDIA` is set. In this case, moving to the next bootdev
|
||||
`BOOTFLOWIF_SINGLE_MEDIA` is set. In this case, moving to the next bootdev
|
||||
processes just the children of the media device. Hunters are used, in this
|
||||
example just the "mmc" hunter.
|
||||
- If `label` indicates a media uclass (e.g. "mmc") then
|
||||
`BOOTFLOWF_SINGLE_UCLASS` is set. In this case, all bootdevs in that uclass
|
||||
`BOOTFLOWIF_SINGLE_UCLASS` is set. In this case, all bootdevs in that uclass
|
||||
are used. Hunters are used, in this example just the "mmc" hunter
|
||||
|
||||
- Otherwise, none of the above flags is set and iteration is set up to work
|
||||
|
@ -543,7 +543,7 @@ bootdev.
|
|||
With the iterator ready, `bootflow_scan_first()` checks whether the current
|
||||
settings produce a valid bootflow. This is handled by `bootflow_check()`, which
|
||||
either returns 0 (if it got something) or an error if not (more on that later).
|
||||
If the `BOOTFLOWF_ALL` iterator flag is set, even errors are returned as
|
||||
If the `BOOTFLOWIF_ALL` iterator flag is set, even errors are returned as
|
||||
incomplete bootflows, but normally an error results in moving onto the next
|
||||
iteration.
|
||||
|
||||
|
@ -651,7 +651,7 @@ e.g. updating the state, depending on what it finds. For global bootmeths the
|
|||
Based on what the bootdev or bootmeth responds with, `bootflow_check()` either
|
||||
returns a valid bootflow, or a partial one with an error. A partial bootflow
|
||||
is one that has some fields set up, but did not reach the `BOOTFLOWST_READY`
|
||||
state. As noted before, if the `BOOTFLOWF_ALL` iterator flag is set, then all
|
||||
state. As noted before, if the `BOOTFLOWIF_ALL` iterator flag is set, then all
|
||||
bootflows are returned, even partial ones. This can help with debugging.
|
||||
|
||||
So at this point you can see that total control over whether a bootflow can
|
||||
|
|
|
@ -93,36 +93,36 @@ struct bootflow {
|
|||
};
|
||||
|
||||
/**
|
||||
* enum bootflow_flags_t - flags for the bootflow iterator
|
||||
* enum bootflow_iter_flags_t - flags for the bootflow iterator
|
||||
*
|
||||
* @BOOTFLOWF_FIXED: Only used fixed/internal media
|
||||
* @BOOTFLOWF_SHOW: Show each bootdev before scanning it; show each hunter
|
||||
* @BOOTFLOWIF_FIXED: Only used fixed/internal media
|
||||
* @BOOTFLOWIF_SHOW: Show each bootdev before scanning it; show each hunter
|
||||
* before using it
|
||||
* @BOOTFLOWF_ALL: Return bootflows with errors as well
|
||||
* @BOOTFLOWF_HUNT: Hunt for new bootdevs using the bootdrv hunters
|
||||
* @BOOTFLOWIF_ALL: Return bootflows with errors as well
|
||||
* @BOOTFLOWIF_HUNT: Hunt for new bootdevs using the bootdrv hunters
|
||||
*
|
||||
* Internal flags:
|
||||
* @BOOTFLOWF_SINGLE_DEV: (internal) Just scan one bootdev
|
||||
* @BOOTFLOWF_SKIP_GLOBAL: (internal) Don't scan global bootmeths
|
||||
* @BOOTFLOWF_SINGLE_UCLASS: (internal) Keep scanning through all devices in
|
||||
* @BOOTFLOWIF_SINGLE_DEV: (internal) Just scan one bootdev
|
||||
* @BOOTFLOWIF_SKIP_GLOBAL: (internal) Don't scan global bootmeths
|
||||
* @BOOTFLOWIF_SINGLE_UCLASS: (internal) Keep scanning through all devices in
|
||||
* this uclass (used with things like "mmc")
|
||||
* @BOOTFLOWF_SINGLE_MEDIA: (internal) Scan one media device in the uclass (used
|
||||
* @BOOTFLOWIF_SINGLE_MEDIA: (internal) Scan one media device in the uclass (used
|
||||
* with things like "mmc1")
|
||||
*/
|
||||
enum bootflow_flags_t {
|
||||
BOOTFLOWF_FIXED = 1 << 0,
|
||||
BOOTFLOWF_SHOW = 1 << 1,
|
||||
BOOTFLOWF_ALL = 1 << 2,
|
||||
BOOTFLOWF_HUNT = 1 << 3,
|
||||
enum bootflow_iter_flags_t {
|
||||
BOOTFLOWIF_FIXED = 1 << 0,
|
||||
BOOTFLOWIF_SHOW = 1 << 1,
|
||||
BOOTFLOWIF_ALL = 1 << 2,
|
||||
BOOTFLOWIF_HUNT = 1 << 3,
|
||||
|
||||
/*
|
||||
* flags used internally by standard boot - do not set these when
|
||||
* calling bootflow_scan_bootdev() etc.
|
||||
*/
|
||||
BOOTFLOWF_SINGLE_DEV = 1 << 16,
|
||||
BOOTFLOWF_SKIP_GLOBAL = 1 << 17,
|
||||
BOOTFLOWF_SINGLE_UCLASS = 1 << 18,
|
||||
BOOTFLOWF_SINGLE_MEDIA = 1 << 19,
|
||||
BOOTFLOWIF_SINGLE_DEV = 1 << 16,
|
||||
BOOTFLOWIF_SKIP_GLOBAL = 1 << 17,
|
||||
BOOTFLOWIF_SINGLE_UCLASS = 1 << 18,
|
||||
BOOTFLOWIF_SINGLE_MEDIA = 1 << 19,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -164,9 +164,9 @@ enum bootflow_meth_flags_t {
|
|||
* updated to a larger value, no less than the number of available partitions.
|
||||
* This ensures that iteration works through all partitions on the bootdev.
|
||||
*
|
||||
* @flags: Flags to use (see enum bootflow_flags_t). If BOOTFLOWF_GLOBAL_FIRST is
|
||||
* enabled then the global bootmeths are being scanned, otherwise we have
|
||||
* moved onto the bootdevs
|
||||
* @flags: Flags to use (see enum bootflow_iter_flags_t). If
|
||||
* BOOTFLOWIF_GLOBAL_FIRST is enabled then the global bootmeths are being
|
||||
* scanned, otherwise we have moved onto the bootdevs
|
||||
* @dev: Current bootdev, NULL if none. This is only ever updated in
|
||||
* bootflow_iter_set_dev()
|
||||
* @part: Current partition number (0 for whole device)
|
||||
|
@ -233,7 +233,7 @@ void bootflow_init(struct bootflow *bflow, struct udevice *bootdev,
|
|||
* This sets everything to the starting point, ready for use.
|
||||
*
|
||||
* @iter: Place to store private info (inited by this call)
|
||||
* @flags: Flags to use (see enum bootflow_flags_t)
|
||||
* @flags: Flags to use (see enum bootflow_iter_flags_t)
|
||||
*/
|
||||
void bootflow_iter_init(struct bootflow_iter *iter, int flags);
|
||||
|
||||
|
@ -259,15 +259,16 @@ int bootflow_iter_drop_bootmeth(struct bootflow_iter *iter,
|
|||
/**
|
||||
* bootflow_scan_first() - find the first bootflow for a device or label
|
||||
*
|
||||
* If @flags includes BOOTFLOWF_ALL then bootflows with errors are returned too
|
||||
* If @flags includes BOOTFLOWIF_ALL then bootflows with errors are returned too
|
||||
*
|
||||
* @dev: Boot device to scan, NULL to work through all of them until it
|
||||
* finds one that can supply a bootflow
|
||||
* @label: Label to control the scan, NULL to work through all devices
|
||||
* until it finds one that can supply a bootflow
|
||||
* @iter: Place to store private info (inited by this call)
|
||||
* @flags: Flags for iterator (enum bootflow_flags_t). Note that if @dev
|
||||
* is NULL, then BOOTFLOWF_SKIP_GLOBAL is set automatically by this function
|
||||
* @flags: Flags for iterator (enum bootflow_iter_flags_t). Note that if
|
||||
* @dev is NULL, then BOOTFLOWIF_SKIP_GLOBAL is set automatically by this
|
||||
* function
|
||||
* @bflow: Place to put the bootflow if found
|
||||
* Return: 0 if found, -ENODEV if no device, other -ve on other error
|
||||
* (iteration can continue)
|
||||
|
|
|
@ -289,7 +289,7 @@ static int bootdev_test_prio(struct unit_test_state *uts)
|
|||
|
||||
/* try again but enable hunting, which brings in SCSI */
|
||||
bootflow_iter_uninit(&iter);
|
||||
ut_assertok(bootflow_scan_first(NULL, NULL, &iter, BOOTFLOWF_HUNT,
|
||||
ut_assertok(bootflow_scan_first(NULL, NULL, &iter, BOOTFLOWIF_HUNT,
|
||||
&bflow));
|
||||
ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow));
|
||||
ut_asserteq(7, iter.num_devs);
|
||||
|
@ -427,8 +427,8 @@ static int bootdev_test_hunt_scan(struct unit_test_state *uts)
|
|||
|
||||
ut_assertok(bootstd_test_drop_bootdev_order(uts));
|
||||
ut_assertok(bootflow_scan_first(NULL, NULL, &iter,
|
||||
BOOTFLOWF_SHOW | BOOTFLOWF_HUNT |
|
||||
BOOTFLOWF_SKIP_GLOBAL, &bflow));
|
||||
BOOTFLOWIF_SHOW | BOOTFLOWIF_HUNT |
|
||||
BOOTFLOWIF_SKIP_GLOBAL, &bflow));
|
||||
ut_asserteq(BIT(MMC_HUNTER) | BIT(1), std->hunters_used);
|
||||
|
||||
return 0;
|
||||
|
@ -649,7 +649,7 @@ static int bootdev_test_next_prio(struct unit_test_state *uts)
|
|||
iter.part = 0;
|
||||
uclass_first_device(UCLASS_BOOTMETH, &bflow.method);
|
||||
iter.cur_prio = 0;
|
||||
iter.flags = BOOTFLOWF_SHOW;
|
||||
iter.flags = BOOTFLOWIF_SHOW;
|
||||
|
||||
dev = NULL;
|
||||
console_record_reset_enable();
|
||||
|
@ -662,7 +662,7 @@ static int bootdev_test_next_prio(struct unit_test_state *uts)
|
|||
ut_assert_console_end();
|
||||
|
||||
/* now try again with hunting enabled */
|
||||
iter.flags = BOOTFLOWF_SHOW | BOOTFLOWF_HUNT;
|
||||
iter.flags = BOOTFLOWIF_SHOW | BOOTFLOWIF_HUNT;
|
||||
iter.cur_prio = 0;
|
||||
iter.part = 0;
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ static int bootflow_iter(struct unit_test_state *uts)
|
|||
/* The first device is mmc2.bootdev which has no media */
|
||||
ut_asserteq(-EPROTONOSUPPORT,
|
||||
bootflow_scan_first(NULL, NULL, &iter,
|
||||
BOOTFLOWF_ALL | BOOTFLOWF_SKIP_GLOBAL, &bflow));
|
||||
BOOTFLOWIF_ALL | BOOTFLOWIF_SKIP_GLOBAL, &bflow));
|
||||
ut_asserteq(2, iter.num_methods);
|
||||
ut_asserteq(0, iter.cur_method);
|
||||
ut_asserteq(0, iter.part);
|
||||
|
|
Loading…
Reference in a new issue