Lines Matching +full:a +full:- +full:child +full:- +full:node +full:- +full:property

1 /* SPDX-License-Identifier: GPL-2.0+ */
8 * Copyright (C) 1996-2005 Paul Mackerras.
20 #include <linux/property.h>
28 struct property { struct
32 struct property *next; argument
54 struct property *properties; argument
55 struct property *deadprops; /* removed properties */
57 struct device_node *child; member
91 struct device_node *node; member
96 struct property *prop;
97 struct property *old_prop;
104 * of_node_init - initialize a devicetree node
105 * @node: Pointer to device node that has been created by kzalloc()
108 * on @node when done to free the memory allocated for it. If the node
109 * is NOT a dynamic node the memory will not be freed. The decision of
110 * whether to free the memory will be done by node->release(), which is
113 static inline void of_node_init(struct device_node *node) in of_node_init() argument
116 kobject_init(&node->kobj, &of_node_ktype); in of_node_init()
118 fwnode_init(&node->fwnode, &of_fwnode_ops); in of_node_init()
122 #define of_node_kobj(n) (&(n)->kobj)
128 extern struct device_node *of_node_get(struct device_node *node);
129 extern void of_node_put(struct device_node *node);
131 /* Dummy ref counting routines - to be implemented later */
132 static inline struct device_node *of_node_get(struct device_node *node) in of_node_get() argument
134 return node; in of_node_get()
136 static inline void of_node_put(struct device_node *node) { } in of_node_put() argument
157 #define OF_BAD_ADDR ((u64)-1)
164 return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &of_fwnode_ops; in is_of_node()
177 #define of_fwnode_handle(node) \ argument
179 typeof(node) __of_fwnode_handle_node = (node); \
182 &__of_fwnode_handle_node->fwnode : NULL; \
185 static inline bool of_node_is_root(const struct device_node *node) in of_node_is_root() argument
187 return node && (node->parent == NULL); in of_node_is_root()
192 return test_bit(flag, &n->_flags); in of_node_check_flag()
198 return test_and_set_bit(flag, &n->_flags); in of_node_test_and_set_flag()
203 set_bit(flag, &n->_flags); in of_node_set_flag()
208 clear_bit(flag, &n->_flags); in of_node_clear_flag()
212 static inline int of_property_check_flag(const struct property *p, unsigned long flag) in of_property_check_flag()
214 return test_bit(flag, &p->_flags); in of_property_check_flag()
217 static inline void of_property_set_flag(struct property *p, unsigned long flag) in of_property_set_flag()
219 set_bit(flag, &p->_flags); in of_property_set_flag()
222 static inline void of_property_clear_flag(struct property *p, unsigned long flag) in of_property_clear_flag()
224 clear_bit(flag, &p->_flags); in of_property_clear_flag()
235 /* Helper to read a big number; size is in cells (not bytes) */
239 for (; size--; cell++) in of_read_number()
255 #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
256 #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
263 return np ? np->full_name : "<no-node>"; in of_node_full_name()
288 extern struct device_node *of_get_parent(const struct device_node *node);
289 extern struct device_node *of_get_next_parent(struct device_node *node);
290 extern struct device_node *of_get_next_child(const struct device_node *node,
292 extern struct device_node *of_get_next_child_with_prefix(const struct device_node *node,
296 const struct device_node *node, struct device_node *prev);
298 const struct device_node *node, struct device_node *prev);
302 extern struct device_node *of_get_child_by_name(const struct device_node *node,
304 extern struct device_node *of_get_available_child_by_name(const struct device_node *node,
313 extern struct property *of_find_property(const struct device_node *np,
362 extern const void *of_get_property(const struct device_node *node,
376 const struct of_device_id *matches, const struct device_node *node);
378 extern int of_alias_from_compatible(const struct device_node *node, char *alias,
412 * of_machine_is_compatible - Test root of device tree for a given compatible value
413 * @compat: compatible string to look for in root node's compatible property.
415 * Return: true if the root node has the given value in its compatible property.
424 extern int of_add_property(struct device_node *np, struct property *prop);
425 extern int of_remove_property(struct device_node *np, struct property *prop);
426 extern int of_update_property(struct device_node *np, struct property *newprop);
446 const __be32 *of_prop_next_u32(const struct property *prop, const __be32 *cur,
449 * struct property *prop;
455 const char *of_prop_next_string(const struct property *prop, const char *cur);
498 return "<no-node>"; in of_node_full_name()
537 static inline struct device_node *of_get_parent(const struct device_node *node) in of_get_parent() argument
542 static inline struct device_node *of_get_next_parent(struct device_node *node) in of_get_next_parent() argument
548 const struct device_node *node, struct device_node *prev) in of_get_next_child() argument
554 const struct device_node *node, struct device_node *prev) in of_get_next_available_child() argument
560 const struct device_node *node, struct device_node *prev) in of_get_next_reserved_child() argument
571 #define of_fwnode_handle(node) NULL argument
580 const struct device_node *node, in of_get_child_by_name() argument
587 const struct device_node *node, in of_get_available_child_by_name() argument
615 static inline struct property *of_find_property(const struct device_node *np, in of_find_property()
639 return -ENOSYS; in of_property_count_elems_of_size()
645 return -ENOSYS; in of_property_read_u16_index()
651 return -ENOSYS; in of_property_read_u32_index()
657 return -ENOSYS; in of_property_read_u64_index()
660 static inline const void *of_get_property(const struct device_node *node, in of_get_property() argument
680 return -ENODEV; in of_cpu_node_to_id()
708 return -ENOSYS; in of_property_read_variable_u8_array()
715 return -ENOSYS; in of_property_read_variable_u16_array()
724 return -ENOSYS; in of_property_read_variable_u32_array()
730 return -ENOSYS; in of_property_read_u64()
739 return -ENOSYS; in of_property_read_variable_u64_array()
746 return -ENOSYS; in of_property_read_string()
753 return -ENOSYS; in of_property_match_string()
760 return -ENOSYS; in of_property_read_string_helper()
770 return -ENOSYS; in __of_parse_phandle_with_args()
779 return -ENOSYS; in of_parse_phandle_with_args_map()
786 return -ENOSYS; in of_count_phandle_with_args()
792 return -ENODEV; in of_modalias()
797 return -ENODEV; in of_request_module()
806 return -ENOSYS; in of_phandle_iterator_init()
811 return -ENOSYS; in of_phandle_iterator_next()
823 return -ENOSYS; in of_alias_get_id()
828 return -ENOSYS; in of_alias_get_highest_id()
836 static inline int of_add_property(struct device_node *np, struct property *prop) in of_add_property()
841 static inline int of_remove_property(struct device_node *np, struct property *prop) in of_remove_property()
856 static inline const __be32 *of_prop_next_u32(const struct property *prop, in of_prop_next_u32()
862 static inline const char *of_prop_next_string(const struct property *prop, in of_prop_next_string()
887 static inline int of_property_check_flag(const struct property *p, in of_property_check_flag()
893 static inline void of_property_set_flag(struct property *p, unsigned long flag) in of_property_set_flag()
897 static inline void of_property_clear_flag(struct property *p, unsigned long flag) in of_property_clear_flag()
905 return -EINVAL; in of_map_id()
930 for (pp = dn->properties; pp != NULL; pp = pp->next)
946 return -ENOSYS; in of_numa_init()
970 * of_parse_phandle - Resolve a phandle property to a device_node pointer
971 * @np: Pointer to device node holding phandle property
972 * @phandle_name: Name of property holding a phandle value
973 * @index: For properties holding a table of phandles, this is the index into
993 * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
994 * @np: pointer to a device tree node containing a list
995 * @list_name: property name that contains a list
996 * @cells_name: property name that specifies phandles' arguments count
997 * @index: index of a phandle to parse out
1004 * Caller is responsible to call of_node_put() on the returned out_args->np
1010 * #list-cells = <2>;
1014 * #list-cells = <1>;
1021 * To get a device_node of the ``node2`` node you may call this:
1022 * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
1030 int cell_count = -1; in of_parse_phandle_with_args()
1032 /* If cells_name is NULL we assume a cell count of 0 */ in of_parse_phandle_with_args()
1041 * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list
1042 * @np: pointer to a device tree node containing a list
1043 * @list_name: property name that contains a list
1045 * @index: index of a phandle to parse out
1052 * Caller is responsible to call of_node_put() on the returned out_args->np
1067 * To get a device_node of the ``node2`` node you may call this:
1081 * of_parse_phandle_with_optional_args() - Find a node pointed by phandle in a list
1082 * @np: pointer to a device tree node containing a list
1083 * @list_name: property name that contains a list
1084 * @cells_name: property name that specifies phandles' arguments count
1085 * @index: index of a phandle to parse out
1088 * Same as of_parse_phandle_with_args() except that if the cells_name property
1091 * This is used to useful, if you have a phandle which didn't have arguments
1092 * before and thus doesn't have a '#*-cells' property but is now migrated to
1106 * of_phandle_args_equal() - Compare two of_phandle_args
1110 * Return: True if a1 and a2 are the same (same node pointer, same phandle
1116 return a1->np == a2->np && in of_phandle_args_equal()
1117 a1->args_count == a2->args_count && in of_phandle_args_equal()
1118 !memcmp(a1->args, a2->args, sizeof(a1->args[0]) * a1->args_count); in of_phandle_args_equal()
1122 * of_property_count_u8_elems - Count the number of u8 elements in a property
1124 * @np: device node from which the property value is to be read.
1125 * @propname: name of the property to be searched.
1127 * Search for a property in a device node and count the number of u8 elements
1130 * Return: The number of elements on sucess, -EINVAL if the property does
1131 * not exist or its length does not match a multiple of u8 and -ENODATA if the
1132 * property does not have a value.
1141 * of_property_count_u16_elems - Count the number of u16 elements in a property
1143 * @np: device node from which the property value is to be read.
1144 * @propname: name of the property to be searched.
1146 * Search for a property in a device node and count the number of u16 elements
1149 * Return: The number of elements on sucess, -EINVAL if the property does
1150 * not exist or its length does not match a multiple of u16 and -ENODATA if the
1151 * property does not have a value.
1160 * of_property_count_u32_elems - Count the number of u32 elements in a property
1162 * @np: device node from which the property value is to be read.
1163 * @propname: name of the property to be searched.
1165 * Search for a property in a device node and count the number of u32 elements
1168 * Return: The number of elements on sucess, -EINVAL if the property does
1169 * not exist or its length does not match a multiple of u32 and -ENODATA if the
1170 * property does not have a value.
1179 * of_property_count_u64_elems - Count the number of u64 elements in a property
1181 * @np: device node from which the property value is to be read.
1182 * @propname: name of the property to be searched.
1184 * Search for a property in a device node and count the number of u64 elements
1187 * Return: The number of elements on sucess, -EINVAL if the property does
1188 * not exist or its length does not match a multiple of u64 and -ENODATA if the
1189 * property does not have a value.
1198 * of_property_read_string_array() - Read an array of strings from a multiple
1199 * strings property.
1200 * @np: device node from which the property value is to be read.
1201 * @propname: name of the property to be searched.
1205 * Search for a property in a device tree node and retrieve a list of
1206 * terminated string values (pointer to data, not a copy) in that property.
1208 * Return: If @out_strs is NULL, the number of strings in the property is returned.
1218 * of_property_count_strings() - Find and return the number of strings from a
1219 * multiple strings property.
1220 * @np: device node from which the property value is to be read.
1221 * @propname: name of the property to be searched.
1223 * Search for a property in a device tree node and retrieve the number of null
1226 * Return: The number of strings on success, -EINVAL if the property does not
1227 * exist, -ENODATA if property does not have a value, and -EILSEQ if the string
1228 * is not null-terminated within the length of the property data.
1237 * of_property_read_string_index() - Find and read a string from a multiple
1238 * strings property.
1239 * @np: device node from which the property value is to be read.
1240 * @propname: name of the property to be searched.
1245 * Search for a property in a device tree node and retrieve a null
1246 * terminated string value (pointer to data, not a copy) in the list of strings
1247 * contained in that property.
1249 * Return: 0 on success, -EINVAL if the property does not exist, -ENODATA if
1250 * property does not have a value, and -EILSEQ if the string is not
1251 * null-terminated within the length of the property data.
1253 * The out_string pointer is modified only if a valid string can be decoded.
1264 * of_property_present - Test if a property is present in a node
1265 * @np: device node to search for the property.
1266 * @propname: name of the property to be searched.
1268 * Test for a property present in a device node.
1270 * Return: true if the property exists false otherwise.
1274 struct property *prop = of_find_property(np, propname, NULL); in of_property_present()
1280 * of_property_read_u8_array - Find and read an array of u8 from a property.
1282 * @np: device node from which the property value is to be read.
1283 * @propname: name of the property to be searched.
1287 * Search for a property in a device node and read 8-bit value(s) from
1291 * ``property = /bits/ 8 <0x50 0x60 0x70>;``
1293 * Return: 0 on success, -EINVAL if the property does not exist,
1294 * -ENODATA if property does not have a value, and -EOVERFLOW if the
1295 * property data isn't large enough.
1297 * The out_values is modified only if a valid u8 value can be decoded.
1312 * of_property_read_u16_array - Find and read an array of u16 from a property.
1314 * @np: device node from which the property value is to be read.
1315 * @propname: name of the property to be searched.
1319 * Search for a property in a device node and read 16-bit value(s) from
1323 * ``property = /bits/ 16 <0x5000 0x6000 0x7000>;``
1325 * Return: 0 on success, -EINVAL if the property does not exist,
1326 * -ENODATA if property does not have a value, and -EOVERFLOW if the
1327 * property data isn't large enough.
1329 * The out_values is modified only if a valid u16 value can be decoded.
1344 * of_property_read_u32_array - Find and read an array of 32 bit integers
1345 * from a property.
1347 * @np: device node from which the property value is to be read.
1348 * @propname: name of the property to be searched.
1352 * Search for a property in a device node and read 32-bit value(s) from
1355 * Return: 0 on success, -EINVAL if the property does not exist,
1356 * -ENODATA if property does not have a value, and -EOVERFLOW if the
1357 * property data isn't large enough.
1359 * The out_values is modified only if a valid u32 value can be decoded.
1374 * of_property_read_u64_array - Find and read an array of 64 bit integers
1375 * from a property.
1377 * @np: device node from which the property value is to be read.
1378 * @propname: name of the property to be searched.
1382 * Search for a property in a device node and read 64-bit value(s) from
1385 * Return: 0 on success, -EINVAL if the property does not exist,
1386 * -ENODATA if property does not have a value, and -EOVERFLOW if the
1387 * property data isn't large enough.
1389 * The out_values is modified only if a valid u64 value can be decoded.
1438 for (struct {const struct property *prop; const __be32 *item; } _it = \
1466 #define for_each_child_of_node(parent, child) \ argument
1467 for (child = of_get_next_child(parent, NULL); child != NULL; \
1468 child = of_get_next_child(parent, child))
1470 #define for_each_child_of_node_scoped(parent, child) \ argument
1471 for (struct device_node *child __free(device_node) = \
1473 child != NULL; \
1474 child = of_get_next_child(parent, child))
1476 #define for_each_child_of_node_with_prefix(parent, child, prefix) \ argument
1477 for (struct device_node *child __free(device_node) = \
1479 child != NULL; \
1480 child = of_get_next_child_with_prefix(parent, child, prefix))
1482 #define for_each_available_child_of_node(parent, child) \ argument
1483 for (child = of_get_next_available_child(parent, NULL); child != NULL; \
1484 child = of_get_next_available_child(parent, child))
1485 #define for_each_reserved_child_of_node(parent, child) \ argument
1486 for (child = of_get_next_reserved_child(parent, NULL); child != NULL; \
1487 child = of_get_next_reserved_child(parent, child))
1489 #define for_each_available_child_of_node_scoped(parent, child) \ argument
1490 for (struct device_node *child __free(device_node) = \
1492 child != NULL; \
1493 child = of_get_next_available_child(parent, child))
1505 struct device_node *child; in of_get_child_count() local
1508 for_each_child_of_node(np, child) in of_get_child_count()
1516 struct device_node *child; in of_get_available_child_count() local
1519 for_each_available_child_of_node(np, child) in of_get_available_child_count()
1555 * struct of_changeset_entry - Holds a changeset entry
1557 * @node: list_head for the log list
1559 * @np: pointer to the device node affected
1560 * @prop: pointer to the property affected
1561 * @old_prop: hold a pointer to the original property
1563 * Every modification of the device tree during a changeset
1564 * is held in a list of of_changeset_entry structures.
1565 * That way we can recover from a partial application, or we can
1569 struct list_head node; member
1572 struct property *prop;
1573 struct property *old_prop;
1577 * struct of_changeset - changeset tracker structure
1581 * changesets are a convenient way to apply bulk changes to the
1582 * live tree. In case of an error, changes are rolled-back.
1611 struct property *prop);
1626 struct device_node *np, struct property *prop) in of_changeset_add_property()
1632 struct device_node *np, struct property *prop) in of_changeset_remove_property()
1638 struct device_node *np, struct property *prop) in of_changeset_update_property()
1675 return -EINVAL; in of_reconfig_notifier_register()
1679 return -EINVAL; in of_reconfig_notifier_unregister()
1684 return -EINVAL; in of_reconfig_notify()
1689 return -EINVAL; in of_reconfig_get_state_change()
1694 * of_device_is_system_power_controller - Tells if system-power-controller is found for device_node
1701 return of_property_read_bool(np, "system-power-controller"); in of_device_is_system_power_controller()
1705 * of_have_populated_dt() - Has DT been populated by bootloader
1707 * Return: True if a DTB has been populated by the bootloader and it isn't the
1735 "pre-apply", in of_overlay_action_name()
1736 "post-apply", in of_overlay_action_name()
1737 "pre-remove", in of_overlay_action_name()
1738 "post-remove", in of_overlay_action_name()
1764 return -ENOTSUPP; in of_overlay_fdt_apply()
1769 return -ENOTSUPP; in of_overlay_remove()
1774 return -ENOTSUPP; in of_overlay_remove_all()