| 602 | } |
| 603 | |
| 604 | struct rt_ofw_node *rt_ofw_find_node_by_path(const char *path) |
| 605 | { |
| 606 | struct rt_ofw_node *np = RT_NULL, *parent, *tmp = RT_NULL; |
| 607 | |
| 608 | if (path) |
| 609 | { |
| 610 | if (!rt_strcmp(path, "/")) |
| 611 | { |
| 612 | np = ofw_node_root; |
| 613 | } |
| 614 | else |
| 615 | { |
| 616 | ++path; |
| 617 | parent = rt_ofw_node_get(ofw_node_root); |
| 618 | |
| 619 | while (*path) |
| 620 | { |
| 621 | const char *next = strchrnul(path, '/'); |
| 622 | rt_size_t len = next - path; |
| 623 | |
| 624 | tmp = RT_NULL; |
| 625 | |
| 626 | rt_ofw_foreach_child_node(parent, np) |
| 627 | { |
| 628 | if (!rt_strncmp(np->full_name, path, len)) |
| 629 | { |
| 630 | rt_ofw_node_put(parent); |
| 631 | |
| 632 | parent = np; |
| 633 | tmp = np; |
| 634 | |
| 635 | break; |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | if (!tmp) |
| 640 | { |
| 641 | rt_ofw_node_put(parent); |
| 642 | |
| 643 | break; |
| 644 | } |
| 645 | |
| 646 | path += len + !!*next; |
| 647 | } |
| 648 | |
| 649 | np = tmp; |
| 650 | } |
| 651 | |
| 652 | rt_ofw_node_get(np); |
| 653 | } |
| 654 | |
| 655 | return np; |
| 656 | } |
| 657 | |
| 658 | struct rt_ofw_node *rt_ofw_find_node_by_phandle(rt_phandle phandle) |
| 659 | { |
no test coverage detected