Lines Matching refs:np
58 bool of_node_name_eq(const struct device_node *np, const char *name) in of_node_name_eq() argument
63 if (!np) in of_node_name_eq()
66 node_name = kbasename(np->full_name); in of_node_name_eq()
73 bool of_node_name_prefix(const struct device_node *np, const char *prefix) in of_node_name_prefix() argument
75 if (!np) in of_node_name_prefix()
78 return strncmp(kbasename(np->full_name), prefix, strlen(prefix)) == 0; in of_node_name_prefix()
82 static bool __of_node_is_type(const struct device_node *np, const char *type) in __of_node_is_type() argument
84 const char *match = __of_get_property(np, "device_type", NULL); in __of_node_is_type()
86 return np && match && type && !strcmp(match, type); in __of_node_is_type()
89 int of_bus_n_addr_cells(struct device_node *np) in of_bus_n_addr_cells() argument
93 for (; np; np = np->parent) in of_bus_n_addr_cells()
94 if (!of_property_read_u32(np, "#address-cells", &cells)) in of_bus_n_addr_cells()
101 int of_n_addr_cells(struct device_node *np) in of_n_addr_cells() argument
103 if (np->parent) in of_n_addr_cells()
104 np = np->parent; in of_n_addr_cells()
106 return of_bus_n_addr_cells(np); in of_n_addr_cells()
110 int of_bus_n_size_cells(struct device_node *np) in of_bus_n_size_cells() argument
114 for (; np; np = np->parent) in of_bus_n_size_cells()
115 if (!of_property_read_u32(np, "#size-cells", &cells)) in of_bus_n_size_cells()
122 int of_n_size_cells(struct device_node *np) in of_n_size_cells() argument
124 if (np->parent) in of_n_size_cells()
125 np = np->parent; in of_n_size_cells()
127 return of_bus_n_size_cells(np); in of_n_size_cells()
132 int __weak of_node_to_nid(struct device_node *np) in of_node_to_nid() argument
154 struct device_node *np; in __of_phandle_cache_inv_entry() local
161 np = phandle_cache[handle_hash]; in __of_phandle_cache_inv_entry()
162 if (np && handle == np->phandle) in __of_phandle_cache_inv_entry()
168 struct device_node *np; in of_core_init() local
180 for_each_of_allnodes(np) { in of_core_init()
181 __of_attach_node_sysfs(np); in of_core_init()
182 if (np->phandle && !phandle_cache[of_phandle_cache_hash(np->phandle)]) in of_core_init()
183 phandle_cache[of_phandle_cache_hash(np->phandle)] = np; in of_core_init()
192 static struct property *__of_find_property(const struct device_node *np, in __of_find_property() argument
197 if (!np) in __of_find_property()
200 for (pp = np->properties; pp; pp = pp->next) { in __of_find_property()
211 struct property *of_find_property(const struct device_node *np, in of_find_property() argument
219 pp = __of_find_property(np, name, lenp); in of_find_property()
228 struct device_node *np; in __of_find_all_nodes() local
230 np = of_root; in __of_find_all_nodes()
232 np = prev->child; in __of_find_all_nodes()
235 np = prev; in __of_find_all_nodes()
236 while (np->parent && !np->sibling) in __of_find_all_nodes()
237 np = np->parent; in __of_find_all_nodes()
238 np = np->sibling; /* Might be null at the end of the tree */ in __of_find_all_nodes()
240 return np; in __of_find_all_nodes()
253 struct device_node *np; in of_find_all_nodes() local
257 np = __of_find_all_nodes(prev); in of_find_all_nodes()
258 of_node_get(np); in of_find_all_nodes()
261 return np; in of_find_all_nodes()
269 const void *__of_get_property(const struct device_node *np, in __of_get_property() argument
272 struct property *pp = __of_find_property(np, name, lenp); in __of_get_property()
281 const void *of_get_property(const struct device_node *np, const char *name, in of_get_property() argument
284 struct property *pp = of_find_property(np, name, lenp); in of_get_property()
522 struct device_node *np; in of_get_parent() local
529 np = of_node_get(node->parent); in of_get_parent()
531 return np; in of_get_parent()
778 struct device_node *np = NULL; in of_find_node_opts_by_path() local
804 np = of_find_node_by_path(pp->value); in of_find_node_opts_by_path()
808 if (!np) in of_find_node_opts_by_path()
815 if (!np) in of_find_node_opts_by_path()
816 np = of_node_get(of_root); in of_find_node_opts_by_path()
817 np = __of_find_node_by_full_path(np, path); in of_find_node_opts_by_path()
819 return np; in of_find_node_opts_by_path()
837 struct device_node *np; in of_find_node_by_name() local
841 for_each_of_allnodes_from(from, np) in of_find_node_by_name()
842 if (of_node_name_eq(np, name) && of_node_get(np)) in of_find_node_by_name()
846 return np; in of_find_node_by_name()
865 struct device_node *np; in of_find_node_by_type() local
869 for_each_of_allnodes_from(from, np) in of_find_node_by_type()
870 if (__of_node_is_type(np, type) && of_node_get(np)) in of_find_node_by_type()
874 return np; in of_find_node_by_type()
895 struct device_node *np; in of_find_compatible_node() local
899 for_each_of_allnodes_from(from, np) in of_find_compatible_node()
900 if (__of_device_is_compatible(np, compatible, type, NULL) && in of_find_compatible_node()
901 of_node_get(np)) in of_find_compatible_node()
905 return np; in of_find_compatible_node()
924 struct device_node *np; in of_find_node_with_property() local
929 for_each_of_allnodes_from(from, np) { in of_find_node_with_property()
930 for (pp = np->properties; pp; pp = pp->next) { in of_find_node_with_property()
932 of_node_get(np); in of_find_node_with_property()
940 return np; in of_find_node_with_property()
1003 struct device_node *np; in of_find_matching_node_and_match() local
1011 for_each_of_allnodes_from(from, np) { in of_find_matching_node_and_match()
1012 m = __of_match_node(matches, np); in of_find_matching_node_and_match()
1013 if (m && of_node_get(np)) { in of_find_matching_node_and_match()
1021 return np; in of_find_matching_node_and_match()
1065 struct device_node *np = NULL; in of_find_node_by_phandle() local
1078 np = phandle_cache[handle_hash]; in of_find_node_by_phandle()
1080 if (!np) { in of_find_node_by_phandle()
1081 for_each_of_allnodes(np) in of_find_node_by_phandle()
1082 if (np->phandle == handle && in of_find_node_by_phandle()
1083 !of_node_check_flag(np, OF_DETACHED)) { in of_find_node_by_phandle()
1084 phandle_cache[handle_hash] = np; in of_find_node_by_phandle()
1089 of_node_get(np); in of_find_node_by_phandle()
1091 return np; in of_find_node_by_phandle()
1098 printk("%s %pOF", msg, args->np); in of_print_phandle_args()
1108 const struct device_node *np, in of_phandle_iterator_init() argument
1125 list = of_get_property(np, list_name, &size); in of_phandle_iterator_init()
1131 it->parent = np; in of_phandle_iterator_init()
1242 int __of_parse_phandle_with_args(const struct device_node *np, in __of_parse_phandle_with_args() argument
1255 of_for_each_phandle(&it, rc, np, list_name, cells_name, cell_count) { in __of_parse_phandle_with_args()
1273 out_args->np = it.node; in __of_parse_phandle_with_args()
1340 int of_parse_phandle_with_args_map(const struct device_node *np, in of_parse_phandle_with_args_map() argument
1376 ret = __of_parse_phandle_with_args(np, list_name, cells_name, -1, index, in of_parse_phandle_with_args_map()
1382 cur = out_args->np; in of_parse_phandle_with_args_map()
1465 out_args->np = new; in of_parse_phandle_with_args_map()
1498 int of_count_phandle_with_args(const struct device_node *np, const char *list_name, in of_count_phandle_with_args() argument
1514 list = of_get_property(np, list_name, &size); in of_count_phandle_with_args()
1521 rc = of_phandle_iterator_init(&it, np, list_name, cells_name, -1); in of_count_phandle_with_args()
1554 int __of_add_property(struct device_node *np, struct property *prop) in __of_add_property() argument
1562 __of_remove_property_from_list(&np->deadprops, prop); in __of_add_property()
1565 next = &np->properties; in __of_add_property()
1581 __of_add_property_sysfs(np, prop); in __of_add_property()
1590 int of_add_property(struct device_node *np, struct property *prop) in of_add_property() argument
1595 rc = __of_add_property(np, prop); in of_add_property()
1599 of_property_notify(OF_RECONFIG_ADD_PROPERTY, np, prop, NULL); in of_add_property()
1605 int __of_remove_property(struct device_node *np, struct property *prop) in __of_remove_property() argument
1612 if (__of_remove_property_from_list(&np->properties, prop)) { in __of_remove_property()
1614 prop->next = np->deadprops; in __of_remove_property()
1615 np->deadprops = prop; in __of_remove_property()
1623 __of_remove_property_sysfs(np, prop); in __of_remove_property()
1637 int of_remove_property(struct device_node *np, struct property *prop) in of_remove_property() argument
1645 rc = __of_remove_property(np, prop); in of_remove_property()
1649 of_property_notify(OF_RECONFIG_REMOVE_PROPERTY, np, prop, NULL); in of_remove_property()
1655 int __of_update_property(struct device_node *np, struct property *newprop, in __of_update_property() argument
1663 __of_remove_property_from_list(&np->deadprops, newprop); in __of_update_property()
1665 for (next = &np->properties; *next; next = &(*next)->next) { in __of_update_property()
1675 oldprop->next = np->deadprops; in __of_update_property()
1676 np->deadprops = oldprop; in __of_update_property()
1685 __of_update_property_sysfs(np, newprop, oldprop); in __of_update_property()
1699 int of_update_property(struct device_node *np, struct property *newprop) in of_update_property() argument
1708 rc = __of_update_property(np, newprop, &oldprop); in of_update_property()
1712 of_property_notify(OF_RECONFIG_UPDATE_PROPERTY, np, newprop, oldprop); in of_update_property()
1717 static void of_alias_add(struct alias_prop *ap, struct device_node *np, in of_alias_add() argument
1720 ap->np = np; in of_alias_add()
1725 ap->alias, ap->stem, ap->id, np); in of_alias_add()
1767 struct device_node *np; in of_alias_scan() local
1777 np = of_find_node_by_path(pp->value); in of_alias_scan()
1778 if (!np) in of_alias_scan()
1796 of_alias_add(ap, np, id, start, len); in of_alias_scan()
1810 int of_alias_get_id(struct device_node *np, const char *stem) in of_alias_get_id() argument
1820 if (np == app->np) { in of_alias_get_id()
1889 struct device_node *of_find_next_cache_node(const struct device_node *np) in of_find_next_cache_node() argument
1893 cache_node = of_parse_phandle(np, "l2-cache", 0); in of_find_next_cache_node()
1895 cache_node = of_parse_phandle(np, "next-level-cache", 0); in of_find_next_cache_node()
1903 if (IS_ENABLED(CONFIG_PPC_PMAC) && of_node_is_type(np, "cpu")) in of_find_next_cache_node()
1904 for_each_child_of_node(np, child) in of_find_next_cache_node()
1923 struct device_node *prev = NULL, *np = of_cpu_device_node_get(cpu); in of_find_last_cache_level() local
1925 while (np) { in of_find_last_cache_level()
1927 prev = np; in of_find_last_cache_level()
1928 np = of_find_next_cache_node(np); in of_find_last_cache_level()
1956 int of_map_id(struct device_node *np, u32 id, in of_map_id() argument
1964 if (!np || !map_name || (!target && !id_out)) in of_map_id()
1967 map = of_get_property(np, map_name, &map_len); in of_map_id()
1977 pr_err("%pOF: Error: Bad %s length: %d\n", np, in of_map_id()
1990 of_property_read_u32(np, map_mask_name, &map_mask); in of_map_id()
2002 np, map_name, map_name, in of_map_id()
2028 np, map_name, map_mask, id_base, out_base, in of_map_id()
2033 pr_info("%pOF: no %s translation for id 0x%x on %pOF\n", np, map_name, in of_map_id()