Browse Source

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
5cea7bdb2a
1 changed files with 8 additions and 10 deletions
  1. 8
    10
      src/interface/efi/efi_driver.c

+ 8
- 10
src/interface/efi/efi_driver.c View File

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

Loading…
Cancel
Save