]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Allow efidev_parent() to traverse multiple device generations
authorMichael Brown <mcb30@ipxe.org>
Mon, 7 Sep 2015 00:25:41 +0000 (01:25 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 7 Sep 2015 00:26:29 +0000 (01:26 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/interface/efi/efi_driver.c

index 2a59257b868b53b235d21e5c351a645a00a55110..b59362c64068a1f9afc68d4ab066f96d7d810ba1 100644 (file)
@@ -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;
 }
 
 /**