Lines Matching +full:bool +full:- +full:property
1 // SPDX-License-Identifier: GPL-2.0+
6 * Copyright (C) 1996-2005 Paul Mackerras.
59 bool of_node_name_eq(const struct device_node *np, const char *name) in of_node_name_eq()
67 node_name = kbasename(np->full_name); in of_node_name_eq()
68 len = strchrnul(node_name, '@') - node_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()
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()
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()
103 * Default root value and walking parent nodes for "#address-cells" in of_bus_n_addr_cells()
108 "Missing '#address-cells' in %pOF\n", np); in of_bus_n_addr_cells()
115 if (np->parent) in of_n_addr_cells()
116 np = np->parent; in of_n_addr_cells()
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()
130 * Default root value and walking parent nodes for "#size-cells" in of_bus_n_size_cells()
135 "Missing '#size-cells' in %pOF\n", np); in of_bus_n_size_cells()
142 if (np->parent) in of_n_size_cells()
143 np = np->parent; in of_n_size_cells()
180 if (np && handle == np->phandle) in __of_phandle_cache_inv_entry()
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()
207 proc_symlink("device-tree", NULL, "/sys/firmware/devicetree/base"); in of_core_init()
210 static struct property *__of_find_property(const struct device_node *np, in __of_find_property()
213 struct property *pp; in __of_find_property()
218 for (pp = np->properties; pp; pp = pp->next) { in __of_find_property()
219 if (of_prop_cmp(pp->name, name) == 0) { in __of_find_property()
221 *lenp = pp->length; in __of_find_property()
229 struct property *of_find_property(const struct device_node *np, in of_find_property()
233 struct property *pp; in of_find_property()
249 } else if (prev->child) { in __of_find_all_nodes()
250 np = prev->child; 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()
262 * of_find_all_nodes - Get next node in global list
284 * Find a property with a given name for a given node
290 const struct property *pp = __of_find_property(np, name, lenp); in __of_get_property()
292 return pp ? pp->value : NULL; in __of_get_property()
296 * Find a property with a given name for a given node
302 const struct property *pp = of_find_property(np, name, lenp); in of_get_property()
304 return pp ? pp->value : NULL; in of_get_property()
309 * __of_device_is_compatible() - Check if the node matches given constraints
341 const struct property *prop; in __of_device_is_compatible()
351 score = INT_MAX/2 - (index << 2); in __of_device_is_compatible()
377 * the device's "compatible" property
416 * of_machine_compatible_match - Test root of device tree against a compatible array
417 …ompats: NULL terminated array of compatible strings to look for in root node's compatible property.
420 * compatible property.
422 bool of_machine_compatible_match(const char *const *compats) in of_machine_compatible_match()
437 static bool __of_device_is_status(const struct device_node *device, in __of_device_is_status()
454 if ((*strings)[len - 1] == '-') { in __of_device_is_status()
469 * __of_device_is_available - check if a device is available for use
473 * Return: True if the status property is absent or set to "okay" or "ok",
476 static bool __of_device_is_available(const struct device_node *device) in __of_device_is_available()
488 * __of_device_is_reserved - check if a device is reserved
492 * Return: True if the status property is set to "reserved", false otherwise
494 static bool __of_device_is_reserved(const struct device_node *device) in __of_device_is_reserved()
502 * of_device_is_available - check if a device is available for use
506 * Return: True if the status property is absent or set to "okay" or "ok",
509 bool of_device_is_available(const struct device_node *device) in of_device_is_available()
512 bool res; in of_device_is_available()
523 * __of_device_is_fail - check if a device has status "fail" or "fail-..."
527 * Return: True if the status property is set to "fail" or "fail-..." (for any
530 static bool __of_device_is_fail(const struct device_node *device) in __of_device_is_fail()
532 static const char * const fail[] = {"fail", "fail-", NULL}; in __of_device_is_fail()
538 * of_device_is_big_endian - check if a device has BE registers
542 * Return: True if the device has a "big-endian" property, or if the kernel
543 * was compiled for BE *and* the device has a "native-endian" property.
549 bool of_device_is_big_endian(const struct device_node *device) in of_device_is_big_endian()
551 if (of_property_read_bool(device, "big-endian")) in of_device_is_big_endian()
554 of_property_read_bool(device, "native-endian")) in of_device_is_big_endian()
561 * of_get_parent - Get a node's parent if any
576 np = of_node_get(node->parent); in of_get_parent()
583 * of_get_next_parent - Iterate to a node's parent
602 parent = of_node_get(node->parent); in of_get_next_parent()
617 next = prev ? prev->sibling : node->child; in __of_get_next_child()
627 * of_get_next_child - Iterate a node childs
649 * of_get_next_child_with_prefix - Find the next child node with prefix
671 next = prev ? prev->sibling : node->child; in of_get_next_child_with_prefix()
672 for (; next; next = next->sibling) { in of_get_next_child_with_prefix()
686 bool (*checker)(const struct device_node *)) in of_get_next_status_child()
695 next = prev ? prev->sibling : node->child; in of_get_next_status_child()
696 for (; next; next = next->sibling) { in of_get_next_status_child()
708 * of_get_next_available_child - Find the next available child node
723 * of_get_next_reserved_child - Find the next reserved child node
738 * of_get_next_cpu_node - Iterate on cpu nodes
741 * Unusable CPUs (those with the status property set to "fail" or "fail-...")
759 next = prev->sibling; in of_get_next_cpu_node()
761 next = node->child; in of_get_next_cpu_node()
764 for (; next; next = next->sibling) { in of_get_next_cpu_node()
780 * of_get_compatible_child - Find compatible child node
784 * Lookup child node whose compatible property contains the given compatible
805 * of_get_child_by_name - Find the child node by name for a given parent
828 * of_get_available_child_by_name - Find the available child node by name for a given parent
865 const char *name = kbasename(child->full_name); in __of_find_node_by_path()
891 * of_find_node_opts_by_path - Find a node matching a full OF path
893 * start with '/', the name of a property of the /aliases
911 const struct property *pp; in of_find_node_opts_by_path()
928 len = p - path; in of_find_node_opts_by_path()
935 if (strlen(pp->name) == len && !strncmp(pp->name, path, len)) { in of_find_node_opts_by_path()
936 np = of_find_node_by_path(pp->value); in of_find_node_opts_by_path()
956 * of_find_node_by_name - Find a node by its "name" property
983 * of_find_node_by_type - Find a node by its "device_type" property
1011 * of_find_compatible_node - Find a node based on type and one of the
1012 * tokens in its "compatible" property
1042 * of_find_node_with_property - Find a node which has a property with
1048 * @prop_name: The name of the property to look for.
1082 for (; matches->name[0] || matches->type[0] || matches->compatible[0]; matches++) { in __of_match_node()
1083 score = __of_device_is_compatible(node, matches->compatible, in __of_match_node()
1084 matches->type, matches->name); in __of_match_node()
1095 * of_match_node - Tell if a device_node has a matching of_match structure
1115 * of_find_matching_node_and_match - Find a node based on an of_device_id
1154 * of_alias_from_compatible - Lookup appropriate alias for a device node
1160 * Based on the value of the compatible property, this routine will attempt
1163 * from the first entry in the compatible list property.
1177 return -ENODEV; in of_alias_from_compatible()
1185 * of_find_node_by_phandle - Find a node given a phandle
1205 handle == phandle_cache[handle_hash]->phandle) in of_find_node_by_phandle()
1210 if (np->phandle == handle && in of_find_node_by_phandle()
1226 printk("%s %pOF", msg, args->np); in of_print_phandle_args()
1227 for (i = 0; i < args->args_count; i++) { in of_print_phandle_args()
1230 pr_cont("%c%08x", delim, args->args[i]); in of_print_phandle_args()
1251 return -EINVAL; in of_phandle_iterator_init()
1255 return -ENOENT; in of_phandle_iterator_init()
1257 it->cells_name = cells_name; in of_phandle_iterator_init()
1258 it->cell_count = cell_count; in of_phandle_iterator_init()
1259 it->parent = np; in of_phandle_iterator_init()
1260 it->list_end = list + size / sizeof(*list); in of_phandle_iterator_init()
1261 it->phandle_end = list; in of_phandle_iterator_init()
1262 it->cur = list; in of_phandle_iterator_init()
1272 if (it->node) { in of_phandle_iterator_next()
1273 of_node_put(it->node); in of_phandle_iterator_next()
1274 it->node = NULL; in of_phandle_iterator_next()
1277 if (!it->cur || it->phandle_end >= it->list_end) in of_phandle_iterator_next()
1278 return -ENOENT; in of_phandle_iterator_next()
1280 it->cur = it->phandle_end; in of_phandle_iterator_next()
1283 it->phandle = be32_to_cpup(it->cur++); in of_phandle_iterator_next()
1285 if (it->phandle) { in of_phandle_iterator_next()
1288 * Find the provider node and parse the #*-cells property to in of_phandle_iterator_next()
1291 it->node = of_find_node_by_phandle(it->phandle); in of_phandle_iterator_next()
1293 if (it->cells_name) { in of_phandle_iterator_next()
1294 if (!it->node) { in of_phandle_iterator_next()
1296 it->parent, it->phandle); in of_phandle_iterator_next()
1300 if (of_property_read_u32(it->node, it->cells_name, in of_phandle_iterator_next()
1305 * of the cells_name property in of_phandle_iterator_next()
1307 if (it->cell_count >= 0) { in of_phandle_iterator_next()
1308 count = it->cell_count; in of_phandle_iterator_next()
1311 it->parent, in of_phandle_iterator_next()
1312 it->cells_name, in of_phandle_iterator_next()
1313 it->node); in of_phandle_iterator_next()
1318 count = it->cell_count; in of_phandle_iterator_next()
1323 * property data length in of_phandle_iterator_next()
1325 if (it->cur + count > it->list_end) { in of_phandle_iterator_next()
1326 if (it->cells_name) in of_phandle_iterator_next()
1328 it->parent, it->cells_name, in of_phandle_iterator_next()
1329 count, it->list_end - it->cur); in of_phandle_iterator_next()
1332 it->parent, of_node_full_name(it->node), in of_phandle_iterator_next()
1333 count, it->list_end - it->cur); in of_phandle_iterator_next()
1338 it->phandle_end = it->cur + count; in of_phandle_iterator_next()
1339 it->cur_count = count; in of_phandle_iterator_next()
1344 if (it->node) { in of_phandle_iterator_next()
1345 of_node_put(it->node); in of_phandle_iterator_next()
1346 it->node = NULL; in of_phandle_iterator_next()
1349 return -EINVAL; in of_phandle_iterator_next()
1359 count = it->cur_count; in of_phandle_iterator_args()
1365 args[i] = be32_to_cpup(it->cur++); in of_phandle_iterator_args()
1380 return -EINVAL; in __of_parse_phandle_with_args()
1388 * or return -ENOENT for an empty entry. in __of_parse_phandle_with_args()
1390 rc = -ENOENT; in __of_parse_phandle_with_args()
1399 out_args->args, in __of_parse_phandle_with_args()
1401 out_args->np = it.node; in __of_parse_phandle_with_args()
1402 out_args->args_count = c; in __of_parse_phandle_with_args()
1416 * -ENOENT : index is for empty phandle in __of_parse_phandle_with_args()
1417 * -EINVAL : parsing error on data in __of_parse_phandle_with_args()
1427 * of_parse_phandle_with_args_map() - Find a node pointed by phandle in a list and remap it
1429 * @list_name: property name that contains a list
1430 * @stem_name: stem of property names that specify phandles' arguments count
1438 * a <@stem_name>-map property.
1440 * Caller is responsible to call of_node_put() on the returned out_args->np
1446 * #list-cells = <2>;
1450 * #list-cells = <1>;
1454 * #list-cells = <1>;
1455 * list-map = <0 &phandle2 3>,
1458 * list-map-mask = <0x3>;
1473 char *cells_name __free(kfree) = kasprintf(GFP_KERNEL, "#%s-cells", stem_name); in of_parse_phandle_with_args_map()
1474 char *map_name __free(kfree) = kasprintf(GFP_KERNEL, "%s-map", stem_name); in of_parse_phandle_with_args_map()
1475 char *mask_name __free(kfree) = kasprintf(GFP_KERNEL, "%s-map-mask", stem_name); in of_parse_phandle_with_args_map()
1476 char *pass_name __free(kfree) = kasprintf(GFP_KERNEL, "%s-map-pass-thru", stem_name); in of_parse_phandle_with_args_map()
1479 static const __be32 dummy_mask[] = { [0 ... (MAX_PHANDLE_ARGS - 1)] = cpu_to_be32(~0) }; in of_parse_phandle_with_args_map()
1480 static const __be32 dummy_pass[] = { [0 ... (MAX_PHANDLE_ARGS - 1)] = cpu_to_be32(0) }; in of_parse_phandle_with_args_map()
1487 return -EINVAL; in of_parse_phandle_with_args_map()
1490 return -ENOMEM; in of_parse_phandle_with_args_map()
1492 ret = __of_parse_phandle_with_args(np, list_name, cells_name, -1, index, in of_parse_phandle_with_args_map()
1497 /* Get the #<list>-cells property */ in of_parse_phandle_with_args_map()
1498 cur = out_args->np; in of_parse_phandle_with_args_map()
1503 /* Precalculate the match array - this simplifies match loop */ in of_parse_phandle_with_args_map()
1505 initial_match_array[i] = cpu_to_be32(out_args->args[i]); in of_parse_phandle_with_args_map()
1507 ret = -EINVAL; in of_parse_phandle_with_args_map()
1509 /* Get the <list>-map property */ in of_parse_phandle_with_args_map()
1516 /* Get the <list>-map-mask property (optional) */ in of_parse_phandle_with_args_map()
1520 /* Iterate through <list>-map property */ in of_parse_phandle_with_args_map()
1525 for (i = 0; i < list_size; i++, map_len--) in of_parse_phandle_with_args_map()
1531 map_len--; in of_parse_phandle_with_args_map()
1535 ret = -EINVAL; in of_parse_phandle_with_args_map()
1549 ret = -EINVAL; in of_parse_phandle_with_args_map()
1553 /* Move forward by new node's #<list>-cells amount */ in of_parse_phandle_with_args_map()
1555 map_len -= new_size; in of_parse_phandle_with_args_map()
1558 ret = -ENOENT; in of_parse_phandle_with_args_map()
1562 /* Get the <list>-map-pass-thru property (optional) */ in of_parse_phandle_with_args_map()
1568 * Successfully parsed a <list>-map translation; copy new in of_parse_phandle_with_args_map()
1570 * bits specified in <list>-map-pass-thru. in of_parse_phandle_with_args_map()
1573 __be32 val = *(map - new_size + i); in of_parse_phandle_with_args_map()
1577 val |= cpu_to_be32(out_args->args[i]) & pass[i]; in of_parse_phandle_with_args_map()
1581 out_args->args[i] = be32_to_cpu(val); in of_parse_phandle_with_args_map()
1583 out_args->args_count = list_size = new_size; in of_parse_phandle_with_args_map()
1585 out_args->np = new; in of_parse_phandle_with_args_map()
1598 * of_count_phandle_with_args() - Find the number of phandles references in a property
1600 * @list_name: property name that contains a list
1601 * @cells_name: property name that specifies phandles' arguments count
1603 * Return: The number of phandle + argument tuples within a property. It
1605 * arguments into a single property. The number of arguments is encoded
1606 * by a property in the phandle-target node. For example, a gpios
1607 * property would contain a list of GPIO specifies consisting of a
1609 * determined by the #gpio-cells property in the node pointed to by the
1630 return -ENOENT; in of_count_phandle_with_args()
1635 rc = of_phandle_iterator_init(&it, np, list_name, cells_name, -1); in of_count_phandle_with_args()
1642 if (rc != -ENOENT) in of_count_phandle_with_args()
1649 static struct property *__of_remove_property_from_list(struct property **list, struct property *pro… in __of_remove_property_from_list()
1651 struct property **next; in __of_remove_property_from_list()
1653 for (next = list; *next; next = &(*next)->next) { in __of_remove_property_from_list()
1655 *next = prop->next; in __of_remove_property_from_list()
1656 prop->next = NULL; in __of_remove_property_from_list()
1664 * __of_add_property - Add a property to a node without lock operations
1666 * @prop: Property to add
1668 int __of_add_property(struct device_node *np, struct property *prop) in __of_add_property()
1672 struct property **next; in __of_add_property()
1676 __of_remove_property_from_list(&np->deadprops, prop); in __of_add_property()
1678 prop->next = NULL; in __of_add_property()
1679 next = &np->properties; in __of_add_property()
1681 if (of_prop_cmp(prop->name, (*next)->name) == 0) { in __of_add_property()
1683 rc = -EEXIST; in __of_add_property()
1686 next = &(*next)->next; in __of_add_property()
1700 * of_add_property - Add a property to a node
1702 * @prop: Property to add
1704 int of_add_property(struct device_node *np, struct property *prop) in of_add_property()
1719 int __of_remove_property(struct device_node *np, struct property *prop) in __of_remove_property()
1722 int rc = -ENODEV; in __of_remove_property()
1726 if (__of_remove_property_from_list(&np->properties, prop)) { in __of_remove_property()
1727 /* Found the property, add it to deadprops list */ in __of_remove_property()
1728 prop->next = np->deadprops; in __of_remove_property()
1729 np->deadprops = prop; in __of_remove_property()
1742 * of_remove_property - Remove a property from a node.
1744 * @prop: Property to remove
1747 * who-knows-how-many pointers to the data using get-property.
1748 * Instead we just move the property to the "dead properties"
1751 int of_remove_property(struct device_node *np, struct property *prop) in of_remove_property()
1756 return -ENODEV; in of_remove_property()
1769 int __of_update_property(struct device_node *np, struct property *newprop, in __of_update_property()
1770 struct property **oldpropp) in __of_update_property()
1772 struct property **next, *oldprop; in __of_update_property()
1777 __of_remove_property_from_list(&np->deadprops, newprop); in __of_update_property()
1779 for (next = &np->properties; *next; next = &(*next)->next) { in __of_update_property()
1780 if (of_prop_cmp((*next)->name, newprop->name) == 0) in __of_update_property()
1787 newprop->next = oldprop->next; in __of_update_property()
1789 oldprop->next = np->deadprops; in __of_update_property()
1790 np->deadprops = oldprop; in __of_update_property()
1793 newprop->next = NULL; in __of_update_property()
1805 * of_update_property - Update a property in a node, if the property does
1809 * who-knows-how-many pointers to the data using get-property.
1810 * Instead we just move the property to the "dead properties" list,
1811 * and add the new property to the property list
1813 int of_update_property(struct device_node *np, struct property *newprop) in of_update_property()
1815 struct property *oldprop; in of_update_property()
1818 if (!newprop->name) in of_update_property()
1819 return -EINVAL; in of_update_property()
1834 ap->np = np; in of_alias_add()
1835 ap->id = id; in of_alias_add()
1836 strscpy(ap->stem, stem, stem_len + 1); in of_alias_add()
1837 list_add_tail(&ap->link, &aliases_lookup); in of_alias_add()
1839 ap->alias, ap->stem, ap->id, np); in of_alias_add()
1843 * of_alias_scan - Scan all properties of the 'aliases' node
1852 const struct property *pp; in of_alias_scan()
1860 /* linux,stdout-path and /aliases/stdout are for legacy compatibility */ in of_alias_scan()
1863 if (of_property_read_string(of_chosen, "stdout-path", &name)) in of_alias_scan()
1864 of_property_read_string(of_chosen, "linux,stdout-path", in of_alias_scan()
1871 of_stdout->fwnode.flags |= FWNODE_FLAG_BEST_EFFORT; in of_alias_scan()
1878 const char *start = pp->name; in of_alias_scan()
1885 if (is_pseudo_property(pp->name)) in of_alias_scan()
1888 np = of_find_node_by_path(pp->value); in of_alias_scan()
1894 while (isdigit(*(end-1)) && end > start) in of_alias_scan()
1895 end--; in of_alias_scan()
1896 len = end - start; in of_alias_scan()
1906 ap->alias = start; in of_alias_scan()
1912 * of_alias_get_id - Get alias id for the given device_node
1924 int id = -ENODEV; in of_alias_get_id()
1928 if (strcmp(app->stem, stem) != 0) in of_alias_get_id()
1931 if (np == app->np) { in of_alias_get_id()
1932 id = app->id; in of_alias_get_id()
1943 * of_alias_get_highest_id - Get highest alias id for the given stem
1952 int id = -ENODEV; in of_alias_get_highest_id()
1956 if (strcmp(app->stem, stem) != 0) in of_alias_get_highest_id()
1959 if (app->id > id) in of_alias_get_highest_id()
1960 id = app->id; in of_alias_get_highest_id()
1969 * of_console_check() - Test and setup console for DT setup
1974 * Check if the given device node matches the stdout-path property in the
1979 bool of_console_check(const struct device_node *dn, char *name, int index) in of_console_check()
1993 * of_find_next_cache_node - Find a node's subsidiary cache
2004 cache_node = of_parse_phandle(np, "l2-cache", 0); in of_find_next_cache_node()
2006 cache_node = of_parse_phandle(np, "next-level-cache", 0); in of_find_next_cache_node()
2011 /* OF on pmac has nodes instead of properties named "l2-cache" in of_find_next_cache_node()
2023 * of_find_last_cache_level - Find the level at which the last cache is
2042 of_property_read_u32(prev, "cache-level", &cache_level); in of_find_last_cache_level()
2049 * of_map_id - Translate an ID through a downstream mapping.
2052 * @map_name: property name of the map to use.
2053 * @map_mask_name: optional property name of the mask to use.
2057 * Given a device ID, look up the appropriate implementation-defined
2059 * ID, as per the "iommu-map" and "msi-map" bindings. Either of @target or
2061 * a non-NULL device node pointer, only entries targeting that node will be
2076 return -EINVAL; in of_map_id()
2081 return -ENODEV; in of_map_id()
2090 return -EINVAL; in of_map_id()
2097 * Can be overridden by "{iommu,msi}-map-mask" property. in of_map_id()
2104 for ( ; map_len > 0; map_len -= 4 * sizeof(*map), map += 4) { in of_map_id()
2112 pr_err("%pOF: Invalid %s translation - %s-mask (0x%x) ignores id-base (0x%x)\n", in of_map_id()
2115 return -EFAULT; in of_map_id()
2123 return -ENODEV; in of_map_id()
2136 *id_out = masked_id - id_base + out_base; in of_map_id()
2138 …pr_debug("%pOF: %s, using mask %08x, id-base: %08x, out-base: %08x, length: %08x, id: %08x -> %08x… in of_map_id()
2140 id_len, id, masked_id - id_base + out_base); in of_map_id()