Lines Matching +full:a +full:- +full:child +full:- +full:node +full:- +full:property
1 // SPDX-License-Identifier: GPL-2.0+
6 * Copyright (C) 1996-2005 Paul Mackerras.
54 /* use when traversing tree through the child, sibling,
67 node_name = kbasename(np->full_name); in of_node_name_eq()
68 len = strchrnul(node_name, '@') - node_name; in of_node_name_eq()
79 return strncmp(kbasename(np->full_name), prefix, strlen(prefix)) == 0; in of_node_name_prefix()
94 for (; np; np = np->parent) in of_bus_n_addr_cells()
95 if (!of_property_read_u32(np, "#address-cells", &cells)) in of_bus_n_addr_cells()
98 /* No #address-cells property for the root node */ in of_bus_n_addr_cells()
104 if (np->parent) in of_n_addr_cells()
105 np = np->parent; in of_n_addr_cells()
115 for (; np; np = np->parent) in of_bus_n_size_cells()
116 if (!of_property_read_u32(np, "#size-cells", &cells)) in of_bus_n_size_cells()
119 /* No #size-cells property for the root node */ in of_bus_n_size_cells()
125 if (np->parent) in of_n_size_cells()
126 np = np->parent; in of_n_size_cells()
163 if (np && handle == np->phandle) in __of_phandle_cache_inv_entry()
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()
189 proc_symlink("device-tree", NULL, "/sys/firmware/devicetree/base"); in of_core_init()
192 static struct property *__of_find_property(const struct device_node *np, in __of_find_property()
195 struct property *pp; in __of_find_property()
200 for (pp = np->properties; pp; pp = pp->next) { in __of_find_property()
201 if (of_prop_cmp(pp->name, name) == 0) { in __of_find_property()
203 *lenp = pp->length; in __of_find_property()
211 struct property *of_find_property(const struct device_node *np, in of_find_property()
215 struct property *pp; in of_find_property()
231 } else if (prev->child) { in __of_find_all_nodes()
232 np = prev->child; in __of_find_all_nodes()
234 /* Walk back up looking for a sibling, or the end of the structure */ 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()
244 * of_find_all_nodes - Get next node in global list
245 * @prev: Previous node or NULL to start iteration
248 * Return: A node pointer with refcount incremented, use
266 * Find a property with a given name for a given node
272 struct property *pp = __of_find_property(np, name, lenp); in __of_get_property()
274 return pp ? pp->value : NULL; in __of_get_property()
278 * Find a property with a given name for a given node
284 struct property *pp = of_find_property(np, name, lenp); in of_get_property()
286 return pp ? pp->value : NULL; in of_get_property()
291 * arch_match_cpu_phys_id - Match the given logical CPU and physical id
293 * @cpu: logical cpu index of a core/thread
294 * @phys_id: physical identifier of a core/thread
297 * However this __weak function provides a default match of physical
310 * Checks if the given "prop_name" property holds the physical id of the
341 * arch_find_n_match_cpu_physical_id - See if the given device node is
343 * else false. If 'thread' is non-NULL, the local thread number within the
349 /* Check for non-standard "ibm,ppc-interrupt-server#s" property in arch_find_n_match_cpu_physical_id()
351 * standard "reg" property. in arch_find_n_match_cpu_physical_id()
355 "ibm,ppc-interrupt-server#s", in arch_find_n_match_cpu_physical_id()
363 * of_get_cpu_node - Get device node associated with the given logical CPU
365 * @cpu: CPU number(logical index) for which device node is required
369 * The main purpose of this function is to retrieve the device node for the
378 * Return: A node pointer for the logical cpu with refcount incremented, use
394 * of_cpu_node_to_id: Get the logical CPU number for a given device_node
398 * Return: The logical CPU number of the given CPU device_node or -ENODEV if the
415 return -ENODEV; in of_cpu_node_to_id()
420 * of_get_cpu_state_node - Get CPU's idle state node at the given index
422 * @cpu_node: The device node for the CPU
425 * Two generic methods can be used to describe a CPU's idle states, either via
426 * a flattened description through the "cpu-idle-states" binding or via the
427 * hierarchical layout, using the "power-domains" and the "domain-idle-states"
428 * bindings. This function check for both and returns the idle state node for
431 * Return: An idle state node if found at @index. The refcount is incremented
440 err = of_parse_phandle_with_args(cpu_node, "power-domains", in of_get_cpu_state_node()
441 "#power-domain-cells", 0, &args); in of_get_cpu_state_node()
444 of_parse_phandle(args.np, "domain-idle-states", index); in of_get_cpu_state_node()
451 return of_parse_phandle(cpu_node, "cpu-idle-states", index); in of_get_cpu_state_node()
456 * __of_device_is_compatible() - Check if the node matches given constraints
457 * @device: pointer to node
460 * @name: required node name, NULL or "" for any match
463 * properties of the given @device. A constraints can be skipped by
466 * Returns 0 for no match, and a positive integer on match. The return
467 * value is a relative score with larger values indicating better
488 struct property *prop; in __of_device_is_compatible()
498 score = INT_MAX/2 - (index << 2); in __of_device_is_compatible()
513 /* Matching name is a bit better than not */ in __of_device_is_compatible()
524 * the device's "compatible" property
540 * a NULL terminated array of strings. Returns the best match
562 * of_machine_is_compatible - Test root of device tree for a given compatible value
563 * @compat: compatible string to look for in root node's compatible property.
565 * Return: A positive integer if the root node has the given value in its
566 * compatible property.
583 * __of_device_is_available - check if a device is available for use
585 * @device: Node to check for availability, with locks already held
587 * Return: True if the status property is absent or set to "okay" or "ok",
611 * of_device_is_available - check if a device is available for use
613 * @device: Node to check for availability
615 * Return: True if the status property is absent or set to "okay" or "ok",
632 * of_device_is_big_endian - check if a device has BE registers
634 * @device: Node to check for endianness
636 * Return: True if the device has a "big-endian" property, or if the kernel
637 * was compiled for BE *and* the device has a "native-endian" property.
645 if (of_property_read_bool(device, "big-endian")) in of_device_is_big_endian()
648 of_property_read_bool(device, "native-endian")) in of_device_is_big_endian()
655 * of_get_parent - Get a node's parent if any
656 * @node: Node to get parent
658 * Return: A node pointer with refcount incremented, use
661 struct device_node *of_get_parent(const struct device_node *node) in of_get_parent() argument
666 if (!node) in of_get_parent()
670 np = of_node_get(node->parent); in of_get_parent()
677 * of_get_next_parent - Iterate to a node's parent
678 * @node: Node to get parent of
681 * refcount on the passed node, making it suitable for iterating
682 * through a node's parents.
684 * Return: A node pointer with refcount incremented, use
687 struct device_node *of_get_next_parent(struct device_node *node) in of_get_next_parent() argument
692 if (!node) in of_get_next_parent()
696 parent = of_node_get(node->parent); in of_get_next_parent()
697 of_node_put(node); in of_get_next_parent()
703 static struct device_node *__of_get_next_child(const struct device_node *node, in __of_get_next_child() argument
708 if (!node) in __of_get_next_child()
711 next = prev ? prev->sibling : node->child; in __of_get_next_child()
716 #define __for_each_child_of_node(parent, child) \ argument
717 for (child = __of_get_next_child(parent, NULL); child != NULL; \
718 child = __of_get_next_child(parent, child))
721 * of_get_next_child - Iterate a node childs
722 * @node: parent node
723 * @prev: previous child of the parent node, or NULL to get first
725 * Return: A node pointer with refcount incremented, use of_node_put() on
726 * it when done. Returns NULL when prev is the last child. Decrements the
729 struct device_node *of_get_next_child(const struct device_node *node, in of_get_next_child() argument
736 next = __of_get_next_child(node, prev); in of_get_next_child()
743 * of_get_next_available_child - Find the next available child node
744 * @node: parent node
745 * @prev: previous child of the parent node, or NULL to get first
750 struct device_node *of_get_next_available_child(const struct device_node *node, in of_get_next_available_child() argument
756 if (!node) in of_get_next_available_child()
760 next = prev ? prev->sibling : node->child; in of_get_next_available_child()
761 for (; next; next = next->sibling) { in of_get_next_available_child()
774 * of_get_next_cpu_node - Iterate on cpu nodes
775 * @prev: previous child of the /cpus node, or NULL to get first
777 * Return: A cpu node pointer with refcount incremented, use of_node_put()
778 * on it when done. Returns NULL when prev is the last child. Decrements
785 struct device_node *node; in of_get_next_cpu_node() local
788 node = of_find_node_by_path("/cpus"); in of_get_next_cpu_node()
792 next = prev->sibling; in of_get_next_cpu_node()
793 else if (node) { in of_get_next_cpu_node()
794 next = node->child; in of_get_next_cpu_node()
795 of_node_put(node); in of_get_next_cpu_node()
797 for (; next; next = next->sibling) { in of_get_next_cpu_node()
811 * of_get_compatible_child - Find compatible child node
812 * @parent: parent node
815 * Lookup child node whose compatible property contains the given compatible
818 * Return: a node pointer with refcount incremented, use of_node_put() on it
824 struct device_node *child; in of_get_compatible_child() local
826 for_each_child_of_node(parent, child) { in of_get_compatible_child()
827 if (of_device_is_compatible(child, compatible)) in of_get_compatible_child()
831 return child; in of_get_compatible_child()
836 * of_get_child_by_name - Find the child node by name for a given parent
837 * @node: parent node
838 * @name: child name to look for.
840 * This function looks for child node for given matching name
842 * Return: A node pointer if found, with refcount incremented, use
844 * Returns NULL if node is not found.
846 struct device_node *of_get_child_by_name(const struct device_node *node, in of_get_child_by_name() argument
849 struct device_node *child; in of_get_child_by_name() local
851 for_each_child_of_node(node, child) in of_get_child_by_name()
852 if (of_node_name_eq(child, name)) in of_get_child_by_name()
854 return child; in of_get_child_by_name()
861 struct device_node *child; in __of_find_node_by_path() local
868 __for_each_child_of_node(parent, child) { in __of_find_node_by_path()
869 const char *name = kbasename(child->full_name); in __of_find_node_by_path()
871 return child; in __of_find_node_by_path()
876 struct device_node *__of_find_node_by_full_path(struct device_node *node, in __of_find_node_by_full_path() argument
881 while (node && *path == '/') { in __of_find_node_by_full_path()
882 struct device_node *tmp = node; in __of_find_node_by_full_path()
885 node = __of_find_node_by_path(node, path); in __of_find_node_by_full_path()
891 return node; in __of_find_node_by_full_path()
895 * of_find_node_opts_by_path - Find a node matching a full OF path
897 * start with '/', the name of a property of the /aliases
898 * node (an alias). In the case of an alias, the node
900 * @opts: Address of a pointer into which to store the start of
902 * a ':' separator.
909 * Return: A node pointer with refcount incremented, use
915 struct property *pp; in of_find_node_opts_by_path()
932 len = p - path; in of_find_node_opts_by_path()
939 if (strlen(pp->name) == len && !strncmp(pp->name, path, len)) { in of_find_node_opts_by_path()
940 np = of_find_node_by_path(pp->value); in of_find_node_opts_by_path()
960 * of_find_node_by_name - Find a node by its "name" property
961 * @from: The node to start searching from or NULL; the node
967 * Return: A node pointer with refcount incremented, use
987 * of_find_node_by_type - Find a node by its "device_type" property
988 * @from: The node to start searching from, or NULL to start searching
989 * the entire device tree. The node you pass will not be
995 * Return: A node pointer with refcount incremented, use
1015 * of_find_compatible_node - Find a node based on type and one of the
1016 * tokens in its "compatible" property
1017 * @from: The node to start searching from or NULL, the node
1025 * Return: A node pointer with refcount incremented, use
1046 * of_find_node_with_property - Find a node which has a property with
1048 * @from: The node to start searching from or NULL, the node
1052 * @prop_name: The name of the property to look for.
1054 * Return: A node pointer with refcount incremented, use
1061 struct property *pp; in of_find_node_with_property()
1066 for (pp = np->properties; pp; pp = pp->next) { in of_find_node_with_property()
1067 if (of_prop_cmp(pp->name, prop_name) == 0) { in of_find_node_with_property()
1082 const struct device_node *node) in __of_match_node() argument
1090 for (; matches->name[0] || matches->type[0] || matches->compatible[0]; matches++) { in __of_match_node()
1091 score = __of_device_is_compatible(node, matches->compatible, in __of_match_node()
1092 matches->type, matches->name); in __of_match_node()
1103 * of_match_node - Tell if a device_node has a matching of_match structure
1105 * @node: the of device structure to match against
1110 const struct device_node *node) in of_match_node() argument
1116 match = __of_match_node(matches, node); in of_match_node()
1123 * of_find_matching_node_and_match - Find a node based on an of_device_id
1125 * @from: The node to start searching from or NULL, the node
1132 * Return: A node pointer with refcount incremented, use
1162 * of_modalias_node - Lookup appropriate modalias for a device node
1163 * @node: pointer to a device tree node
1167 * Based on the value of the compatible property, this routine will attempt
1168 * to choose an appropriate modalias value for a particular device tree node.
1169 * It does this by stripping the manufacturer prefix (as delimited by a ',')
1170 * from the first entry in the compatible list property.
1174 int of_modalias_node(struct device_node *node, char *modalias, int len) in of_modalias_node() argument
1179 compatible = of_get_property(node, "compatible", &cplen); in of_modalias_node()
1181 return -ENODEV; in of_modalias_node()
1189 * of_find_node_by_phandle - Find a node given a phandle
1190 * @handle: phandle of the node to find
1192 * Return: A node pointer with refcount incremented, use
1209 handle == phandle_cache[handle_hash]->phandle) in of_find_node_by_phandle()
1214 if (np->phandle == handle && in of_find_node_by_phandle()
1230 printk("%s %pOF", msg, args->np); in of_print_phandle_args()
1231 for (i = 0; i < args->args_count; i++) { in of_print_phandle_args()
1234 pr_cont("%c%08x", delim, args->args[i]); in of_print_phandle_args()
1255 return -EINVAL; in of_phandle_iterator_init()
1259 return -ENOENT; in of_phandle_iterator_init()
1261 it->cells_name = cells_name; in of_phandle_iterator_init()
1262 it->cell_count = cell_count; in of_phandle_iterator_init()
1263 it->parent = np; in of_phandle_iterator_init()
1264 it->list_end = list + size / sizeof(*list); in of_phandle_iterator_init()
1265 it->phandle_end = list; in of_phandle_iterator_init()
1266 it->cur = list; in of_phandle_iterator_init()
1276 if (it->node) { in of_phandle_iterator_next()
1277 of_node_put(it->node); in of_phandle_iterator_next()
1278 it->node = NULL; in of_phandle_iterator_next()
1281 if (!it->cur || it->phandle_end >= it->list_end) in of_phandle_iterator_next()
1282 return -ENOENT; in of_phandle_iterator_next()
1284 it->cur = it->phandle_end; in of_phandle_iterator_next()
1287 it->phandle = be32_to_cpup(it->cur++); in of_phandle_iterator_next()
1289 if (it->phandle) { in of_phandle_iterator_next()
1292 * Find the provider node and parse the #*-cells property to in of_phandle_iterator_next()
1295 it->node = of_find_node_by_phandle(it->phandle); in of_phandle_iterator_next()
1297 if (it->cells_name) { in of_phandle_iterator_next()
1298 if (!it->node) { in of_phandle_iterator_next()
1300 it->parent, it->phandle); in of_phandle_iterator_next()
1304 if (of_property_read_u32(it->node, it->cells_name, in of_phandle_iterator_next()
1309 * of the cells_name property in of_phandle_iterator_next()
1311 if (it->cell_count >= 0) { in of_phandle_iterator_next()
1312 count = it->cell_count; in of_phandle_iterator_next()
1315 it->parent, in of_phandle_iterator_next()
1316 it->cells_name, in of_phandle_iterator_next()
1317 it->node); in of_phandle_iterator_next()
1322 count = it->cell_count; in of_phandle_iterator_next()
1327 * property data length in of_phandle_iterator_next()
1329 if (it->cur + count > it->list_end) { in of_phandle_iterator_next()
1331 it->parent, it->cells_name, in of_phandle_iterator_next()
1332 count, it->cell_count); in of_phandle_iterator_next()
1337 it->phandle_end = it->cur + count; in of_phandle_iterator_next()
1338 it->cur_count = count; in of_phandle_iterator_next()
1343 if (it->node) { in of_phandle_iterator_next()
1344 of_node_put(it->node); in of_phandle_iterator_next()
1345 it->node = NULL; in of_phandle_iterator_next()
1348 return -EINVAL; in of_phandle_iterator_next()
1358 count = it->cur_count; in of_phandle_iterator_args()
1364 args[i] = be32_to_cpup(it->cur++); in of_phandle_iterator_args()
1384 * or return -ENOENT for an empty entry. in __of_parse_phandle_with_args()
1386 rc = -ENOENT; in __of_parse_phandle_with_args()
1395 out_args->args, in __of_parse_phandle_with_args()
1397 out_args->np = it.node; in __of_parse_phandle_with_args()
1398 out_args->args_count = c; in __of_parse_phandle_with_args()
1400 of_node_put(it.node); in __of_parse_phandle_with_args()
1411 * Unlock node before returning result; will be one of: in __of_parse_phandle_with_args()
1412 * -ENOENT : index is for empty phandle in __of_parse_phandle_with_args()
1413 * -EINVAL : parsing error on data in __of_parse_phandle_with_args()
1417 of_node_put(it.node); in __of_parse_phandle_with_args()
1422 * of_parse_phandle - Resolve a phandle property to a device_node pointer
1423 * @np: Pointer to device node holding phandle property
1424 * @phandle_name: Name of property holding a phandle value
1425 * @index: For properties holding a table of phandles, this is the index into
1448 * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
1449 * @np: pointer to a device tree node containing a list
1450 * @list_name: property name that contains a list
1451 * @cells_name: property name that specifies phandles' arguments count
1452 * @index: index of a phandle to parse out
1459 * Caller is responsible to call of_node_put() on the returned out_args->np
1465 * #list-cells = <2>;
1469 * #list-cells = <1>;
1476 * To get a device_node of the ``node2`` node you may call this:
1477 * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
1483 int cell_count = -1; in of_parse_phandle_with_args()
1486 return -EINVAL; in of_parse_phandle_with_args()
1488 /* If cells_name is NULL we assume a cell count of 0 */ in of_parse_phandle_with_args()
1498 * of_parse_phandle_with_args_map() - Find a node pointed by phandle in a list and remap it
1499 * @np: pointer to a device tree node containing a list
1500 * @list_name: property name that contains a list
1501 * @stem_name: stem of property names that specify phandles' arguments count
1502 * @index: index of a phandle to parse out
1508 * is that this API remaps a phandle if the node the phandle points to has
1509 * a <@stem_name>-map property.
1511 * Caller is responsible to call of_node_put() on the returned out_args->np
1517 * #list-cells = <2>;
1521 * #list-cells = <1>;
1525 * #list-cells = <1>;
1526 * list-map = <0 &phandle2 3>,
1529 * list-map-mask = <0x3>;
1536 * To get a device_node of the ``node2`` node you may call this:
1556 return -EINVAL; in of_parse_phandle_with_args_map()
1558 cells_name = kasprintf(GFP_KERNEL, "#%s-cells", stem_name); in of_parse_phandle_with_args_map()
1560 return -ENOMEM; in of_parse_phandle_with_args_map()
1562 ret = -ENOMEM; in of_parse_phandle_with_args_map()
1563 map_name = kasprintf(GFP_KERNEL, "%s-map", stem_name); in of_parse_phandle_with_args_map()
1567 mask_name = kasprintf(GFP_KERNEL, "%s-map-mask", stem_name); in of_parse_phandle_with_args_map()
1571 pass_name = kasprintf(GFP_KERNEL, "%s-map-pass-thru", stem_name); in of_parse_phandle_with_args_map()
1575 ret = __of_parse_phandle_with_args(np, list_name, cells_name, -1, index, in of_parse_phandle_with_args_map()
1580 /* Get the #<list>-cells property */ in of_parse_phandle_with_args_map()
1581 cur = out_args->np; in of_parse_phandle_with_args_map()
1586 /* Precalculate the match array - this simplifies match loop */ in of_parse_phandle_with_args_map()
1588 initial_match_array[i] = cpu_to_be32(out_args->args[i]); in of_parse_phandle_with_args_map()
1590 ret = -EINVAL; in of_parse_phandle_with_args_map()
1592 /* Get the <list>-map property */ in of_parse_phandle_with_args_map()
1600 /* Get the <list>-map-mask property (optional) */ in of_parse_phandle_with_args_map()
1604 /* Iterate through <list>-map property */ in of_parse_phandle_with_args_map()
1609 for (i = 0; i < list_size; i++, map_len--) in of_parse_phandle_with_args_map()
1615 map_len--; in of_parse_phandle_with_args_map()
1634 /* Move forward by new node's #<list>-cells amount */ in of_parse_phandle_with_args_map()
1636 map_len -= new_size; in of_parse_phandle_with_args_map()
1641 /* Get the <list>-map-pass-thru property (optional) */ in of_parse_phandle_with_args_map()
1647 * Successfully parsed a <list>-map translation; copy new in of_parse_phandle_with_args_map()
1649 * bits specified in <list>-map-pass-thru. in of_parse_phandle_with_args_map()
1651 match_array = map - new_size; in of_parse_phandle_with_args_map()
1653 __be32 val = *(map - new_size + i); in of_parse_phandle_with_args_map()
1657 val |= cpu_to_be32(out_args->args[i]) & pass[i]; in of_parse_phandle_with_args_map()
1660 out_args->args[i] = be32_to_cpu(val); in of_parse_phandle_with_args_map()
1662 out_args->args_count = list_size = new_size; in of_parse_phandle_with_args_map()
1664 out_args->np = new; in of_parse_phandle_with_args_map()
1682 * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list
1683 * @np: pointer to a device tree node containing a list
1684 * @list_name: property name that contains a list
1686 * @index: index of a phandle to parse out
1693 * Caller is responsible to call of_node_put() on the returned out_args->np
1708 * To get a device_node of the ``node2`` node you may call this:
1716 return -EINVAL; in of_parse_phandle_with_fixed_args()
1723 * of_count_phandle_with_args() - Find the number of phandles references in a property
1724 * @np: pointer to a device tree node containing a list
1725 * @list_name: property name that contains a list
1726 * @cells_name: property name that specifies phandles' arguments count
1728 * Return: The number of phandle + argument tuples within a property. It
1729 * is a typical pattern to encode a list of phandle and variable
1730 * arguments into a single property. The number of arguments is encoded
1731 * by a property in the phandle-target node. For example, a gpios
1732 * property would contain a list of GPIO specifies consisting of a
1734 * determined by the #gpio-cells property in the node pointed to by the
1744 * If cells_name is NULL we assume a cell count of 0. This makes in of_count_phandle_with_args()
1745 * counting the phandles trivial as each 32bit word in the list is a in of_count_phandle_with_args()
1755 return -ENOENT; in of_count_phandle_with_args()
1760 rc = of_phandle_iterator_init(&it, np, list_name, cells_name, -1); in of_count_phandle_with_args()
1767 if (rc != -ENOENT) in of_count_phandle_with_args()
1775 * __of_add_property - Add a property to a node without lock operations
1776 * @np: Caller's Device Node
1777 * @prop: Property to add
1779 int __of_add_property(struct device_node *np, struct property *prop) in __of_add_property()
1781 struct property **next; in __of_add_property()
1783 prop->next = NULL; in __of_add_property()
1784 next = &np->properties; in __of_add_property()
1786 if (strcmp(prop->name, (*next)->name) == 0) in __of_add_property()
1788 return -EEXIST; in __of_add_property()
1790 next = &(*next)->next; in __of_add_property()
1798 * of_add_property - Add a property to a node
1799 * @np: Caller's Device Node
1800 * @prop: Property to add
1802 int of_add_property(struct device_node *np, struct property *prop) in of_add_property()
1825 int __of_remove_property(struct device_node *np, struct property *prop) in __of_remove_property()
1827 struct property **next; in __of_remove_property()
1829 for (next = &np->properties; *next; next = &(*next)->next) { in __of_remove_property()
1834 return -ENODEV; in __of_remove_property()
1836 /* found the node */ in __of_remove_property()
1837 *next = prop->next; in __of_remove_property()
1838 prop->next = np->deadprops; in __of_remove_property()
1839 np->deadprops = prop; in __of_remove_property()
1845 * of_remove_property - Remove a property from a node.
1846 * @np: Caller's Device Node
1847 * @prop: Property to remove
1850 * who-knows-how-many pointers to the data using get-property.
1851 * Instead we just move the property to the "dead properties"
1854 int of_remove_property(struct device_node *np, struct property *prop) in of_remove_property()
1860 return -ENODEV; in of_remove_property()
1880 int __of_update_property(struct device_node *np, struct property *newprop, in __of_update_property()
1881 struct property **oldpropp) in __of_update_property()
1883 struct property **next, *oldprop; in __of_update_property()
1885 for (next = &np->properties; *next; next = &(*next)->next) { in __of_update_property()
1886 if (of_prop_cmp((*next)->name, newprop->name) == 0) in __of_update_property()
1892 /* replace the node */ in __of_update_property()
1893 newprop->next = oldprop->next; in __of_update_property()
1895 oldprop->next = np->deadprops; in __of_update_property()
1896 np->deadprops = oldprop; in __of_update_property()
1898 /* new node */ in __of_update_property()
1899 newprop->next = NULL; in __of_update_property()
1907 * of_update_property - Update a property in a node, if the property does
1911 * who-knows-how-many pointers to the data using get-property.
1912 * Instead we just move the property to the "dead properties" list,
1913 * and add the new property to the property list
1915 int of_update_property(struct device_node *np, struct property *newprop) in of_update_property()
1917 struct property *oldprop; in of_update_property()
1921 if (!newprop->name) in of_update_property()
1922 return -EINVAL; in of_update_property()
1944 ap->np = np; in of_alias_add()
1945 ap->id = id; in of_alias_add()
1946 strncpy(ap->stem, stem, stem_len); in of_alias_add()
1947 ap->stem[stem_len] = 0; in of_alias_add()
1948 list_add_tail(&ap->link, &aliases_lookup); in of_alias_add()
1949 pr_debug("adding DT alias:%s: stem=%s id=%i node=%pOF\n", in of_alias_add()
1950 ap->alias, ap->stem, ap->id, np); in of_alias_add()
1954 * of_alias_scan - Scan all properties of the 'aliases' node
1955 * @dt_alloc: An allocator that provides a virtual address to memory
1958 * The function scans all the properties of the 'aliases' node and populates
1964 struct property *pp; in of_alias_scan()
1972 /* linux,stdout-path and /aliases/stdout are for legacy compatibility */ in of_alias_scan()
1975 if (of_property_read_string(of_chosen, "stdout-path", &name)) in of_alias_scan()
1976 of_property_read_string(of_chosen, "linux,stdout-path", in of_alias_scan()
1988 const char *start = pp->name; in of_alias_scan()
1995 if (!strcmp(pp->name, "name") || in of_alias_scan()
1996 !strcmp(pp->name, "phandle") || in of_alias_scan()
1997 !strcmp(pp->name, "linux,phandle")) in of_alias_scan()
2000 np = of_find_node_by_path(pp->value); in of_alias_scan()
2006 while (isdigit(*(end-1)) && end > start) in of_alias_scan()
2007 end--; in of_alias_scan()
2008 len = end - start; in of_alias_scan()
2018 ap->alias = start; in of_alias_scan()
2024 * of_alias_get_id - Get alias id for the given device_node
2036 int id = -ENODEV; in of_alias_get_id()
2040 if (strcmp(app->stem, stem) != 0) in of_alias_get_id()
2043 if (np == app->np) { in of_alias_get_id()
2044 id = app->id; in of_alias_get_id()
2055 * of_alias_get_alias_list - Get alias list for the given device driver
2064 * Return: 0 or -ENOSYS when !CONFIG_OF or
2065 * -EOVERFLOW if alias ID is greater then allocated nbits
2081 __func__, app->stem, app->id); in of_alias_get_alias_list()
2083 if (strcmp(app->stem, stem) != 0) { in of_alias_get_alias_list()
2085 __func__, app->stem); in of_alias_get_alias_list()
2089 if (of_match_node(matches, app->np)) { in of_alias_get_alias_list()
2090 pr_debug("%s: Allocated ID %d\n", __func__, app->id); in of_alias_get_alias_list()
2092 if (app->id >= nbits) { in of_alias_get_alias_list()
2094 __func__, app->id, nbits); in of_alias_get_alias_list()
2095 ret = -EOVERFLOW; in of_alias_get_alias_list()
2097 set_bit(app->id, bitmap); in of_alias_get_alias_list()
2108 * of_alias_get_highest_id - Get highest alias id for the given stem
2117 int id = -ENODEV; in of_alias_get_highest_id()
2121 if (strcmp(app->stem, stem) != 0) in of_alias_get_highest_id()
2124 if (app->id > id) in of_alias_get_highest_id()
2125 id = app->id; in of_alias_get_highest_id()
2134 * of_console_check() - Test and setup console for DT setup
2135 * @dn: Pointer to device node
2139 * Check if the given device node matches the stdout-path property in the
2140 * /chosen node. If it does then register it as the preferred console.
2158 * of_find_next_cache_node - Find a node's subsidiary cache
2159 * @np: node of type "cpu" or "cache"
2161 * Return: A node pointer with refcount incremented, use
2162 * of_node_put() on it when done. Caller should hold a reference
2167 struct device_node *child, *cache_node; in of_find_next_cache_node() local
2169 cache_node = of_parse_phandle(np, "l2-cache", 0); in of_find_next_cache_node()
2171 cache_node = of_parse_phandle(np, "next-level-cache", 0); in of_find_next_cache_node()
2176 /* OF on pmac has nodes instead of properties named "l2-cache" in of_find_next_cache_node()
2180 for_each_child_of_node(np, child) in of_find_next_cache_node()
2181 if (of_node_is_type(child, "cache")) in of_find_next_cache_node()
2182 return child; in of_find_next_cache_node()
2188 * of_find_last_cache_level - Find the level at which the last cache is
2207 of_property_read_u32(prev, "cache-level", &cache_level); in of_find_last_cache_level()
2213 * of_map_id - Translate an ID through a downstream mapping.
2214 * @np: root complex device node.
2216 * @map_name: property name of the map to use.
2217 * @map_mask_name: optional property name of the mask to use.
2218 * @target: optional pointer to a target device node.
2221 * Given a device ID, look up the appropriate implementation-defined
2223 * ID, as per the "iommu-map" and "msi-map" bindings. Either of @target or
2225 * a non-NULL device node pointer, only entries targeting that node will be
2226 * matched; if it points to a NULL value, it will receive the device node of
2227 * the first matching target phandle, with a reference held.
2229 * Return: 0 on success or a standard error code on failure.
2240 return -EINVAL; in of_map_id()
2245 return -ENODEV; in of_map_id()
2254 return -EINVAL; in of_map_id()
2261 * Can be overridden by "{iommu,msi}-map-mask" property. in of_map_id()
2268 for ( ; map_len > 0; map_len -= 4 * sizeof(*map), map += 4) { in of_map_id()
2276 pr_err("%pOF: Invalid %s translation - %s-mask (0x%x) ignores id-base (0x%x)\n", in of_map_id()
2279 return -EFAULT; in of_map_id()
2287 return -ENODEV; in of_map_id()
2300 *id_out = masked_id - id_base + out_base; in of_map_id()
2302 …pr_debug("%pOF: %s, using mask %08x, id-base: %08x, out-base: %08x, length: %08x, id: %08x -> %08x… in of_map_id()
2304 id_len, id, masked_id - id_base + out_base); in of_map_id()