MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_ofw_find_node_by_path

Function rt_ofw_find_node_by_path

components/drivers/ofw/base.c:604–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602}
603
604struct 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
658struct rt_ofw_node *rt_ofw_find_node_by_phandle(rt_phandle phandle)
659{

Callers 6

rt_ofw_console_setupFunction · 0.85
ofw_dtsFunction · 0.85
rt_fdt_unflattenFunction · 0.85
ofw_alias_scanFunction · 0.85
thermal_ofw_setupFunction · 0.85

Calls 5

rt_strcmpFunction · 0.85
rt_ofw_node_getFunction · 0.85
strchrnulFunction · 0.85
rt_strncmpFunction · 0.85
rt_ofw_node_putFunction · 0.85

Tested by

no test coverage detected