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.
19 #include <linux/property.h>
27 struct property { struct
31 struct property *next; argument
53 struct property *properties; argument
54 struct property *deadprops; /* removed properties */
56 struct device_node *child; member
90 struct device_node *node; member
95 struct property *prop;
96 struct property *old_prop;
103 * of_node_init - initialize a devicetree node
104 * @node: Pointer to device node that has been created by kzalloc()
107 * on @node when done to free the memory allocated for it. If the node
108 * is NOT a dynamic node the memory will not be freed. The decision of
109 * whether to free the memory will be done by node->release(), which is
112 static inline void of_node_init(struct device_node *node) in of_node_init() argument
115 kobject_init(&node->kobj, &of_node_ktype); in of_node_init()
117 fwnode_init(&node->fwnode, &of_fwnode_ops); in of_node_init()
121 #define of_node_kobj(n) (&(n)->kobj)
127 extern struct device_node *of_node_get(struct device_node *node);
128 extern void of_node_put(struct device_node *node);
130 /* Dummy ref counting routines - to be implemented later */
131 static inline struct device_node *of_node_get(struct device_node *node) in of_node_get() argument
133 return node; in of_node_get()
135 static inline void of_node_put(struct device_node *node) { } in of_node_put() argument
155 #define OF_BAD_ADDR ((u64)-1)
162 return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &of_fwnode_ops; in is_of_node()
175 #define of_fwnode_handle(node) \ argument
177 typeof(node) __of_fwnode_handle_node = (node); \
180 &__of_fwnode_handle_node->fwnode : NULL; \
188 static inline bool of_node_is_root(const struct device_node *node) in of_node_is_root() argument
190 return node && (node->parent == NULL); in of_node_is_root()
195 return test_bit(flag, &n->_flags); in of_node_check_flag()
201 return test_and_set_bit(flag, &n->_flags); in of_node_test_and_set_flag()
206 set_bit(flag, &n->_flags); in of_node_set_flag()
211 clear_bit(flag, &n->_flags); in of_node_clear_flag()
215 static inline int of_property_check_flag(const struct property *p, unsigned long flag) in of_property_check_flag()
217 return test_bit(flag, &p->_flags); in of_property_check_flag()
220 static inline void of_property_set_flag(struct property *p, unsigned long flag) in of_property_set_flag()
222 set_bit(flag, &p->_flags); in of_property_set_flag()
225 static inline void of_property_clear_flag(struct property *p, unsigned long flag) in of_property_clear_flag()
227 clear_bit(flag, &p->_flags); in of_property_clear_flag()
238 /* Helper to read a big number; size is in cells (not bytes) */
242 for (; size--; cell++) in of_read_number()
258 #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
259 #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
266 return np ? np->full_name : "<no-node>"; in of_node_full_name()
291 extern struct device_node *of_get_parent(const struct device_node *node);
292 extern struct device_node *of_get_next_parent(struct device_node *node);
293 extern struct device_node *of_get_next_child(const struct device_node *node,
296 const struct device_node *node, struct device_node *prev);
300 extern struct device_node *of_get_child_by_name(const struct device_node *node,
309 extern struct property *of_find_property(const struct device_node *np,
354 extern const void *of_get_property(const struct device_node *node,
366 for (pp = dn->properties; pp != NULL; pp = pp->next)
371 const struct of_device_id *matches, const struct device_node *node);
373 extern int of_alias_from_compatible(const struct device_node *node, char *alias,
407 extern int of_add_property(struct device_node *np, struct property *prop);
408 extern int of_remove_property(struct device_node *np, struct property *prop);
409 extern int of_update_property(struct device_node *np, struct property *newprop);
424 * struct property *prop;
431 const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
434 * struct property *prop;
440 const char *of_prop_next_string(struct property *prop, const char *cur);
483 return "<no-node>"; in of_node_full_name()
522 static inline struct device_node *of_get_parent(const struct device_node *node) in of_get_parent() argument
527 static inline struct device_node *of_get_next_parent(struct device_node *node) in of_get_next_parent() argument
533 const struct device_node *node, struct device_node *prev) in of_get_next_child() argument
539 const struct device_node *node, struct device_node *prev) in of_get_next_available_child() argument
550 #define of_fwnode_handle(node) NULL argument
564 const struct device_node *node, in of_get_child_by_name() argument
592 static inline struct property *of_find_property(const struct device_node *np, in of_find_property()
610 return -ENOSYS; in of_property_count_elems_of_size()
616 return -ENOSYS; in of_property_read_u32_index()
622 return -ENOSYS; in of_property_read_u64_index()
625 static inline const void *of_get_property(const struct device_node *node, in of_get_property() argument
645 return -ENODEV; in of_cpu_node_to_id()
673 return -ENOSYS; in of_property_read_variable_u8_array()
680 return -ENOSYS; in of_property_read_variable_u16_array()
689 return -ENOSYS; in of_property_read_variable_u32_array()
695 return -ENOSYS; in of_property_read_u64()
704 return -ENOSYS; in of_property_read_variable_u64_array()
711 return -ENOSYS; in of_property_read_string()
718 return -ENOSYS; in of_property_match_string()
725 return -ENOSYS; in of_property_read_string_helper()
735 return -ENOSYS; in __of_parse_phandle_with_args()
744 return -ENOSYS; in of_parse_phandle_with_args_map()
751 return -ENOSYS; in of_count_phandle_with_args()
757 return -ENODEV; in of_modalias()
762 return -ENODEV; in of_request_module()
771 return -ENOSYS; in of_phandle_iterator_init()
776 return -ENOSYS; in of_phandle_iterator_next()
788 return -ENOSYS; in of_alias_get_id()
793 return -ENOSYS; in of_alias_get_highest_id()
801 static inline int of_add_property(struct device_node *np, struct property *prop) in of_add_property()
806 static inline int of_remove_property(struct device_node *np, struct property *prop) in of_remove_property()
816 static inline const __be32 *of_prop_next_u32(struct property *prop, in of_prop_next_u32()
822 static inline const char *of_prop_next_string(struct property *prop, in of_prop_next_string()
847 static inline int of_property_check_flag(const struct property *p, in of_property_check_flag()
853 static inline void of_property_set_flag(struct property *p, unsigned long flag) in of_property_set_flag()
857 static inline void of_property_clear_flag(struct property *p, unsigned long flag) in of_property_clear_flag()
865 return -EINVAL; in of_map_id()
889 static inline int of_prop_val_eq(struct property *p1, struct property *p2) in of_prop_val_eq()
891 return p1->length == p2->length && in of_prop_val_eq()
892 !memcmp(p1->value, p2->value, (size_t)p1->length); in of_prop_val_eq()
909 return -ENOSYS; in of_numa_init()
933 * of_parse_phandle - Resolve a phandle property to a device_node pointer
934 * @np: Pointer to device node holding phandle property
935 * @phandle_name: Name of property holding a phandle value
936 * @index: For properties holding a table of phandles, this is the index into
956 * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
957 * @np: pointer to a device tree node containing a list
958 * @list_name: property name that contains a list
959 * @cells_name: property name that specifies phandles' arguments count
960 * @index: index of a phandle to parse out
967 * Caller is responsible to call of_node_put() on the returned out_args->np
973 * #list-cells = <2>;
977 * #list-cells = <1>;
984 * To get a device_node of the ``node2`` node you may call this:
985 * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
993 int cell_count = -1; in of_parse_phandle_with_args()
995 /* If cells_name is NULL we assume a cell count of 0 */ in of_parse_phandle_with_args()
1004 * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list
1005 * @np: pointer to a device tree node containing a list
1006 * @list_name: property name that contains a list
1008 * @index: index of a phandle to parse out
1015 * Caller is responsible to call of_node_put() on the returned out_args->np
1030 * To get a device_node of the ``node2`` node you may call this:
1044 * of_parse_phandle_with_optional_args() - Find a node pointed by phandle in a list
1045 * @np: pointer to a device tree node containing a list
1046 * @list_name: property name that contains a list
1047 * @cells_name: property name that specifies phandles' arguments count
1048 * @index: index of a phandle to parse out
1051 * Same as of_parse_phandle_with_args() except that if the cells_name property
1054 * This is used to useful, if you have a phandle which didn't have arguments
1055 * before and thus doesn't have a '#*-cells' property but is now migrated to
1069 * of_property_count_u8_elems - Count the number of u8 elements in a property
1071 * @np: device node from which the property value is to be read.
1072 * @propname: name of the property to be searched.
1074 * Search for a property in a device node and count the number of u8 elements
1077 * Return: The number of elements on sucess, -EINVAL if the property does
1078 * not exist or its length does not match a multiple of u8 and -ENODATA if the
1079 * property does not have a value.
1088 * of_property_count_u16_elems - Count the number of u16 elements in a property
1090 * @np: device node from which the property value is to be read.
1091 * @propname: name of the property to be searched.
1093 * Search for a property in a device node and count the number of u16 elements
1096 * Return: The number of elements on sucess, -EINVAL if the property does
1097 * not exist or its length does not match a multiple of u16 and -ENODATA if the
1098 * property does not have a value.
1107 * of_property_count_u32_elems - Count the number of u32 elements in a property
1109 * @np: device node from which the property value is to be read.
1110 * @propname: name of the property to be searched.
1112 * Search for a property in a device node and count the number of u32 elements
1115 * Return: The number of elements on sucess, -EINVAL if the property does
1116 * not exist or its length does not match a multiple of u32 and -ENODATA if the
1117 * property does not have a value.
1126 * of_property_count_u64_elems - Count the number of u64 elements in a property
1128 * @np: device node from which the property value is to be read.
1129 * @propname: name of the property to be searched.
1131 * Search for a property in a device node and count the number of u64 elements
1134 * Return: The number of elements on sucess, -EINVAL if the property does
1135 * not exist or its length does not match a multiple of u64 and -ENODATA if the
1136 * property does not have a value.
1145 * of_property_read_string_array() - Read an array of strings from a multiple
1146 * strings property.
1147 * @np: device node from which the property value is to be read.
1148 * @propname: name of the property to be searched.
1152 * Search for a property in a device tree node and retrieve a list of
1153 * terminated string values (pointer to data, not a copy) in that property.
1155 * Return: If @out_strs is NULL, the number of strings in the property is returned.
1165 * of_property_count_strings() - Find and return the number of strings from a
1166 * multiple strings property.
1167 * @np: device node from which the property value is to be read.
1168 * @propname: name of the property to be searched.
1170 * Search for a property in a device tree node and retrieve the number of null
1173 * Return: The number of strings on success, -EINVAL if the property does not
1174 * exist, -ENODATA if property does not have a value, and -EILSEQ if the string
1175 * is not null-terminated within the length of the property data.
1184 * of_property_read_string_index() - Find and read a string from a multiple
1185 * strings property.
1186 * @np: device node from which the property value is to be read.
1187 * @propname: name of the property to be searched.
1192 * Search for a property in a device tree node and retrieve a null
1193 * terminated string value (pointer to data, not a copy) in the list of strings
1194 * contained in that property.
1196 * Return: 0 on success, -EINVAL if the property does not exist, -ENODATA if
1197 * property does not have a value, and -EILSEQ if the string is not
1198 * null-terminated within the length of the property data.
1200 * The out_string pointer is modified only if a valid string can be decoded.
1211 * of_property_read_bool - Find a property
1212 * @np: device node from which the property value is to be read.
1213 * @propname: name of the property to be searched.
1215 * Search for a boolean property in a device node. Usage on non-boolean
1216 * property types is deprecated.
1218 * Return: true if the property exists false otherwise.
1223 struct property *prop = of_find_property(np, propname, NULL); in of_property_read_bool()
1229 * of_property_present - Test if a property is present in a node
1230 * @np: device node to search for the property.
1231 * @propname: name of the property to be searched.
1233 * Test for a property present in a device node.
1235 * Return: true if the property exists false otherwise.
1243 * of_property_read_u8_array - Find and read an array of u8 from a property.
1245 * @np: device node from which the property value is to be read.
1246 * @propname: name of the property to be searched.
1250 * Search for a property in a device node and read 8-bit value(s) from
1254 * ``property = /bits/ 8 <0x50 0x60 0x70>;``
1256 * Return: 0 on success, -EINVAL if the property does not exist,
1257 * -ENODATA if property does not have a value, and -EOVERFLOW if the
1258 * property data isn't large enough.
1260 * The out_values is modified only if a valid u8 value can be decoded.
1275 * of_property_read_u16_array - Find and read an array of u16 from a property.
1277 * @np: device node from which the property value is to be read.
1278 * @propname: name of the property to be searched.
1282 * Search for a property in a device node and read 16-bit value(s) from
1286 * ``property = /bits/ 16 <0x5000 0x6000 0x7000>;``
1288 * Return: 0 on success, -EINVAL if the property does not exist,
1289 * -ENODATA if property does not have a value, and -EOVERFLOW if the
1290 * property data isn't large enough.
1292 * The out_values is modified only if a valid u16 value can be decoded.
1307 * of_property_read_u32_array - Find and read an array of 32 bit integers
1308 * from a property.
1310 * @np: device node from which the property value is to be read.
1311 * @propname: name of the property to be searched.
1315 * Search for a property in a device node and read 32-bit value(s) from
1318 * Return: 0 on success, -EINVAL if the property does not exist,
1319 * -ENODATA if property does not have a value, and -EOVERFLOW if the
1320 * property data isn't large enough.
1322 * The out_values is modified only if a valid u32 value can be decoded.
1337 * of_property_read_u64_array - Find and read an array of 64 bit integers
1338 * from a property.
1340 * @np: device node from which the property value is to be read.
1341 * @propname: name of the property to be searched.
1345 * Search for a property in a device node and read 64-bit value(s) from
1348 * Return: 0 on success, -EINVAL if the property does not exist,
1349 * -ENODATA if property does not have a value, and -EOVERFLOW if the
1350 * property data isn't large enough.
1352 * The out_values is modified only if a valid u64 value can be decoded.
1428 #define for_each_child_of_node(parent, child) \ argument
1429 for (child = of_get_next_child(parent, NULL); child != NULL; \
1430 child = of_get_next_child(parent, child))
1431 #define for_each_available_child_of_node(parent, child) \ argument
1432 for (child = of_get_next_available_child(parent, NULL); child != NULL; \
1433 child = of_get_next_available_child(parent, child))
1445 struct device_node *child; in of_get_child_count() local
1448 for_each_child_of_node(np, child) in of_get_child_count()
1456 struct device_node *child; in of_get_available_child_count() local
1459 for_each_available_child_of_node(np, child) in of_get_available_child_count()
1495 * struct of_changeset_entry - Holds a changeset entry
1497 * @node: list_head for the log list
1499 * @np: pointer to the device node affected
1500 * @prop: pointer to the property affected
1501 * @old_prop: hold a pointer to the original property
1503 * Every modification of the device tree during a changeset
1504 * is held in a list of of_changeset_entry structures.
1505 * That way we can recover from a partial application, or we can
1509 struct list_head node; member
1512 struct property *prop;
1513 struct property *old_prop;
1517 * struct of_changeset - changeset tracker structure
1521 * changesets are a convenient way to apply bulk changes to the
1522 * live tree. In case of an error, changes are rolled-back.
1551 struct property *prop);
1566 struct device_node *np, struct property *prop) in of_changeset_add_property()
1572 struct device_node *np, struct property *prop) in of_changeset_remove_property()
1578 struct device_node *np, struct property *prop) in of_changeset_update_property()
1608 return -EINVAL; in of_reconfig_notifier_register()
1612 return -EINVAL; in of_reconfig_notifier_unregister()
1617 return -EINVAL; in of_reconfig_notify()
1622 return -EINVAL; in of_reconfig_get_state_change()
1627 * of_device_is_system_power_controller - Tells if system-power-controller is found for device_node
1634 return of_property_read_bool(np, "system-power-controller"); in of_device_is_system_power_controller()
1653 "pre-apply", in of_overlay_action_name()
1654 "post-apply", in of_overlay_action_name()
1655 "pre-remove", in of_overlay_action_name()
1656 "post-remove", in of_overlay_action_name()
1682 return -ENOTSUPP; in of_overlay_fdt_apply()
1687 return -ENOTSUPP; in of_overlay_remove()
1692 return -ENOTSUPP; in of_overlay_remove_all()