Lines Matching +full:child +full:- +full:node
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()
41 static long __init parse_acpi_path(struct efi_dev_path *node, in parse_acpi_path() argument
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()
79 static long __init parse_pci_path(struct efi_dev_path *node, in parse_pci_path() argument
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()
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()
99 * Insert parsers for further node types here.
101 * Each parser takes a pointer to the @node and to the @parent (will be NULL
102 * for the first device path node). If a device corresponding to @node was
104 * device returned in @child.
111 * Be sure to validate the node length and contents before commencing the
115 static long __init parse_end_path(struct efi_dev_path *node, in parse_end_path() argument
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()
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
132 * @node: EFI Device Path
135 * Parse a series of EFI Device Path nodes at @node and find the corresponding
138 * put_device() after use. The @node pointer is updated to point to the
139 * location immediately after the "End of Hardware Device Path" node.
144 * If a Device Path node is malformed or its corresponding device is not found,
145 * @node is updated to point to this offending node and an ERR_PTR is returned.
150 * while (!IS_ERR_OR_NULL(dev = efi_get_device_by_path(&node, &len))) {
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.
166 struct device * __init efi_get_device_by_path(struct efi_dev_path **node, in efi_get_device_by_path() argument
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()
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()