Lines Matching +full:parent +full:- +full:child
2 * dev-path-parser.c - EFI Device Path parser
35 if (adev->pnp.unique_id) in match_acpi_dev()
36 return !strcmp(adev->pnp.unique_id, hid_uid.uid); in match_acpi_dev()
42 struct device *parent, struct device **child) in parse_acpi_path() argument
47 if (node->length != 12) in parse_acpi_path()
48 return -EINVAL; in parse_acpi_path()
51 'A' + ((node->acpi.hid >> 10) & 0x1f) - 1, in parse_acpi_path()
52 'A' + ((node->acpi.hid >> 5) & 0x1f) - 1, in parse_acpi_path()
53 'A' + ((node->acpi.hid >> 0) & 0x1f) - 1, in parse_acpi_path()
54 node->acpi.hid >> 16); in parse_acpi_path()
55 sprintf(hid_uid.uid, "%u", node->acpi.uid); in parse_acpi_path()
57 *child = bus_find_device(&acpi_bus_type, NULL, &hid_uid, in parse_acpi_path()
59 if (!*child) in parse_acpi_path()
60 return -ENODEV; in parse_acpi_path()
62 phys_dev = acpi_get_first_physical_node(to_acpi_device(*child)); in parse_acpi_path()
65 put_device(*child); in parse_acpi_path()
66 *child = phys_dev; in parse_acpi_path()
76 return dev_is_pci(dev) && to_pci_dev(dev)->devfn == devfn; in match_pci_dev()
80 struct device *parent, struct device **child) in parse_pci_path() argument
84 if (node->length != 6) in parse_pci_path()
85 return -EINVAL; in parse_pci_path()
86 if (!parent) in parse_pci_path()
87 return -EINVAL; in parse_pci_path()
89 devfn = PCI_DEVFN(node->pci.dev, node->pci.fn); in parse_pci_path()
91 *child = device_find_child(parent, &devfn, match_pci_dev); in parse_pci_path()
92 if (!*child) in parse_pci_path()
93 return -ENODEV; in parse_pci_path()
101 * Each parser takes a pointer to the @node and to the @parent (will be NULL
103 * found below @parent, its reference count should be incremented and the
104 * device returned in @child.
116 struct device *parent, struct device **child) in parse_end_path() argument
118 if (node->length != 4) in parse_end_path()
119 return -EINVAL; in parse_end_path()
120 if (node->sub_type != EFI_DEV_END_INSTANCE && in parse_end_path()
121 node->sub_type != EFI_DEV_END_ENTIRE) in parse_end_path()
122 return -EINVAL; in parse_end_path()
123 if (!parent) in parse_end_path()
124 return -ENODEV; in parse_end_path()
126 *child = get_device(parent); in parse_end_path()
127 return node->sub_type; in parse_end_path()
131 * efi_get_device_by_path - find device by EFI Device Path
162 * %ERR_PTR(-ENODEV) if no device was found,
163 * %ERR_PTR(-EINVAL) if a node is malformed or exceeds @len,
164 * %ERR_PTR(-ENOTSUPP) if support for a node type is not yet implemented.
169 struct device *parent = NULL, *child; in efi_get_device_by_path() local
176 if (*len < 4 || *len < (*node)->length) in efi_get_device_by_path()
177 ret = -EINVAL; in efi_get_device_by_path()
178 else if ((*node)->type == EFI_DEV_ACPI && in efi_get_device_by_path()
179 (*node)->sub_type == EFI_DEV_BASIC_ACPI) in efi_get_device_by_path()
180 ret = parse_acpi_path(*node, parent, &child); in efi_get_device_by_path()
181 else if ((*node)->type == EFI_DEV_HW && in efi_get_device_by_path()
182 (*node)->sub_type == EFI_DEV_PCI) in efi_get_device_by_path()
183 ret = parse_pci_path(*node, parent, &child); in efi_get_device_by_path()
184 else if (((*node)->type == EFI_DEV_END_PATH || in efi_get_device_by_path()
185 (*node)->type == EFI_DEV_END_PATH2)) in efi_get_device_by_path()
186 ret = parse_end_path(*node, parent, &child); in efi_get_device_by_path()
188 ret = -ENOTSUPP; in efi_get_device_by_path()
190 put_device(parent); in efi_get_device_by_path()
194 parent = child; in efi_get_device_by_path()
195 *node = (void *)*node + (*node)->length; in efi_get_device_by_path()
196 *len -= (*node)->length; in efi_get_device_by_path()
202 return child; in efi_get_device_by_path()