| 593 | } |
| 594 | |
| 595 | int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle) |
| 596 | { |
| 597 | int offset; |
| 598 | |
| 599 | if ((phandle == 0) || (phandle == -1)) |
| 600 | return -FDT_ERR_BADPHANDLE; |
| 601 | |
| 602 | FDT_CHECK_HEADER(fdt); |
| 603 | |
| 604 | /* FIXME: The algorithm here is pretty horrible: we |
| 605 | * potentially scan each property of a node in |
| 606 | * fdt_get_phandle(), then if that didn't find what |
| 607 | * we want, we scan over them again making our way to the next |
| 608 | * node. Still it's the easiest to implement approach; |
| 609 | * performance can come later. */ |
| 610 | for (offset = fdt_next_node(fdt, -1, NULL); |
| 611 | offset >= 0; |
| 612 | offset = fdt_next_node(fdt, offset, NULL)) { |
| 613 | if (fdt_get_phandle(fdt, offset) == phandle) |
| 614 | return offset; |
| 615 | } |
| 616 | |
| 617 | return offset; /* error from fdt_next_node() */ |
| 618 | } |
| 619 | |
| 620 | int fdt_stringlist_contains(const char *strlist, int listlen, const char *str) |
| 621 | { |
no test coverage detected