diff options
author | Michael Brown | 2015-09-07 02:25:41 +0200 |
---|---|---|
committer | Michael Brown | 2015-09-07 02:26:29 +0200 |
commit | 5cea7bdb2af44a5e6b652c302f2761dc8fa1048f (patch) | |
tree | a12c8405b47ad648175d471ac448467c04b23f79 /src/interface/efi/efi_driver.c | |
parent | [efi] Add USB headers and GUID definitions (diff) | |
download | ipxe-5cea7bdb2af44a5e6b652c302f2761dc8fa1048f.tar.gz ipxe-5cea7bdb2af44a5e6b652c302f2761dc8fa1048f.tar.xz ipxe-5cea7bdb2af44a5e6b652c302f2761dc8fa1048f.zip |
[efi] Allow efidev_parent() to traverse multiple device generations
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/efi/efi_driver.c')
-rw-r--r-- | src/interface/efi/efi_driver.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index 2a59257b..b59362c6 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -68,18 +68,16 @@ static struct efi_device * efidev_find ( EFI_HANDLE device ) { * @ret efidev Parent EFI device, or NULL */ struct efi_device * efidev_parent ( struct device *dev ) { - struct device *parent = dev->parent; - struct efi_device *efidev; + struct device *parent; - /* Check that parent exists and is an EFI device */ - if ( ! parent ) - return NULL; - if ( parent->desc.bus_type != BUS_TYPE_EFI ) - return NULL; + /* Walk upwards until we find an EFI device */ + while ( ( parent = dev->parent ) ) { + if ( parent->desc.bus_type == BUS_TYPE_EFI ) + return container_of ( parent, struct efi_device, dev ); + dev = parent; + } - /* Get containing EFI device */ - efidev = container_of ( parent, struct efi_device, dev ); - return efidev; + return NULL; } /** |