Selaa lähdekoodia

[efi] Allow efidev_parent() to traverse multiple device generations

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 vuotta sitten
vanhempi
commit
5cea7bdb2a
1 muutettua tiedostoa jossa 8 lisäystä ja 10 poistoa
  1. 8
    10
      src/interface/efi/efi_driver.c

+ 8
- 10
src/interface/efi/efi_driver.c Näytä tiedosto

@@ -68,18 +68,16 @@ static struct efi_device * efidev_find ( EFI_HANDLE device ) {
68 68
  * @ret efidev		Parent EFI device, or NULL
69 69
  */
70 70
 struct efi_device * efidev_parent ( struct device *dev ) {
71
-	struct device *parent = dev->parent;
72
-	struct efi_device *efidev;
71
+	struct device *parent;
73 72
 
74
-	/* Check that parent exists and is an EFI device */
75
-	if ( ! parent )
76
-		return NULL;
77
-	if ( parent->desc.bus_type != BUS_TYPE_EFI )
78
-		return NULL;
73
+	/* Walk upwards until we find an EFI device */
74
+	while ( ( parent = dev->parent ) ) {
75
+		if ( parent->desc.bus_type == BUS_TYPE_EFI )
76
+			return container_of ( parent, struct efi_device, dev );
77
+		dev = parent;
78
+	}
79 79
 
80
-	/* Get containing EFI device */
81
-	efidev = container_of ( parent, struct efi_device, dev );
82
-	return efidev;
80
+	return NULL;
83 81
 }
84 82
 
85 83
 /**

Loading…
Peruuta
Tallenna