summaryrefslogtreecommitdiff
path: root/boot/bootmeth_efi.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-07-27 06:01:22 +0300
committerTom Rini <trini@konsulko.com>2023-08-03 22:30:54 +0300
commit146242cc998ed6e002831d4ff409189353e1960a (patch)
treed8a4908a7eeb7bb3a2ece1c1aff48612522c4ea9 /boot/bootmeth_efi.c
parent0c0c82b5177e9afb3a248da4d004f3dc48975c91 (diff)
downloadu-boot-146242cc998ed6e002831d4ff409189353e1960a.tar.xz
bootstd: Use a function to detect network in EFI bootmeth
This checks for a network-based bootflow in two places, one of which is less than ideal. Move the correct test into a function and use it in both places. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot/bootmeth_efi.c')
-rw-r--r--boot/bootmeth_efi.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index af31fbfc85..e88e171ccc 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -94,6 +94,20 @@ static int get_efi_pxe_vci(char *str, int max_len)
return 0;
}
+/**
+ * bootmeth_uses_network() - check if the media device is Ethernet
+ *
+ * @bflow: Bootflow to check
+ * Returns: true if the media device is Ethernet, else false
+ */
+static bool bootmeth_uses_network(struct bootflow *bflow)
+{
+ const struct udevice *media = dev_get_parent(bflow->dev);
+
+ return IS_ENABLED(CONFIG_CMD_DHCP) &&
+ device_get_uclass_id(media) == UCLASS_ETH;
+}
+
static void set_efi_bootdev(struct blk_desc *desc, struct bootflow *bflow)
{
const struct udevice *media_dev;
@@ -354,11 +368,9 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow)
static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow)
{
- const struct udevice *media = dev_get_parent(bflow->dev);
int ret;
- if (IS_ENABLED(CONFIG_CMD_DHCP) &&
- device_get_uclass_id(media) == UCLASS_ETH) {
+ if (bootmeth_uses_network(bflow)) {
/* we only support reading from one device, so ignore 'dev' */
ret = distro_efi_read_bootflow_net(bflow);
if (ret)
@@ -378,7 +390,7 @@ int distro_efi_boot(struct udevice *dev, struct bootflow *bflow)
char cmd[50];
/* A non-zero buffer indicates the kernel is there */
- if (bflow->buf) {
+ if (!bootmeth_uses_network(bflow)) {
/* Set the EFI bootdev again, since reading an FDT loses it! */
if (bflow->blk) {
struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);