Lines Matching refs:np

133     struct rt_ofw_node *np;  in ofw_get_next_node()  local
166 np = ofw_node_root; in ofw_get_next_node()
170 np = prev->child; in ofw_get_next_node()
174 np = prev; in ofw_get_next_node()
176 while (np->parent && !np->sibling) in ofw_get_next_node()
178 np = np->parent; in ofw_get_next_node()
181 np = np->sibling; in ofw_get_next_node()
184 return np; in ofw_get_next_node()
187 static void ofw_node_destroy(struct rt_ofw_node *np) in ofw_node_destroy() argument
191 if (np->parent) in ofw_node_destroy()
194 prev = np->parent->child; in ofw_node_destroy()
196 if (prev == np) in ofw_node_destroy()
198 np->parent->child = RT_NULL; in ofw_node_destroy()
202 while (prev->sibling != np) in ofw_node_destroy()
207 prev->sibling = np->sibling; in ofw_node_destroy()
211 while (np) in ofw_node_destroy()
213 if (rt_ofw_node_test_flag(np, RT_OFW_F_SYSTEM) == RT_FALSE) in ofw_node_destroy()
215 LOG_E("%s is system node", np->full_name); in ofw_node_destroy()
219 prev = np; in ofw_node_destroy()
221 np = ofw_get_next_node(np); in ofw_node_destroy()
228 rt_err_t rt_ofw_node_destroy(struct rt_ofw_node *np) in rt_ofw_node_destroy() argument
232 if (np) in rt_ofw_node_destroy()
234 if (rt_ref_read(&np->ref) <= 1) in rt_ofw_node_destroy()
236 ofw_node_destroy(np); in rt_ofw_node_destroy()
251 struct rt_ofw_node *rt_ofw_node_get(struct rt_ofw_node *np) in rt_ofw_node_get() argument
253 if (np) in rt_ofw_node_get()
255 LOG_D("%s get ref = %d", np->full_name, rt_ref_read(&np->ref)); in rt_ofw_node_get()
256 rt_ref_get(&np->ref); in rt_ofw_node_get()
259 return np; in rt_ofw_node_get()
264 struct rt_ofw_node *np = rt_container_of(r, struct rt_ofw_node, ref); in ofw_node_release() local
266 LOG_E("%s is release", np->full_name); in ofw_node_release()
267 (void)np; in ofw_node_release()
272 void rt_ofw_node_put(struct rt_ofw_node *np) in rt_ofw_node_put() argument
274 if (np) in rt_ofw_node_put()
276 LOG_D("%s put ref = %d", np->full_name, rt_ref_read(&np->ref)); in rt_ofw_node_put()
277 rt_ref_put(&np->ref, &ofw_node_release); in rt_ofw_node_put()
281 rt_bool_t rt_ofw_node_tag_equ(const struct rt_ofw_node *np, const char *tag) in rt_ofw_node_tag_equ() argument
285 if (np && tag) in rt_ofw_node_tag_equ()
287 const char *node_name = rt_fdt_node_name(np->full_name); in rt_ofw_node_tag_equ()
296 rt_bool_t rt_ofw_node_tag_prefix(const struct rt_ofw_node *np, const char *prefix) in rt_ofw_node_tag_prefix() argument
300 if (np && prefix) in rt_ofw_node_tag_prefix()
302 ret = !rt_strncmp(rt_fdt_node_name(np->full_name), prefix, rt_strlen(prefix)); in rt_ofw_node_tag_prefix()
344 static int ofw_node_index_of_compatible(const struct rt_ofw_node *np, const char *compatible) in ofw_node_index_of_compatible() argument
347 struct rt_ofw_prop *prop = rt_ofw_get_prop(np, "compatible", RT_NULL); in ofw_node_index_of_compatible()
392 static rt_bool_t ofw_node_is_fail(const struct rt_ofw_node *np) in ofw_node_is_fail() argument
395 const char *status = rt_ofw_prop_read_raw(np, "status", RT_NULL); in ofw_node_is_fail()
405 static rt_bool_t ofw_node_is_available(const struct rt_ofw_node *np) in ofw_node_is_available() argument
408 const char *status = rt_ofw_prop_read_raw(np, "status", RT_NULL); in ofw_node_is_available()
418 rt_bool_t rt_ofw_node_is_available(const struct rt_ofw_node *np) in rt_ofw_node_is_available() argument
420 return np ? ofw_node_is_available(np) : RT_FALSE; in rt_ofw_node_is_available()
423 rt_bool_t rt_ofw_node_is_compatible(const struct rt_ofw_node *np, const char *compatible) in rt_ofw_node_is_compatible() argument
427 if (np) in rt_ofw_node_is_compatible()
429 res = ofw_node_index_of_compatible(np, compatible) >= 0; in rt_ofw_node_is_compatible()
466 struct rt_ofw_node_id *rt_ofw_node_match(struct rt_ofw_node *np, const struct rt_ofw_node_id *ids) in rt_ofw_node_match() argument
471 if (np && ids && (prop = rt_ofw_get_prop(np, "compatible", RT_NULL))) in rt_ofw_node_match()
481 struct rt_ofw_node *np = RT_NULL; in rt_ofw_find_node_by_tag() local
485 rt_ofw_foreach_nodes(from, np) in rt_ofw_find_node_by_tag()
487 if (rt_ofw_node_tag_equ(np, tag)) in rt_ofw_find_node_by_tag()
494 return np; in rt_ofw_find_node_by_tag()
500 struct rt_ofw_node *np = RT_NULL; in rt_ofw_find_node_by_prop_r() local
504 rt_ofw_foreach_nodes(from, np) in rt_ofw_find_node_by_prop_r()
506 struct rt_ofw_prop *prop = rt_ofw_get_prop(np, propname, RT_NULL); in rt_ofw_find_node_by_prop_r()
520 return np; in rt_ofw_find_node_by_prop_r()
525 struct rt_ofw_node *np = RT_NULL; in rt_ofw_find_node_by_name() local
529 rt_ofw_foreach_nodes(from, np) in rt_ofw_find_node_by_name()
531 if (np->name && !rt_strcmp(np->name, name)) in rt_ofw_find_node_by_name()
533 np = rt_ofw_node_get(np); in rt_ofw_find_node_by_name()
539 return np; in rt_ofw_find_node_by_name()
544 struct rt_ofw_node *np = RT_NULL; in rt_ofw_find_node_by_type() local
548 rt_ofw_foreach_nodes(from, np) in rt_ofw_find_node_by_type()
550 if (rt_ofw_node_is_type(np, type)) in rt_ofw_find_node_by_type()
557 return np; in rt_ofw_find_node_by_type()
562 struct rt_ofw_node *np = RT_NULL; in rt_ofw_find_node_by_compatible() local
566 rt_ofw_foreach_nodes(from, np) in rt_ofw_find_node_by_compatible()
568 if (ofw_node_index_of_compatible(np, compatible) >= 0) in rt_ofw_find_node_by_compatible()
575 return np; in rt_ofw_find_node_by_compatible()
581 struct rt_ofw_node *np = RT_NULL; in rt_ofw_find_node_by_ids_r() local
585 rt_ofw_foreach_nodes(from, np) in rt_ofw_find_node_by_ids_r()
587 struct rt_ofw_node_id *id = rt_ofw_node_match(np, ids); in rt_ofw_find_node_by_ids_r()
601 return np; in rt_ofw_find_node_by_ids_r()
606 struct rt_ofw_node *np = RT_NULL, *parent, *tmp = RT_NULL; in rt_ofw_find_node_by_path() local
612 np = ofw_node_root; in rt_ofw_find_node_by_path()
626 rt_ofw_foreach_child_node(parent, np) in rt_ofw_find_node_by_path()
628 if (!rt_strncmp(np->full_name, path, len)) in rt_ofw_find_node_by_path()
632 parent = np; in rt_ofw_find_node_by_path()
633 tmp = np; in rt_ofw_find_node_by_path()
649 np = tmp; in rt_ofw_find_node_by_path()
652 rt_ofw_node_get(np); in rt_ofw_find_node_by_path()
655 return np; in rt_ofw_find_node_by_path()
660 struct rt_ofw_node *np = RT_NULL; in rt_ofw_find_node_by_phandle() local
667 np = _phandle_hash[poff]; in rt_ofw_find_node_by_phandle()
669 if (!np) in rt_ofw_find_node_by_phandle()
671 rt_ofw_foreach_allnodes(np) in rt_ofw_find_node_by_phandle()
673 if (np->phandle == phandle) in rt_ofw_find_node_by_phandle()
675 _phandle_hash[poff] = np; in rt_ofw_find_node_by_phandle()
683 rt_ofw_node_get(np); in rt_ofw_find_node_by_phandle()
687 return np; in rt_ofw_find_node_by_phandle()
690 struct rt_ofw_node *rt_ofw_get_parent(const struct rt_ofw_node *np) in rt_ofw_get_parent() argument
692 if (np) in rt_ofw_get_parent()
694 np = rt_ofw_node_get(np->parent); in rt_ofw_get_parent()
697 return (struct rt_ofw_node *)np; in rt_ofw_get_parent()
736 int rt_ofw_get_child_count(const struct rt_ofw_node *np) in rt_ofw_get_child_count() argument
740 if (np) in rt_ofw_get_child_count()
746 rt_ofw_foreach_child_node(np, child) in rt_ofw_get_child_count()
759 int rt_ofw_get_available_child_count(const struct rt_ofw_node *np) in rt_ofw_get_available_child_count() argument
763 if (np) in rt_ofw_get_available_child_count()
769 rt_ofw_foreach_available_child_node(np, child) in rt_ofw_get_available_child_count()
784 struct rt_ofw_node *np; in rt_ofw_get_next_node() local
786 np = rt_ofw_node_get(ofw_get_next_node(prev)); in rt_ofw_get_next_node()
789 return np; in rt_ofw_get_next_node()
959 struct rt_ofw_node *np = RT_NULL, *state_np; in rt_ofw_get_cpu_state_node() local
970 np = state_np; in rt_ofw_get_cpu_state_node()
974 if (!np) in rt_ofw_get_cpu_state_node()
985 np = rt_ofw_find_node_by_phandle((rt_phandle)phandle); in rt_ofw_get_cpu_state_node()
994 return np; in rt_ofw_get_cpu_state_node()
1004 struct rt_ofw_node *np = ofw_node_cpus->child; in rt_ofw_get_cpu_id() local
1006 for (; np; np = np->sibling) in rt_ofw_get_cpu_id()
1013 if (cpu_np == np) in rt_ofw_get_cpu_id()
1048 struct rt_ofw_node *np = ofw_node_aliases, *tmp; in ofw_alias_scan() local
1050 rt_ofw_foreach_prop(np, prop) in ofw_alias_scan()
1096 info->np = tmp; in ofw_alias_scan()
1107 struct rt_ofw_node *np = RT_NULL; in rt_ofw_get_alias_node() local
1122 np = info->np; in rt_ofw_get_alias_node()
1129 return np; in rt_ofw_get_alias_node()
1132 int ofw_alias_node_id(struct rt_ofw_node *np) in ofw_alias_node_id() argument
1137 if (np) in ofw_alias_node_id()
1144 if (info->np == np) in ofw_alias_node_id()
1160 int rt_ofw_get_alias_id(struct rt_ofw_node *np, const char *tag) in rt_ofw_get_alias_id() argument
1165 if (np && tag) in rt_ofw_get_alias_id()
1177 if (info->np == np) in rt_ofw_get_alias_id()
1225 static rt_err_t ofw_map_id(struct rt_ofw_node *np, rt_uint32_t id, const char *map_name, const char… in ofw_map_id() argument
1236 rt_ofw_prop_read_u32(np, map_mask_name, &map_mask); in ofw_map_id()
1252 np->full_name, map_name, map_mask_name, map_mask, id_base); in ofw_map_id()
1294 np->full_name, map_name, map_mask_name, map_mask, in ofw_map_id()
1302 LOG_I("%s: No %s translation for id(0x%x) on %s", np->full_name, map_name, in ofw_map_id()
1315 rt_err_t rt_ofw_map_id(struct rt_ofw_node *np, rt_uint32_t id, const char *map_name, const char *ma… in rt_ofw_map_id() argument
1320 if (np && map_name && (ref_np || out_id)) in rt_ofw_map_id()
1323 const fdt32_t *map = rt_ofw_prop_read_raw(np, map_name, &map_len); in rt_ofw_map_id()
1340 LOG_E("%s: Invalid %s length = %u", np->full_name, map_name, map_len); in rt_ofw_map_id()
1346 err = ofw_map_id(np, id, map_name, map_mask_name, map, map_len, ref_np, out_id); in rt_ofw_map_id()
1362 struct rt_ofw_node *np = RT_NULL, *child; in rt_ofw_append_child() local
1368 np = rt_calloc(1, sizeof(*np) + sizeof(*phandle_value)); in rt_ofw_append_child()
1372 if (np) in rt_ofw_append_child()
1376 np->full_name = full_name; in rt_ofw_append_child()
1377 np->phandle = phandle; in rt_ofw_append_child()
1378 np->parent = parent; in rt_ofw_append_child()
1380 rt_ref_init(&np->ref); in rt_ofw_append_child()
1382 phandle_value = (void *)np + sizeof(*np); in rt_ofw_append_child()
1385 err = rt_ofw_append_prop(np, "phandle", sizeof(*phandle_value), phandle_value); in rt_ofw_append_child()
1395 child->sibling = np; in rt_ofw_append_child()
1403 parent->child = np; in rt_ofw_append_child()
1408 rt_free(np); in rt_ofw_append_child()
1409 np = RT_NULL; in rt_ofw_append_child()
1413 return rt_ofw_node_get(np); in rt_ofw_append_child()
1416 rt_err_t rt_ofw_append_prop(struct rt_ofw_node *np, const char *name, int length, void *value) in rt_ofw_append_prop() argument
1420 if (np && name && ((length && value) || (!length && !value))) in rt_ofw_append_prop()
1431 if (np->props) in rt_ofw_append_prop()
1433 rt_ofw_foreach_prop(np, last_prop) in rt_ofw_append_prop()
1444 np->props = prop; in rt_ofw_append_prop()
1460 struct rt_ofw_node *rt_ofw_parse_phandle(const struct rt_ofw_node *np, const char *phandle_name, in… in rt_ofw_parse_phandle() argument
1465 if (!rt_ofw_parse_phandle_cells(np, phandle_name, RT_NULL, index, &args)) in rt_ofw_parse_phandle()
1473 static rt_err_t ofw_parse_phandle_cells(const struct rt_ofw_node *np, const char *list_name, const … in ofw_parse_phandle_cells() argument
1512 rt_ofw_foreach_prop_u32(np, list_name, prop, cell, value) in ofw_parse_phandle_cells()
1549 rt_err_t rt_ofw_parse_phandle_cells(const struct rt_ofw_node *np, const char *list_name, const char… in rt_ofw_parse_phandle_cells() argument
1554 if (np && list_name && index >= 0 && out_args) in rt_ofw_parse_phandle_cells()
1556 err = ofw_parse_phandle_cells(np, list_name, cells_name, index, out_args); in rt_ofw_parse_phandle_cells()
1566 int rt_ofw_count_phandle_cells(const struct rt_ofw_node *np, const char *list_name, const char *cel… in rt_ofw_count_phandle_cells() argument
1570 if (np && list_name) in rt_ofw_count_phandle_cells()
1578 if (rt_ofw_get_prop(np, list_name, &length)) in rt_ofw_count_phandle_cells()
1588 while (!ofw_parse_phandle_cells(np, list_name, cells_name, index, &args)) in rt_ofw_count_phandle_cells()
1603 static const char *ofw_get_prop_fuzzy_name(const struct rt_ofw_node *np, const char *name) in ofw_get_prop_fuzzy_name() argument
1678 …LOG_W("%s fuzzy name = %s len is %d out of %d", np->full_name, name, rt_strlen(name), sizeof(split… in ofw_get_prop_fuzzy_name()
1681 rt_ofw_foreach_prop(np, prop) in ofw_get_prop_fuzzy_name()
1754 const char *rt_ofw_get_prop_fuzzy_name(const struct rt_ofw_node *np, const char *name) in rt_ofw_get_prop_fuzzy_name() argument
1758 if (np && name) in rt_ofw_get_prop_fuzzy_name()
1760 propname = ofw_get_prop_fuzzy_name(np, name); in rt_ofw_get_prop_fuzzy_name()
1767 struct rt_ofw_prop *rt_ofw_get_prop(const struct rt_ofw_node *np, const char *name, rt_ssize_t *out… in rt_ofw_get_prop() argument
1771 if (np && name) in rt_ofw_get_prop()
1773 rt_ofw_foreach_prop(np, prop) in rt_ofw_get_prop()
1792 const struct rt_ofw_node *np, const char *propname, \
1796 if (np && propname && index >= 0 && nr >= 0 && out_values) \
1800 elm = rt_ofw_prop_read_raw(np, propname, &len); \
1831 int rt_ofw_prop_read_string_array_index(const struct rt_ofw_node *np, const char *propname, in rt_ofw_prop_read_string_array_index() argument
1836 if (np && propname && index >= 0 && nr >= 0 && out_strings) in rt_ofw_prop_read_string_array_index()
1839 const char *value = rt_ofw_prop_read_raw(np, propname, &len); in rt_ofw_prop_read_string_array_index()
1874 int rt_ofw_prop_count_of_size(const struct rt_ofw_node *np, const char *propname, int size) in rt_ofw_prop_count_of_size() argument
1878 if (np && propname && size > 0) in rt_ofw_prop_count_of_size()
1884 if (rt_ofw_get_prop(np, propname, &len)) in rt_ofw_prop_count_of_size()
1902 int rt_ofw_prop_index_of_string(const struct rt_ofw_node *np, const char *propname, const char *str… in rt_ofw_prop_index_of_string() argument
1906 if (np && propname && string) in rt_ofw_prop_index_of_string()
1908 struct rt_ofw_prop *prop = rt_ofw_get_prop(np, propname, RT_NULL); in rt_ofw_prop_index_of_string()