Lines Matching +full:bool +full:- +full:property
1 // SPDX-License-Identifier: GPL-2.0+
6 * Copyright (C) 1996-2005 Paul Mackerras.
57 bool of_node_name_eq(const struct device_node *np, const char *name) in of_node_name_eq()
65 node_name = kbasename(np->full_name); in of_node_name_eq()
66 len = strchrnul(node_name, '@') - node_name; in of_node_name_eq()
72 bool of_node_name_prefix(const struct device_node *np, const char *prefix) in of_node_name_prefix()
77 return strncmp(kbasename(np->full_name), prefix, strlen(prefix)) == 0; in of_node_name_prefix()
86 if (np->parent) in of_n_addr_cells()
87 np = np->parent; in of_n_addr_cells()
88 if (!of_property_read_u32(np, "#address-cells", &cells)) in of_n_addr_cells()
90 } while (np->parent); in of_n_addr_cells()
91 /* No #address-cells property for the root node */ in of_n_addr_cells()
101 if (np->parent) in of_n_size_cells()
102 np = np->parent; in of_n_size_cells()
103 if (!of_property_read_u32(np, "#size-cells", &cells)) in of_n_size_cells()
105 } while (np->parent); in of_n_size_cells()
106 /* No #size-cells property for the root node */ in of_n_size_cells()
120 * - phandle property values are in a contiguous range of 1..n
123 * - the phandle lookup overhead reduction provided by the cache
179 if (np && handle == np->phandle) { in __of_free_phandle_cache_entry()
198 if (np->phandle && np->phandle != OF_PHANDLE_ILLEGAL) in of_populate_phandle_cache()
205 phandle_cache_mask = cache_entries - 1; in of_populate_phandle_cache()
213 if (np->phandle && np->phandle != OF_PHANDLE_ILLEGAL) { in of_populate_phandle_cache()
215 phandle_cache[np->phandle & phandle_cache_mask] = np; in of_populate_phandle_cache()
242 proc_symlink("device-tree", NULL, "/sys/firmware/devicetree/base"); in of_core_init()
245 static struct property *__of_find_property(const struct device_node *np, in __of_find_property()
248 struct property *pp; in __of_find_property()
253 for (pp = np->properties; pp; pp = pp->next) { in __of_find_property()
254 if (of_prop_cmp(pp->name, name) == 0) { in __of_find_property()
256 *lenp = pp->length; in __of_find_property()
264 struct property *of_find_property(const struct device_node *np, in of_find_property()
268 struct property *pp; in of_find_property()
284 } else if (prev->child) { in __of_find_all_nodes()
285 np = prev->child; in __of_find_all_nodes()
289 while (np->parent && !np->sibling) in __of_find_all_nodes()
290 np = np->parent; in __of_find_all_nodes()
291 np = np->sibling; /* Might be null at the end of the tree */ in __of_find_all_nodes()
297 * of_find_all_nodes - Get next node in global list
319 * Find a property with a given name for a given node
325 struct property *pp = __of_find_property(np, name, lenp); in __of_get_property()
327 return pp ? pp->value : NULL; in __of_get_property()
331 * Find a property with a given name for a given node
337 struct property *pp = of_find_property(np, name, lenp); in of_get_property()
339 return pp ? pp->value : NULL; in of_get_property()
344 * arch_match_cpu_phys_id - Match the given logical CPU and physical id
357 bool __weak arch_match_cpu_phys_id(int cpu, u64 phys_id) in arch_match_cpu_phys_id()
363 * Checks if the given "prop_name" property holds the physical id of the
367 static bool __of_find_n_match_cpu_property(struct device_node *cpun, in __of_find_n_match_cpu_property()
392 * arch_find_n_match_cpu_physical_id - See if the given device node is
394 * else false. If 'thread' is non-NULL, the local thread number within the
397 bool __weak arch_find_n_match_cpu_physical_id(struct device_node *cpun, in arch_find_n_match_cpu_physical_id()
400 /* Check for non-standard "ibm,ppc-interrupt-server#s" property in arch_find_n_match_cpu_physical_id()
402 * standard "reg" property. in arch_find_n_match_cpu_physical_id()
406 "ibm,ppc-interrupt-server#s", in arch_find_n_match_cpu_physical_id()
414 * of_get_cpu_node - Get device node associated with the given logical CPU
450 * Returns -ENODEV if the CPU is not found.
455 bool found = false; in of_cpu_node_to_id()
466 return -ENODEV; in of_cpu_node_to_id()
471 * __of_device_is_compatible() - Check if the node matches given constraints
503 struct property *prop; in __of_device_is_compatible()
513 score = INT_MAX/2 - (index << 2); in __of_device_is_compatible()
523 if (!device->type || of_node_cmp(type, device->type)) in __of_device_is_compatible()
530 if (!device->name || of_node_cmp(name, device->name)) in __of_device_is_compatible()
539 * the device's "compatible" property
577 * of_machine_is_compatible - Test root of device tree for a given compatible value
578 * @compat: compatible string to look for in root node's compatible property.
581 * compatible property.
598 * __of_device_is_available - check if a device is available for use
602 * Returns true if the status property is absent or set to "okay" or "ok",
605 static bool __of_device_is_available(const struct device_node *device) in __of_device_is_available()
626 * of_device_is_available - check if a device is available for use
630 * Returns true if the status property is absent or set to "okay" or "ok",
633 bool of_device_is_available(const struct device_node *device) in of_device_is_available()
636 bool res; in of_device_is_available()
647 * of_device_is_big_endian - check if a device has BE registers
651 * Returns true if the device has a "big-endian" property, or if the kernel
652 * was compiled for BE *and* the device has a "native-endian" property.
658 bool of_device_is_big_endian(const struct device_node *device) in of_device_is_big_endian()
660 if (of_property_read_bool(device, "big-endian")) in of_device_is_big_endian()
663 of_property_read_bool(device, "native-endian")) in of_device_is_big_endian()
670 * of_get_parent - Get a node's parent if any
685 np = of_node_get(node->parent); in of_get_parent()
692 * of_get_next_parent - Iterate to a node's parent
711 parent = of_node_get(node->parent); in of_get_next_parent()
726 next = prev ? prev->sibling : node->child; in __of_get_next_child()
727 for (; next; next = next->sibling) in __of_get_next_child()
738 * of_get_next_child - Iterate a node childs
760 * of_get_next_available_child - Find the next available child node
777 next = prev ? prev->sibling : node->child; in of_get_next_available_child()
778 for (; next; next = next->sibling) { in of_get_next_available_child()
791 * of_get_compatible_child - Find compatible child node
795 * Lookup child node whose compatible property contains the given compatible
816 * of_get_child_by_name - Find the child node by name for a given parent
832 if (child->name && (of_node_cmp(child->name, name) == 0)) in of_get_child_by_name()
849 const char *name = kbasename(child->full_name); in __of_find_node_by_path()
875 * of_find_node_opts_by_path - Find a node matching a full OF path
877 * start with '/', the name of a property of the /aliases
895 struct property *pp; in of_find_node_opts_by_path()
912 len = p - path; in of_find_node_opts_by_path()
919 if (strlen(pp->name) == len && !strncmp(pp->name, path, len)) { in of_find_node_opts_by_path()
920 np = of_find_node_by_path(pp->value); in of_find_node_opts_by_path()
940 * of_find_node_by_name - Find a node by its "name" property
958 if (np->name && (of_node_cmp(np->name, name) == 0) in of_find_node_by_name()
968 * of_find_node_by_type - Find a node by its "device_type" property
987 if (np->type && (of_node_cmp(np->type, type) == 0) in of_find_node_by_type()
997 * of_find_compatible_node - Find a node based on type and one of the
998 * tokens in its "compatible" property
1028 * of_find_node_with_property - Find a node which has a property with
1034 * @prop_name: The name of the property to look for.
1043 struct property *pp; in of_find_node_with_property()
1048 for (pp = np->properties; pp; pp = pp->next) { in of_find_node_with_property()
1049 if (of_prop_cmp(pp->name, prop_name) == 0) { in of_find_node_with_property()
1072 for (; matches->name[0] || matches->type[0] || matches->compatible[0]; matches++) { in __of_match_node()
1073 score = __of_device_is_compatible(node, matches->compatible, in __of_match_node()
1074 matches->type, matches->name); in __of_match_node()
1085 * of_match_node - Tell if a device_node has a matching of_match structure
1105 * of_find_matching_node_and_match - Find a node based on an of_device_id
1144 * of_modalias_node - Lookup appropriate modalias for a device node
1149 * Based on the value of the compatible property, this routine will attempt
1152 * from the first entry in the compatible list property.
1163 return -ENODEV; in of_modalias_node()
1171 * of_find_node_by_phandle - Find a node given a phandle
1192 handle == phandle_cache[masked_handle]->phandle) in of_find_node_by_phandle()
1204 if (np->phandle == handle && in of_find_node_by_phandle()
1224 printk("%s %pOF", msg, args->np); in of_print_phandle_args()
1225 for (i = 0; i < args->args_count; i++) { in of_print_phandle_args()
1228 pr_cont("%c%08x", delim, args->args[i]); in of_print_phandle_args()
1246 return -ENOENT; in of_phandle_iterator_init()
1248 it->cells_name = cells_name; in of_phandle_iterator_init()
1249 it->cell_count = cell_count; in of_phandle_iterator_init()
1250 it->parent = np; in of_phandle_iterator_init()
1251 it->list_end = list + size / sizeof(*list); in of_phandle_iterator_init()
1252 it->phandle_end = list; in of_phandle_iterator_init()
1253 it->cur = list; in of_phandle_iterator_init()
1263 if (it->node) { in of_phandle_iterator_next()
1264 of_node_put(it->node); in of_phandle_iterator_next()
1265 it->node = NULL; in of_phandle_iterator_next()
1268 if (!it->cur || it->phandle_end >= it->list_end) in of_phandle_iterator_next()
1269 return -ENOENT; in of_phandle_iterator_next()
1271 it->cur = it->phandle_end; in of_phandle_iterator_next()
1274 it->phandle = be32_to_cpup(it->cur++); in of_phandle_iterator_next()
1276 if (it->phandle) { in of_phandle_iterator_next()
1279 * Find the provider node and parse the #*-cells property to in of_phandle_iterator_next()
1282 it->node = of_find_node_by_phandle(it->phandle); in of_phandle_iterator_next()
1284 if (it->cells_name) { in of_phandle_iterator_next()
1285 if (!it->node) { in of_phandle_iterator_next()
1287 it->parent); in of_phandle_iterator_next()
1291 if (of_property_read_u32(it->node, it->cells_name, in of_phandle_iterator_next()
1294 it->parent, in of_phandle_iterator_next()
1295 it->cells_name, in of_phandle_iterator_next()
1296 it->node); in of_phandle_iterator_next()
1300 count = it->cell_count; in of_phandle_iterator_next()
1305 * property data length in of_phandle_iterator_next()
1307 if (it->cur + count > it->list_end) { in of_phandle_iterator_next()
1308 pr_err("%pOF: arguments longer than property\n", in of_phandle_iterator_next()
1309 it->parent); in of_phandle_iterator_next()
1314 it->phandle_end = it->cur + count; in of_phandle_iterator_next()
1315 it->cur_count = count; in of_phandle_iterator_next()
1320 if (it->node) { in of_phandle_iterator_next()
1321 of_node_put(it->node); in of_phandle_iterator_next()
1322 it->node = NULL; in of_phandle_iterator_next()
1325 return -EINVAL; in of_phandle_iterator_next()
1335 count = it->cur_count; in of_phandle_iterator_args()
1341 args[i] = be32_to_cpup(it->cur++); in of_phandle_iterator_args()
1361 * or return -ENOENT for an empty entry. in __of_parse_phandle_with_args()
1363 rc = -ENOENT; in __of_parse_phandle_with_args()
1372 out_args->args, in __of_parse_phandle_with_args()
1374 out_args->np = it.node; in __of_parse_phandle_with_args()
1375 out_args->args_count = c; in __of_parse_phandle_with_args()
1389 * -ENOENT : index is for empty phandle in __of_parse_phandle_with_args()
1390 * -EINVAL : parsing error on data in __of_parse_phandle_with_args()
1399 * of_parse_phandle - Resolve a phandle property to a device_node pointer
1400 * @np: Pointer to device node holding phandle property
1401 * @phandle_name: Name of property holding a phandle value
1425 * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
1427 * @list_name: property name that contains a list
1428 * @cells_name: property name that specifies phandles' arguments count
1436 * Caller is responsible to call of_node_put() on the returned out_args->np
1442 * #list-cells = <2>;
1446 * #list-cells = <1>;
1454 * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
1461 return -EINVAL; in of_parse_phandle_with_args()
1468 * of_parse_phandle_with_args_map() - Find a node pointed by phandle in a list and remap it
1470 * @list_name: property name that contains a list
1471 * @stem_name: stem of property names that specify phandles' arguments count
1479 * a <@stem_name>-map property.
1481 * Caller is responsible to call of_node_put() on the returned out_args->np
1487 * #list-cells = <2>;
1491 * #list-cells = <1>;
1495 * #list-cells = <1>;
1496 * list-map = <0 &phandle2 3>,
1499 * list-map-mask = <0x3>;
1526 return -EINVAL; in of_parse_phandle_with_args_map()
1528 cells_name = kasprintf(GFP_KERNEL, "#%s-cells", stem_name); in of_parse_phandle_with_args_map()
1530 return -ENOMEM; in of_parse_phandle_with_args_map()
1532 ret = -ENOMEM; in of_parse_phandle_with_args_map()
1533 map_name = kasprintf(GFP_KERNEL, "%s-map", stem_name); in of_parse_phandle_with_args_map()
1537 mask_name = kasprintf(GFP_KERNEL, "%s-map-mask", stem_name); in of_parse_phandle_with_args_map()
1541 pass_name = kasprintf(GFP_KERNEL, "%s-map-pass-thru", stem_name); in of_parse_phandle_with_args_map()
1550 /* Get the #<list>-cells property */ in of_parse_phandle_with_args_map()
1551 cur = out_args->np; in of_parse_phandle_with_args_map()
1556 /* Precalculate the match array - this simplifies match loop */ in of_parse_phandle_with_args_map()
1558 initial_match_array[i] = cpu_to_be32(out_args->args[i]); in of_parse_phandle_with_args_map()
1560 ret = -EINVAL; in of_parse_phandle_with_args_map()
1562 /* Get the <list>-map property */ in of_parse_phandle_with_args_map()
1570 /* Get the <list>-map-mask property (optional) */ in of_parse_phandle_with_args_map()
1574 /* Iterate through <list>-map property */ in of_parse_phandle_with_args_map()
1579 for (i = 0; i < list_size; i++, map_len--) in of_parse_phandle_with_args_map()
1585 map_len--; in of_parse_phandle_with_args_map()
1604 /* Move forward by new node's #<list>-cells amount */ in of_parse_phandle_with_args_map()
1606 map_len -= new_size; in of_parse_phandle_with_args_map()
1611 /* Get the <list>-map-pass-thru property (optional) */ in of_parse_phandle_with_args_map()
1617 * Successfully parsed a <list>-map translation; copy new in of_parse_phandle_with_args_map()
1619 * bits specified in <list>-map-pass-thru. in of_parse_phandle_with_args_map()
1621 match_array = map - new_size; in of_parse_phandle_with_args_map()
1623 __be32 val = *(map - new_size + i); in of_parse_phandle_with_args_map()
1627 val |= cpu_to_be32(out_args->args[i]) & pass[i]; in of_parse_phandle_with_args_map()
1630 out_args->args[i] = be32_to_cpu(val); in of_parse_phandle_with_args_map()
1632 out_args->args_count = list_size = new_size; in of_parse_phandle_with_args_map()
1634 out_args->np = new; in of_parse_phandle_with_args_map()
1652 * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list
1654 * @list_name: property name that contains a list
1663 * Caller is responsible to call of_node_put() on the returned out_args->np
1686 return -EINVAL; in of_parse_phandle_with_fixed_args()
1693 * of_count_phandle_with_args() - Find the number of phandles references in a property
1695 * @list_name: property name that contains a list
1696 * @cells_name: property name that specifies phandles' arguments count
1698 * Returns the number of phandle + argument tuples within a property. It
1700 * arguments into a single property. The number of arguments is encoded
1701 * by a property in the phandle-target node. For example, a gpios
1702 * property would contain a list of GPIO specifies consisting of a
1704 * determined by the #gpio-cells property in the node pointed to by the
1720 if (rc != -ENOENT) in of_count_phandle_with_args()
1728 * __of_add_property - Add a property to a node without lock operations
1730 int __of_add_property(struct device_node *np, struct property *prop) in __of_add_property()
1732 struct property **next; in __of_add_property()
1734 prop->next = NULL; in __of_add_property()
1735 next = &np->properties; in __of_add_property()
1737 if (strcmp(prop->name, (*next)->name) == 0) in __of_add_property()
1739 return -EEXIST; in __of_add_property()
1741 next = &(*next)->next; in __of_add_property()
1749 * of_add_property - Add a property to a node
1751 int of_add_property(struct device_node *np, struct property *prop) in of_add_property()
1773 int __of_remove_property(struct device_node *np, struct property *prop) in __of_remove_property()
1775 struct property **next; in __of_remove_property()
1777 for (next = &np->properties; *next; next = &(*next)->next) { in __of_remove_property()
1782 return -ENODEV; in __of_remove_property()
1785 *next = prop->next; in __of_remove_property()
1786 prop->next = np->deadprops; in __of_remove_property()
1787 np->deadprops = prop; in __of_remove_property()
1793 * of_remove_property - Remove a property from a node.
1796 * who-knows-how-many pointers to the data using get-property.
1797 * Instead we just move the property to the "dead properties"
1800 int of_remove_property(struct device_node *np, struct property *prop) in of_remove_property()
1806 return -ENODEV; in of_remove_property()
1825 int __of_update_property(struct device_node *np, struct property *newprop, in __of_update_property()
1826 struct property **oldpropp) in __of_update_property()
1828 struct property **next, *oldprop; in __of_update_property()
1830 for (next = &np->properties; *next; next = &(*next)->next) { in __of_update_property()
1831 if (of_prop_cmp((*next)->name, newprop->name) == 0) in __of_update_property()
1838 newprop->next = oldprop->next; in __of_update_property()
1840 oldprop->next = np->deadprops; in __of_update_property()
1841 np->deadprops = oldprop; in __of_update_property()
1844 newprop->next = NULL; in __of_update_property()
1852 * of_update_property - Update a property in a node, if the property does
1856 * who-knows-how-many pointers to the data using get-property.
1857 * Instead we just move the property to the "dead properties" list,
1858 * and add the new property to the property list
1860 int of_update_property(struct device_node *np, struct property *newprop) in of_update_property()
1862 struct property *oldprop; in of_update_property()
1866 if (!newprop->name) in of_update_property()
1867 return -EINVAL; in of_update_property()
1889 ap->np = np; in of_alias_add()
1890 ap->id = id; in of_alias_add()
1891 strncpy(ap->stem, stem, stem_len); in of_alias_add()
1892 ap->stem[stem_len] = 0; in of_alias_add()
1893 list_add_tail(&ap->link, &aliases_lookup); in of_alias_add()
1895 ap->alias, ap->stem, ap->id, np); in of_alias_add()
1899 * of_alias_scan - Scan all properties of the 'aliases' node
1910 struct property *pp; in of_alias_scan()
1918 /* linux,stdout-path and /aliases/stdout are for legacy compatibility */ in of_alias_scan()
1921 if (of_property_read_string(of_chosen, "stdout-path", &name)) in of_alias_scan()
1922 of_property_read_string(of_chosen, "linux,stdout-path", in of_alias_scan()
1934 const char *start = pp->name; in of_alias_scan()
1941 if (!strcmp(pp->name, "name") || in of_alias_scan()
1942 !strcmp(pp->name, "phandle") || in of_alias_scan()
1943 !strcmp(pp->name, "linux,phandle")) in of_alias_scan()
1946 np = of_find_node_by_path(pp->value); in of_alias_scan()
1952 while (isdigit(*(end-1)) && end > start) in of_alias_scan()
1953 end--; in of_alias_scan()
1954 len = end - start; in of_alias_scan()
1964 ap->alias = start; in of_alias_scan()
1970 * of_alias_get_id - Get alias id for the given device_node
1980 int id = -ENODEV; in of_alias_get_id()
1984 if (strcmp(app->stem, stem) != 0) in of_alias_get_id()
1987 if (np == app->np) { in of_alias_get_id()
1988 id = app->id; in of_alias_get_id()
1999 * of_alias_get_highest_id - Get highest alias id for the given stem
2008 int id = -ENODEV; in of_alias_get_highest_id()
2012 if (strcmp(app->stem, stem) != 0) in of_alias_get_highest_id()
2015 if (app->id > id) in of_alias_get_highest_id()
2016 id = app->id; in of_alias_get_highest_id()
2025 * of_console_check() - Test and setup console for DT setup
2026 * @dn - Pointer to device node
2027 * @name - Name to use for preferred console without index. ex. "ttyS"
2028 * @index - Index to use for preferred console.
2030 * Check if the given device node matches the stdout-path property in the
2034 bool of_console_check(struct device_node *dn, char *name, int index) in of_console_check()
2048 * of_find_next_cache_node - Find a node's subsidiary cache
2059 cache_node = of_parse_phandle(np, "l2-cache", 0); in of_find_next_cache_node()
2061 cache_node = of_parse_phandle(np, "next-level-cache", 0); in of_find_next_cache_node()
2066 /* OF on pmac has nodes instead of properties named "l2-cache" in of_find_next_cache_node()
2069 if (IS_ENABLED(CONFIG_PPC_PMAC) && !strcmp(np->type, "cpu")) in of_find_next_cache_node()
2071 if (!strcmp(child->type, "cache")) in of_find_next_cache_node()
2078 * of_find_last_cache_level - Find the level at which the last cache is
2097 of_property_read_u32(prev, "cache-level", &cache_level); in of_find_last_cache_level()