diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index d34b7e37cf..91087981d2 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -364,7 +364,8 @@ int bootdev_unbind_dev(struct udevice *parent) * @seqp: Returns the sequence number, or -1 if none * @method_flagsp: If non-NULL, returns any flags implied by the label * (enum bootflow_meth_flags_t), 0 if none - * Returns: sequence number on success, else -ve error code + * Returns: sequence number on success, -EPFNOSUPPORT is the uclass is not + * known, other -ve error code on other error */ static int label_to_uclass(const char *label, int *seqp, int *method_flagsp) { @@ -394,8 +395,7 @@ static int label_to_uclass(const char *label, int *seqp, int *method_flagsp) id = UCLASS_ETH; method_flags |= BOOTFLOW_METHF_DHCP_ONLY; } else { - log_warning("Unknown uclass '%s' in label\n", label); - return -EINVAL; + return -EPFNOSUPPORT; } } if (id == UCLASS_USB) @@ -458,7 +458,6 @@ int bootdev_find_by_label(const char *label, struct udevice **devp, } log_debug("- no device in %s\n", media->name); } - log_warning("Unknown seq %d for label '%s'\n", seq, label); return -ENOENT; } @@ -577,9 +576,28 @@ int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp, log_debug("next\n"); for (dev = NULL; !dev && iter->labels[++iter->cur_label];) { - log_debug("Scanning: %s\n", iter->labels[iter->cur_label]); - bootdev_hunt_and_find_by_label(iter->labels[iter->cur_label], - &dev, method_flagsp); + const char *label = iter->labels[iter->cur_label]; + int ret; + + log_debug("Scanning: %s\n", label); + ret = bootdev_hunt_and_find_by_label(label, &dev, + method_flagsp); + if (iter->flags & BOOTFLOWIF_SHOW) { + if (ret == -EPFNOSUPPORT) { + log_warning("Unknown uclass '%s' in label\n", + label); + } else if (ret == -ENOENT) { + /* + * looking for, e.g. 'scsi0' should find + * something if SCSI is present + */ + if (!trailing_strtol(label)) { + log_warning("No bootdevs for '%s'\n", + label); + } + } + } + } if (!dev) diff --git a/include/bootdev.h b/include/bootdev.h index b92ff4d4f1..e72ef3650f 100644 --- a/include/bootdev.h +++ b/include/bootdev.h @@ -258,7 +258,7 @@ int bootdev_find_by_label(const char *label, struct udevice **devp, * @devp: returns the device found, on success * @method_flagsp: If non-NULL, returns any flags implied by the label * (enum bootflow_meth_flags_t), 0 if none. Unset if function fails - * Return: 0 if OK, -EINVAL if the uclass is not supported by this board, + * Return: 0 if OK, -EPFNOSUPPORT if the uclass is not supported by this board, * -ENOENT if there is no device with that number */ int bootdev_find_by_any(const char *name, struct udevice **devp, diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 4fe9fd7220..0899c78c2c 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -124,7 +124,8 @@ static int bootdev_test_labels(struct unit_test_state *uts) mflags); /* Check invalid uclass */ - ut_asserteq(-EINVAL, bootdev_find_by_label("fred0", &dev, &mflags)); + ut_asserteq(-EPFNOSUPPORT, + bootdev_find_by_label("fred0", &dev, &mflags)); /* Check unknown sequence number */ ut_asserteq(-ENOENT, bootdev_find_by_label("mmc6", &dev, &mflags)); @@ -179,9 +180,8 @@ static int bootdev_test_any(struct unit_test_state *uts) /* Check invalid uclass */ mflags = 123; - ut_asserteq(-EINVAL, bootdev_find_by_any("fred0", &dev, &mflags)); - ut_assert_nextline("Unknown uclass 'fred0' in label"); - ut_assert_nextline("Cannot find bootdev 'fred0' (err=-22)"); + ut_asserteq(-EPFNOSUPPORT, bootdev_find_by_any("fred0", &dev, &mflags)); + ut_assert_nextline("Cannot find bootdev 'fred0' (err=-96)"); ut_asserteq(123, mflags); ut_assert_console_end(); @@ -512,9 +512,8 @@ static int bootdev_test_hunt_label(struct unit_test_state *uts) old = (void *)&mflags; /* arbitrary pointer to check against dev */ dev = old; mflags = 123; - ut_asserteq(-EINVAL, + ut_asserteq(-EPFNOSUPPORT, bootdev_hunt_and_find_by_label("fred", &dev, &mflags)); - ut_assert_nextline("Unknown uclass 'fred' in label"); ut_asserteq_ptr(old, dev); ut_asserteq(123, mflags); ut_assert_console_end(); @@ -525,7 +524,6 @@ static int bootdev_test_hunt_label(struct unit_test_state *uts) bootdev_hunt_and_find_by_label("mmc4", &dev, &mflags)); ut_asserteq_ptr(old, dev); ut_asserteq(123, mflags); - ut_assert_nextline("Unknown seq 4 for label 'mmc4'"); ut_assert_console_end(); ut_assertok(bootstd_test_check_mmc_hunter(uts));