Lines Matching refs:np
59 bool of_node_name_eq(const struct device_node *np, const char *name) in of_node_name_eq() argument
64 if (!np) in of_node_name_eq()
67 node_name = kbasename(np->full_name); in of_node_name_eq()
74 bool of_node_name_prefix(const struct device_node *np, const char *prefix) in of_node_name_prefix() argument
76 if (!np) in of_node_name_prefix()
79 return strncmp(kbasename(np->full_name), prefix, strlen(prefix)) == 0; in of_node_name_prefix()
83 static bool __of_node_is_type(const struct device_node *np, const char *type) in __of_node_is_type() argument
85 const char *match = __of_get_property(np, "device_type", NULL); in __of_node_is_type()
87 return np && match && type && !strcmp(match, type); in __of_node_is_type()
95 int of_bus_n_addr_cells(struct device_node *np) in of_bus_n_addr_cells() argument
99 for (; np; np = np->parent) { in of_bus_n_addr_cells()
100 if (!of_property_read_u32(np, "#address-cells", &cells)) in of_bus_n_addr_cells()
108 "Missing '#address-cells' in %pOF\n", np); in of_bus_n_addr_cells()
113 int of_n_addr_cells(struct device_node *np) in of_n_addr_cells() argument
115 if (np->parent) in of_n_addr_cells()
116 np = np->parent; in of_n_addr_cells()
118 return of_bus_n_addr_cells(np); in of_n_addr_cells()
122 int of_bus_n_size_cells(struct device_node *np) in of_bus_n_size_cells() argument
126 for (; np; np = np->parent) { in of_bus_n_size_cells()
127 if (!of_property_read_u32(np, "#size-cells", &cells)) in of_bus_n_size_cells()
135 "Missing '#size-cells' in %pOF\n", np); in of_bus_n_size_cells()
140 int of_n_size_cells(struct device_node *np) in of_n_size_cells() argument
142 if (np->parent) in of_n_size_cells()
143 np = np->parent; in of_n_size_cells()
145 return of_bus_n_size_cells(np); in of_n_size_cells()
150 int __weak of_node_to_nid(struct device_node *np) in of_node_to_nid() argument
172 struct device_node *np; in __of_phandle_cache_inv_entry() local
179 np = phandle_cache[handle_hash]; in __of_phandle_cache_inv_entry()
180 if (np && handle == np->phandle) in __of_phandle_cache_inv_entry()
186 struct device_node *np; in of_core_init() local
198 for_each_of_allnodes(np) { in of_core_init()
199 __of_attach_node_sysfs(np); in of_core_init()
200 if (np->phandle && !phandle_cache[of_phandle_cache_hash(np->phandle)]) in of_core_init()
201 phandle_cache[of_phandle_cache_hash(np->phandle)] = np; in of_core_init()
210 static struct property *__of_find_property(const struct device_node *np, in __of_find_property() argument
215 if (!np) in __of_find_property()
218 for (pp = np->properties; pp; pp = pp->next) { in __of_find_property()
229 struct property *of_find_property(const struct device_node *np, in of_find_property() argument
237 pp = __of_find_property(np, name, lenp); in of_find_property()
246 struct device_node *np; in __of_find_all_nodes() local
248 np = of_root; in __of_find_all_nodes()
250 np = prev->child; in __of_find_all_nodes()
253 np = prev; in __of_find_all_nodes()
254 while (np->parent && !np->sibling) in __of_find_all_nodes()
255 np = np->parent; in __of_find_all_nodes()
256 np = np->sibling; /* Might be null at the end of the tree */ in __of_find_all_nodes()
258 return np; in __of_find_all_nodes()
271 struct device_node *np; in of_find_all_nodes() local
275 np = __of_find_all_nodes(prev); in of_find_all_nodes()
276 of_node_get(np); in of_find_all_nodes()
279 return np; in of_find_all_nodes()
287 const void *__of_get_property(const struct device_node *np, in __of_get_property() argument
290 const struct property *pp = __of_find_property(np, name, lenp); in __of_get_property()
299 const void *of_get_property(const struct device_node *np, const char *name, in of_get_property() argument
302 const struct property *pp = of_find_property(np, name, lenp); in of_get_property()
616 struct device_node *np; in of_get_parent() local
623 np = of_node_get(node->parent); in of_get_parent()
625 return np; in of_get_parent()
957 struct device_node *np = NULL; in of_find_node_opts_by_path() local
983 np = of_find_node_by_path(pp->value); in of_find_node_opts_by_path()
987 if (!np) in of_find_node_opts_by_path()
994 if (!np) in of_find_node_opts_by_path()
995 np = of_node_get(of_root); in of_find_node_opts_by_path()
996 np = __of_find_node_by_full_path(np, path); in of_find_node_opts_by_path()
998 return np; in of_find_node_opts_by_path()
1016 struct device_node *np; in of_find_node_by_name() local
1020 for_each_of_allnodes_from(from, np) in of_find_node_by_name()
1021 if (of_node_name_eq(np, name) && of_node_get(np)) in of_find_node_by_name()
1025 return np; in of_find_node_by_name()
1044 struct device_node *np; in of_find_node_by_type() local
1048 for_each_of_allnodes_from(from, np) in of_find_node_by_type()
1049 if (__of_node_is_type(np, type) && of_node_get(np)) in of_find_node_by_type()
1053 return np; in of_find_node_by_type()
1074 struct device_node *np; in of_find_compatible_node() local
1078 for_each_of_allnodes_from(from, np) in of_find_compatible_node()
1079 if (__of_device_is_compatible(np, compatible, type, NULL) && in of_find_compatible_node()
1080 of_node_get(np)) in of_find_compatible_node()
1084 return np; in of_find_compatible_node()
1103 struct device_node *np; in of_find_node_with_property() local
1107 for_each_of_allnodes_from(from, np) { in of_find_node_with_property()
1108 if (__of_find_property(np, prop_name, NULL)) { in of_find_node_with_property()
1109 of_node_get(np); in of_find_node_with_property()
1115 return np; in of_find_node_with_property()
1178 struct device_node *np; in of_find_matching_node_and_match() local
1186 for_each_of_allnodes_from(from, np) { in of_find_matching_node_and_match()
1187 m = __of_match_node(matches, np); in of_find_matching_node_and_match()
1188 if (m && of_node_get(np)) { in of_find_matching_node_and_match()
1196 return np; in of_find_matching_node_and_match()
1240 struct device_node *np = NULL; in of_find_node_by_phandle() local
1253 np = phandle_cache[handle_hash]; in of_find_node_by_phandle()
1255 if (!np) { in of_find_node_by_phandle()
1256 for_each_of_allnodes(np) in of_find_node_by_phandle()
1257 if (np->phandle == handle && in of_find_node_by_phandle()
1258 !of_node_check_flag(np, OF_DETACHED)) { in of_find_node_by_phandle()
1259 phandle_cache[handle_hash] = np; in of_find_node_by_phandle()
1264 of_node_get(np); in of_find_node_by_phandle()
1266 return np; in of_find_node_by_phandle()
1273 printk("%s %pOF", msg, args->np); in of_print_phandle_args()
1283 const struct device_node *np, in of_phandle_iterator_init() argument
1300 list = of_get_property(np, list_name, &size); in of_phandle_iterator_init()
1306 it->parent = np; in of_phandle_iterator_init()
1417 int __of_parse_phandle_with_args(const struct device_node *np, in __of_parse_phandle_with_args() argument
1430 of_for_each_phandle(&it, rc, np, list_name, cells_name, cell_count) { in __of_parse_phandle_with_args()
1448 out_args->np = it.node; in __of_parse_phandle_with_args()
1515 int of_parse_phandle_with_args_map(const struct device_node *np, in of_parse_phandle_with_args_map() argument
1539 ret = __of_parse_phandle_with_args(np, list_name, cells_name, -1, index, in of_parse_phandle_with_args_map()
1545 cur = out_args->np; in of_parse_phandle_with_args_map()
1632 out_args->np = new; in of_parse_phandle_with_args_map()
1659 int of_count_phandle_with_args(const struct device_node *np, const char *list_name, in of_count_phandle_with_args() argument
1675 list = of_get_property(np, list_name, &size); in of_count_phandle_with_args()
1682 rc = of_phandle_iterator_init(&it, np, list_name, cells_name, -1); in of_count_phandle_with_args()
1715 int __of_add_property(struct device_node *np, struct property *prop) in __of_add_property() argument
1723 __of_remove_property_from_list(&np->deadprops, prop); in __of_add_property()
1726 next = &np->properties; in __of_add_property()
1742 __of_add_property_sysfs(np, prop); in __of_add_property()
1751 int of_add_property(struct device_node *np, struct property *prop) in of_add_property() argument
1756 rc = __of_add_property(np, prop); in of_add_property()
1760 of_property_notify(OF_RECONFIG_ADD_PROPERTY, np, prop, NULL); in of_add_property()
1766 int __of_remove_property(struct device_node *np, struct property *prop) in __of_remove_property() argument
1773 if (__of_remove_property_from_list(&np->properties, prop)) { in __of_remove_property()
1775 prop->next = np->deadprops; in __of_remove_property()
1776 np->deadprops = prop; in __of_remove_property()
1784 __of_remove_property_sysfs(np, prop); in __of_remove_property()
1798 int of_remove_property(struct device_node *np, struct property *prop) in of_remove_property() argument
1806 rc = __of_remove_property(np, prop); in of_remove_property()
1810 of_property_notify(OF_RECONFIG_REMOVE_PROPERTY, np, prop, NULL); in of_remove_property()
1816 int __of_update_property(struct device_node *np, struct property *newprop, in __of_update_property() argument
1824 __of_remove_property_from_list(&np->deadprops, newprop); in __of_update_property()
1826 for (next = &np->properties; *next; next = &(*next)->next) { in __of_update_property()
1836 oldprop->next = np->deadprops; in __of_update_property()
1837 np->deadprops = oldprop; in __of_update_property()
1846 __of_update_property_sysfs(np, newprop, oldprop); in __of_update_property()
1860 int of_update_property(struct device_node *np, struct property *newprop) in of_update_property() argument
1869 rc = __of_update_property(np, newprop, &oldprop); in of_update_property()
1873 of_property_notify(OF_RECONFIG_UPDATE_PROPERTY, np, newprop, oldprop); in of_update_property()
1878 static void of_alias_add(struct alias_prop *ap, struct device_node *np, in of_alias_add() argument
1881 ap->np = np; in of_alias_add()
1886 ap->alias, ap->stem, ap->id, np); in of_alias_add()
1927 struct device_node *np; in of_alias_scan() local
1935 np = of_find_node_by_path(pp->value); in of_alias_scan()
1936 if (!np) in of_alias_scan()
1946 of_node_put(np); in of_alias_scan()
1953 of_node_put(np); in of_alias_scan()
1958 of_alias_add(ap, np, id, start, len); in of_alias_scan()
1972 int of_alias_get_id(const struct device_node *np, const char *stem) in of_alias_get_id() argument
1982 if (np == app->np) { in of_alias_get_id()
2051 struct device_node *of_find_next_cache_node(const struct device_node *np) in of_find_next_cache_node() argument
2055 cache_node = of_parse_phandle(np, "l2-cache", 0); in of_find_next_cache_node()
2057 cache_node = of_parse_phandle(np, "next-level-cache", 0); in of_find_next_cache_node()
2065 if (IS_ENABLED(CONFIG_PPC_PMAC) && of_node_is_type(np, "cpu")) in of_find_next_cache_node()
2066 for_each_child_of_node(np, child) in of_find_next_cache_node()
2085 struct device_node *prev = NULL, *np = of_cpu_device_node_get(cpu); in of_find_last_cache_level() local
2087 while (np) { in of_find_last_cache_level()
2089 prev = np; in of_find_last_cache_level()
2090 np = of_find_next_cache_node(np); in of_find_last_cache_level()
2118 int of_map_id(const struct device_node *np, u32 id, in of_map_id() argument
2126 if (!np || !map_name || (!target && !id_out)) in of_map_id()
2129 map = of_get_property(np, map_name, &map_len); in of_map_id()
2139 pr_err("%pOF: Error: Bad %s length: %d\n", np, in of_map_id()
2152 of_property_read_u32(np, map_mask_name, &map_mask); in of_map_id()
2164 np, map_name, map_name, in of_map_id()
2190 np, map_name, map_mask, id_base, out_base, in of_map_id()
2195 pr_info("%pOF: no %s translation for id 0x%x on %pOF\n", np, map_name, in of_map_id()