-/* $OpenBSD: fdt.c,v 1.34 2023/04/26 14:39:42 kettenis Exp $ */
+/* $OpenBSD: fdt.c,v 1.35 2024/03/27 23:05:27 kettenis Exp $ */
/*
* Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net>
while (*p) {
void *child;
const char *q;
+ const char *s;
while (*p == '/')
p++;
if (q == NULL)
q = p + strlen(p);
+ /* Check for a complete match. */
for (child = fdt_child_node(node); child;
child = fdt_next_node(child)) {
- if (strncmp(p, fdt_node_name(child), q - p) == 0) {
- node = child;
+ s = fdt_node_name(child);
+ if (strncmp(p, s, q - p) == 0 && s[q - p] == '\0')
break;
- }
+ }
+ if (child) {
+ node = child;
+ p = q;
+ continue;
}
- if (child == NULL)
- return NULL; /* No match found. */
+ /* Check for a match without the unit name. */
+ for (child = fdt_child_node(node); child;
+ child = fdt_next_node(child)) {
+ s = fdt_node_name(child);
+ if (strncmp(p, s, q - p) == 0 && s[q - p] == '@')
+ break;
+ }
+ if (child) {
+ node = child;
+ p = q;
+ continue;
+ }
- p = q;
+ return NULL; /* No match found. */
}
return node;