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.
22 #include <linux/property.h>
31 struct property { struct
35 struct property *next; argument
57 struct property *properties; argument
58 struct property *deadprops; /* removed properties */
60 struct device_node *child; member
94 struct device_node *node; member
99 struct property *prop;
100 struct property *old_prop;
103 /* initialize a node */
106 static inline void of_node_init(struct device_node *node) in of_node_init() argument
109 kobject_init(&node->kobj, &of_node_ktype); in of_node_init()
111 fwnode_init(&node->fwnode, &of_fwnode_ops); in of_node_init()
115 #define of_node_kobj(n) (&(n)->kobj)
121 extern struct device_node *of_node_get(struct device_node *node);
122 extern void of_node_put(struct device_node *node);
124 /* Dummy ref counting routines - to be implemented later */
125 static inline struct device_node *of_node_get(struct device_node *node) in of_node_get() argument
127 return node; in of_node_get()
129 static inline void of_node_put(struct device_node *node) { } in of_node_put() argument
150 #define OF_BAD_ADDR ((u64)-1)
157 return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &of_fwnode_ops; in is_of_node()
170 #define of_fwnode_handle(node) \ argument
172 typeof(node) __of_fwnode_handle_node = (node); \
175 &__of_fwnode_handle_node->fwnode : NULL; \
183 static inline bool of_node_is_root(const struct device_node *node) in of_node_is_root() argument
185 return node && (node->parent == NULL); in of_node_is_root()
190 return test_bit(flag, &n->_flags); in of_node_check_flag()
196 return test_and_set_bit(flag, &n->_flags); in of_node_test_and_set_flag()
201 set_bit(flag, &n->_flags); in of_node_set_flag()
206 clear_bit(flag, &n->_flags); in of_node_clear_flag()
210 static inline int of_property_check_flag(struct property *p, unsigned long flag) in of_property_check_flag()
212 return test_bit(flag, &p->_flags); in of_property_check_flag()
215 static inline void of_property_set_flag(struct property *p, unsigned long flag) in of_property_set_flag()
217 set_bit(flag, &p->_flags); in of_property_set_flag()
220 static inline void of_property_clear_flag(struct property *p, unsigned long flag) in of_property_clear_flag()
222 clear_bit(flag, &p->_flags); in of_property_clear_flag()
233 /* Helper to read a big number; size is in cells (not bytes) */
237 for (; size--; cell++) in of_read_number()
253 #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
254 #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
261 return np ? np->full_name : "<no-node>"; in of_node_full_name()
286 extern struct device_node *of_get_parent(const struct device_node *node);
287 extern struct device_node *of_get_next_parent(struct device_node *node);
288 extern struct device_node *of_get_next_child(const struct device_node *node,
291 const struct device_node *node, struct device_node *prev);
295 extern struct device_node *of_get_child_by_name(const struct device_node *node,
304 extern struct property *of_find_property(const struct device_node *np,
349 extern const void *of_get_property(const struct device_node *node,
358 for (pp = dn->properties; pp != NULL; pp = pp->next)
363 const struct of_device_id *matches, const struct device_node *node);
364 extern int of_modalias_node(struct device_node *node, char *modalias, int len);
402 extern int of_add_property(struct device_node *np, struct property *prop);
403 extern int of_remove_property(struct device_node *np, struct property *prop);
404 extern int of_update_property(struct device_node *np, struct property *newprop);
419 * of_property_read_u8_array - Find and read an array of u8 from a property.
421 * @np: device node from which the property value is to be read.
422 * @propname: name of the property to be searched.
426 * Search for a property in a device node and read 8-bit value(s) from
430 * ``property = /bits/ 8 <0x50 0x60 0x70>;``
432 * Return: 0 on success, -EINVAL if the property does not exist,
433 * -ENODATA if property does not have a value, and -EOVERFLOW if the
434 * property data isn't large enough.
436 * The out_values is modified only if a valid u8 value can be decoded.
451 * of_property_read_u16_array - Find and read an array of u16 from a property.
453 * @np: device node from which the property value is to be read.
454 * @propname: name of the property to be searched.
458 * Search for a property in a device node and read 16-bit value(s) from
462 * ``property = /bits/ 16 <0x5000 0x6000 0x7000>;``
464 * Return: 0 on success, -EINVAL if the property does not exist,
465 * -ENODATA if property does not have a value, and -EOVERFLOW if the
466 * property data isn't large enough.
468 * The out_values is modified only if a valid u16 value can be decoded.
483 * of_property_read_u32_array - Find and read an array of 32 bit integers
484 * from a property.
486 * @np: device node from which the property value is to be read.
487 * @propname: name of the property to be searched.
491 * Search for a property in a device node and read 32-bit value(s) from
494 * Return: 0 on success, -EINVAL if the property does not exist,
495 * -ENODATA if property does not have a value, and -EOVERFLOW if the
496 * property data isn't large enough.
498 * The out_values is modified only if a valid u32 value can be decoded.
513 * of_property_read_u64_array - Find and read an array of 64 bit integers
514 * from a property.
516 * @np: device node from which the property value is to be read.
517 * @propname: name of the property to be searched.
521 * Search for a property in a device node and read 64-bit value(s) from
524 * Return: 0 on success, -EINVAL if the property does not exist,
525 * -ENODATA if property does not have a value, and -EOVERFLOW if the
526 * property data isn't large enough.
528 * The out_values is modified only if a valid u64 value can be decoded.
543 * struct property *prop;
550 const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
553 * struct property *prop;
559 const char *of_prop_next_string(struct property *prop, const char *cur);
606 return "<no-node>"; in of_node_full_name()
645 static inline struct device_node *of_get_parent(const struct device_node *node) in of_get_parent() argument
650 static inline struct device_node *of_get_next_parent(struct device_node *node) in of_get_next_parent() argument
656 const struct device_node *node, struct device_node *prev) in of_get_next_child() argument
662 const struct device_node *node, struct device_node *prev) in of_get_next_available_child() argument
673 #define of_fwnode_handle(node) NULL argument
687 const struct device_node *node, in of_get_child_by_name() argument
715 static inline struct property *of_find_property(const struct device_node *np, in of_find_property()
733 return -ENOSYS; in of_property_count_elems_of_size()
739 return -ENOSYS; in of_property_read_u8_array()
745 return -ENOSYS; in of_property_read_u16_array()
752 return -ENOSYS; in of_property_read_u32_array()
759 return -ENOSYS; in of_property_read_u64_array()
765 return -ENOSYS; in of_property_read_u32_index()
771 return -ENOSYS; in of_property_read_u64_index()
774 static inline const void *of_get_property(const struct device_node *node, in of_get_property() argument
812 return -ENOSYS; in of_property_read_variable_u8_array()
819 return -ENOSYS; in of_property_read_variable_u16_array()
828 return -ENOSYS; in of_property_read_variable_u32_array()
834 return -ENOSYS; in of_property_read_u64()
843 return -ENOSYS; in of_property_read_variable_u64_array()
850 return -ENOSYS; in of_property_read_string()
857 return -ENOSYS; in of_property_match_string()
864 return -ENOSYS; in of_property_read_string_helper()
880 return -ENOSYS; in of_parse_phandle_with_args()
889 return -ENOSYS; in of_parse_phandle_with_args_map()
896 return -ENOSYS; in of_parse_phandle_with_fixed_args()
903 return -ENOSYS; in of_count_phandle_with_args()
912 return -ENOSYS; in of_phandle_iterator_init()
917 return -ENOSYS; in of_phandle_iterator_next()
929 return -ENOSYS; in of_alias_get_id()
934 return -ENOSYS; in of_alias_get_highest_id()
941 return -ENOSYS; in of_alias_get_alias_list()
949 static inline int of_add_property(struct device_node *np, struct property *prop) in of_add_property()
954 static inline int of_remove_property(struct device_node *np, struct property *prop) in of_remove_property()
964 static inline const __be32 *of_prop_next_u32(struct property *prop, in of_prop_next_u32()
970 static inline const char *of_prop_next_string(struct property *prop, in of_prop_next_string()
995 static inline int of_property_check_flag(struct property *p, unsigned long flag) in of_property_check_flag()
1000 static inline void of_property_set_flag(struct property *p, unsigned long flag) in of_property_set_flag()
1004 static inline void of_property_clear_flag(struct property *p, unsigned long flag) in of_property_clear_flag()
1010 return -ENODEV; in of_cpu_node_to_id()
1017 return -EINVAL; in of_map_id()
1036 static inline int of_prop_val_eq(struct property *p1, struct property *p2) in of_prop_val_eq()
1038 return p1->length == p2->length && in of_prop_val_eq()
1039 !memcmp(p1->value, p2->value, (size_t)p1->length); in of_prop_val_eq()
1056 return -ENOSYS; in of_numa_init()
1080 * of_property_count_u8_elems - Count the number of u8 elements in a property
1082 * @np: device node from which the property value is to be read.
1083 * @propname: name of the property to be searched.
1085 * Search for a property in a device node and count the number of u8 elements
1088 * Return: The number of elements on sucess, -EINVAL if the property does
1089 * not exist or its length does not match a multiple of u8 and -ENODATA if the
1090 * property does not have a value.
1099 * of_property_count_u16_elems - Count the number of u16 elements in a property
1101 * @np: device node from which the property value is to be read.
1102 * @propname: name of the property to be searched.
1104 * Search for a property in a device node and count the number of u16 elements
1107 * Return: The number of elements on sucess, -EINVAL if the property does
1108 * not exist or its length does not match a multiple of u16 and -ENODATA if the
1109 * property does not have a value.
1118 * of_property_count_u32_elems - Count the number of u32 elements in a property
1120 * @np: device node from which the property value is to be read.
1121 * @propname: name of the property to be searched.
1123 * Search for a property in a device node and count the number of u32 elements
1126 * Return: The number of elements on sucess, -EINVAL if the property does
1127 * not exist or its length does not match a multiple of u32 and -ENODATA if the
1128 * property does not have a value.
1137 * of_property_count_u64_elems - Count the number of u64 elements in a property
1139 * @np: device node from which the property value is to be read.
1140 * @propname: name of the property to be searched.
1142 * Search for a property in a device node and count the number of u64 elements
1145 * Return: The number of elements on sucess, -EINVAL if the property does
1146 * not exist or its length does not match a multiple of u64 and -ENODATA if the
1147 * property does not have a value.
1156 * of_property_read_string_array() - Read an array of strings from a multiple
1157 * strings property.
1158 * @np: device node from which the property value is to be read.
1159 * @propname: name of the property to be searched.
1163 * Search for a property in a device tree node and retrieve a list of
1164 * terminated string values (pointer to data, not a copy) in that property.
1166 * Return: If @out_strs is NULL, the number of strings in the property is returned.
1176 * of_property_count_strings() - Find and return the number of strings from a
1177 * multiple strings property.
1178 * @np: device node from which the property value is to be read.
1179 * @propname: name of the property to be searched.
1181 * Search for a property in a device tree node and retrieve the number of null
1184 * Return: The number of strings on success, -EINVAL if the property does not
1185 * exist, -ENODATA if property does not have a value, and -EILSEQ if the string
1186 * is not null-terminated within the length of the property data.
1195 * of_property_read_string_index() - Find and read a string from a multiple
1196 * strings property.
1197 * @np: device node from which the property value is to be read.
1198 * @propname: name of the property to be searched.
1203 * Search for a property in a device tree node and retrieve a null
1204 * terminated string value (pointer to data, not a copy) in the list of strings
1205 * contained in that property.
1207 * Return: 0 on success, -EINVAL if the property does not exist, -ENODATA if
1208 * property does not have a value, and -EILSEQ if the string is not
1209 * null-terminated within the length of the property data.
1211 * The out_string pointer is modified only if a valid string can be decoded.
1222 * of_property_read_bool - Find a property
1223 * @np: device node from which the property value is to be read.
1224 * @propname: name of the property to be searched.
1226 * Search for a property in a device node.
1228 * Return: true if the property exists false otherwise.
1233 struct property *prop = of_find_property(np, propname, NULL); in of_property_read_bool()
1300 #define for_each_child_of_node(parent, child) \ argument
1301 for (child = of_get_next_child(parent, NULL); child != NULL; \
1302 child = of_get_next_child(parent, child))
1303 #define for_each_available_child_of_node(parent, child) \ argument
1304 for (child = of_get_next_available_child(parent, NULL); child != NULL; \
1305 child = of_get_next_available_child(parent, child))
1317 struct device_node *child; in of_get_child_count() local
1320 for_each_child_of_node(np, child) in of_get_child_count()
1328 struct device_node *child; in of_get_available_child_count() local
1331 for_each_available_child_of_node(np, child) in of_get_available_child_count()
1367 * struct of_changeset_entry - Holds a changeset entry
1369 * @node: list_head for the log list
1371 * @np: pointer to the device node affected
1372 * @prop: pointer to the property affected
1373 * @old_prop: hold a pointer to the original property
1375 * Every modification of the device tree during a changeset
1376 * is held in a list of of_changeset_entry structures.
1377 * That way we can recover from a partial application, or we can
1381 struct list_head node; member
1384 struct property *prop;
1385 struct property *old_prop;
1389 * struct of_changeset - changeset tracker structure
1393 * changesets are a convenient way to apply bulk changes to the
1394 * live tree. In case of an error, changes are rolled-back.
1421 struct property *prop);
1436 struct device_node *np, struct property *prop) in of_changeset_add_property()
1442 struct device_node *np, struct property *prop) in of_changeset_remove_property()
1448 struct device_node *np, struct property *prop) in of_changeset_update_property()
1455 return -EINVAL; in of_reconfig_notifier_register()
1459 return -EINVAL; in of_reconfig_notifier_unregister()
1464 return -EINVAL; in of_reconfig_notify()
1469 return -EINVAL; in of_reconfig_get_state_change()
1474 * of_device_is_system_power_controller - Tells if system-power-controller is found for device_node
1481 return of_property_read_bool(np, "system-power-controller"); in of_device_is_system_power_controller()
1515 return -ENOTSUPP; in of_overlay_fdt_apply()
1520 return -ENOTSUPP; in of_overlay_remove()
1525 return -ENOTSUPP; in of_overlay_remove_all()