Lines Matching +full:int +full:- +full:property
1 // SPDX-License-Identifier: GPL-2.0
28 * of_node_get() - Increment refcount of a node
37 kobject_get(&node->kobj); in of_node_get()
43 * of_node_put() - Decrement refcount of a node
50 kobject_put(&node->kobj); in of_node_put()
56 int of_reconfig_notifier_register(struct notifier_block *nb) in of_reconfig_notifier_register()
62 int of_reconfig_notifier_unregister(struct notifier_block *nb) in of_reconfig_notifier_unregister()
78 func("changeset: " prefix "%-15s %pOF%s%s\n", \
80 prop ? ":" : "", prop ? prop->name : ""); \
85 int of_reconfig_notify(unsigned long action, struct of_reconfig_data *p) in of_reconfig_notify()
87 int rc; in of_reconfig_notify()
90 of_changeset_action_debug("notify: ", action, pr->dn, pr->prop); in of_reconfig_notify()
97 * of_reconfig_get_state_change() - Returns new state of device
98 * @action - action of the of notifier
99 * @arg - argument of the of notifier
107 int of_reconfig_get_state_change(unsigned long action, struct of_reconfig_data *pr) in of_reconfig_get_state_change()
109 struct property *prop, *old_prop = NULL; in of_reconfig_get_state_change()
110 int is_status, status_state, old_status_state, prev_state, new_state; in of_reconfig_get_state_change()
116 prop = of_find_property(pr->dn, "status", NULL); in of_reconfig_get_state_change()
120 prop = pr->prop; in of_reconfig_get_state_change()
123 prop = pr->prop; in of_reconfig_get_state_change()
124 old_prop = pr->old_prop; in of_reconfig_get_state_change()
131 status_state = -1; in of_reconfig_get_state_change()
132 old_status_state = -1; in of_reconfig_get_state_change()
133 prev_state = -1; in of_reconfig_get_state_change()
134 new_state = -1; in of_reconfig_get_state_change()
136 if (prop && !strcmp(prop->name, "status")) { in of_reconfig_get_state_change()
138 status_state = !strcmp(prop->value, "okay") || in of_reconfig_get_state_change()
139 !strcmp(prop->value, "ok"); in of_reconfig_get_state_change()
141 old_status_state = !strcmp(old_prop->value, "okay") || in of_reconfig_get_state_change()
142 !strcmp(old_prop->value, "ok"); in of_reconfig_get_state_change()
148 /* -1 & 0 status either missing or okay */ in of_reconfig_get_state_change()
152 /* -1 & 0 status either missing or okay */ in of_reconfig_get_state_change()
158 /* no status property -> enabled (legacy) */ in of_reconfig_get_state_change()
166 /* no status property -> enabled (legacy) */ in of_reconfig_get_state_change()
185 int of_property_notify(int action, struct device_node *np, in of_property_notify()
186 struct property *prop, struct property *oldprop) in of_property_notify()
203 int sz; in __of_attach_node()
209 np->name = __of_get_property(np, "name", NULL); in __of_attach_node()
210 if (!np->name) in __of_attach_node()
211 np->name = "<NULL>"; in __of_attach_node()
219 np->phandle = be32_to_cpup(phandle); in __of_attach_node()
221 np->phandle = 0; in __of_attach_node()
224 np->child = NULL; in __of_attach_node()
225 np->sibling = np->parent->child; in __of_attach_node()
226 np->parent->child = np; in __of_attach_node()
228 np->fwnode.flags |= FWNODE_FLAG_NOT_DEVICE; in __of_attach_node()
236 * of_attach_node() - Plug a device node into the tree and global list.
239 int of_attach_node(struct device_node *np) in of_attach_node()
262 parent = np->parent; in __of_detach_node()
268 if (parent->child == np) in __of_detach_node()
269 parent->child = np->sibling; in __of_detach_node()
272 for (prevsib = np->parent->child; in __of_detach_node()
273 prevsib->sibling != np; in __of_detach_node()
274 prevsib = prevsib->sibling) in __of_detach_node()
276 prevsib->sibling = np->sibling; in __of_detach_node()
282 __of_phandle_cache_inv_entry(np->phandle); in __of_detach_node()
290 * of_detach_node() - "Unplug" a node from the device tree.
293 int of_detach_node(struct device_node *np) in of_detach_node()
310 void __of_prop_free(struct property *prop) in __of_prop_free()
312 kfree(prop->name); in __of_prop_free()
313 kfree(prop->value); in __of_prop_free()
317 static void property_list_free(struct property *prop_list) in property_list_free()
319 struct property *prop, *next; in property_list_free()
322 next = prop->next; in property_list_free()
328 * of_node_release() - release a dynamically allocated node
347 __func__, node->parent, node->full_name); in of_node_release()
356 strcmp(node->parent->full_name, "testcase-data")) { in of_node_release()
358 …e_put() on this node will result in a kobject warning 'refcount_t: underflow; use-after-free.'\n"); in of_node_release()
376 * If node->properties non-empty then properties were added in of_node_release()
378 * yet been removed, or by a non-overlay mechanism. in of_node_release()
380 if (node->properties) in of_node_release()
385 if (node->child) in of_node_release()
387 __func__, node->parent, node->full_name); in of_node_release()
389 property_list_free(node->properties); in of_node_release()
390 property_list_free(node->deadprops); in of_node_release()
393 kfree(node->full_name); in of_node_release()
394 kfree(node->data); in of_node_release()
399 * __of_prop_dup - Copy a property dynamically.
400 * @prop: Property to copy
403 * Copy a property by dynamically allocating the memory of both the
404 * property structure and the property name & contents. The property's
408 * Return: The newly allocated property or NULL on out of memory error.
410 struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags) in __of_prop_dup()
412 struct property *new; in __of_prop_dup()
420 * In case of a boolean property, this will allocate a value in __of_prop_dup()
424 new->name = kstrdup(prop->name, allocflags); in __of_prop_dup()
425 new->value = kmemdup(prop->value, prop->length, allocflags); in __of_prop_dup()
426 new->length = prop->length; in __of_prop_dup()
427 if (!new->name || !new->value) in __of_prop_dup()
430 /* mark the property as dynamic */ in __of_prop_dup()
441 * __of_node_dup() - Duplicate or create an empty device node dynamically.
460 node->full_name = kstrdup(full_name, GFP_KERNEL); in __of_node_dup()
461 if (!node->full_name) { in __of_node_dup()
472 struct property *pp, *new_pp; in __of_node_dup()
491 * of_changeset_create_node - Dynamically create a device node and attach to
505 int ret; in of_changeset_create_node()
510 np->parent = parent; in of_changeset_create_node()
524 if (ce->action == OF_RECONFIG_ATTACH_NODE && in __of_changeset_entry_destroy()
525 of_node_check_flag(ce->np, OF_OVERLAY)) { in __of_changeset_entry_destroy()
526 if (kref_read(&ce->np->kobj.kref) > 1) { in __of_changeset_entry_destroy()
527 …, expected refcount 1 instead of %d, of_node_get()/of_node_put() unbalanced - destroy cset entry: … in __of_changeset_entry_destroy()
528 kref_read(&ce->np->kobj.kref), ce->np); in __of_changeset_entry_destroy()
530 of_node_set_flag(ce->np, OF_OVERLAY_FREE_CSET); in __of_changeset_entry_destroy()
534 of_node_put(ce->np); in __of_changeset_entry_destroy()
535 list_del(&ce->node); in __of_changeset_entry_destroy()
544 switch (ce->action) { in __of_changeset_entry_invert()
546 rce->action = OF_RECONFIG_DETACH_NODE; in __of_changeset_entry_invert()
549 rce->action = OF_RECONFIG_ATTACH_NODE; in __of_changeset_entry_invert()
552 rce->action = OF_RECONFIG_REMOVE_PROPERTY; in __of_changeset_entry_invert()
555 rce->action = OF_RECONFIG_ADD_PROPERTY; in __of_changeset_entry_invert()
558 rce->old_prop = ce->prop; in __of_changeset_entry_invert()
559 rce->prop = ce->old_prop; in __of_changeset_entry_invert()
560 /* update was used but original property did not exist */ in __of_changeset_entry_invert()
561 if (!rce->prop) { in __of_changeset_entry_invert()
562 rce->action = OF_RECONFIG_REMOVE_PROPERTY; in __of_changeset_entry_invert()
563 rce->prop = ce->prop; in __of_changeset_entry_invert()
569 static int __of_changeset_entry_notify(struct of_changeset_entry *ce, in __of_changeset_entry_notify()
574 int ret = 0; in __of_changeset_entry_notify()
581 switch (ce->action) { in __of_changeset_entry_notify()
585 rd.dn = ce->np; in __of_changeset_entry_notify()
586 ret = of_reconfig_notify(ce->action, &rd); in __of_changeset_entry_notify()
591 ret = of_property_notify(ce->action, ce->np, ce->prop, ce->old_prop); in __of_changeset_entry_notify()
595 (int)ce->action); in __of_changeset_entry_notify()
596 ret = -EINVAL; in __of_changeset_entry_notify()
600 pr_err("changeset notifier error @%pOF\n", ce->np); in __of_changeset_entry_notify()
604 static int __of_changeset_entry_apply(struct of_changeset_entry *ce) in __of_changeset_entry_apply()
606 int ret = 0; in __of_changeset_entry_apply()
608 of_changeset_action_debug("apply: ", ce->action, ce->np, ce->prop); in __of_changeset_entry_apply()
610 switch (ce->action) { in __of_changeset_entry_apply()
612 __of_attach_node(ce->np); in __of_changeset_entry_apply()
615 __of_detach_node(ce->np); in __of_changeset_entry_apply()
618 ret = __of_add_property(ce->np, ce->prop); in __of_changeset_entry_apply()
621 ret = __of_remove_property(ce->np, ce->prop); in __of_changeset_entry_apply()
625 ret = __of_update_property(ce->np, ce->prop, &ce->old_prop); in __of_changeset_entry_apply()
628 ret = -EINVAL; in __of_changeset_entry_apply()
632 of_changeset_action_err("apply failed: ", ce->action, ce->np, ce->prop); in __of_changeset_entry_apply()
639 static inline int __of_changeset_entry_revert(const struct of_changeset_entry *ce) in __of_changeset_entry_revert()
648 * of_changeset_init - Initialize a changeset for use
657 INIT_LIST_HEAD(&ocs->entries); in of_changeset_init()
662 * of_changeset_destroy - Destroy a changeset
680 * free any device node that has a non-zero reference count. in of_changeset_destroy()
684 list_for_each_entry_safe_reverse(ce, cen, &ocs->entries, node) in of_changeset_destroy()
699 int __of_changeset_apply_entries(struct of_changeset *ocs, int *ret_revert) in __of_changeset_apply_entries()
702 int ret, ret_tmp; in __of_changeset_apply_entries()
705 list_for_each_entry(ce, &ocs->entries, node) { in __of_changeset_apply_entries()
709 list_for_each_entry_continue_reverse(ce, &ocs->entries, in __of_changeset_apply_entries()
728 int __of_changeset_apply_notify(struct of_changeset *ocs) in __of_changeset_apply_notify()
731 int ret = 0, ret_tmp; in __of_changeset_apply_notify()
737 list_for_each_entry(ce, &ocs->entries, node) { in __of_changeset_apply_notify()
756 static int __of_changeset_apply(struct of_changeset *ocs) in __of_changeset_apply()
758 int ret, ret_revert = 0; in __of_changeset_apply()
768 * of_changeset_apply - Applies a changeset
773 * Any side-effects of live tree state changes are applied here on
774 * success, like creation/destruction of devices and side-effects
780 int of_changeset_apply(struct of_changeset *ocs) in of_changeset_apply()
782 int ret; in of_changeset_apply()
794 * If revert fails, an attempt is made to re-apply the entries that were
797 * If multiple re-apply errors occur then only the final apply error is
803 int __of_changeset_revert_entries(struct of_changeset *ocs, int *ret_apply) in __of_changeset_revert_entries()
806 int ret, ret_tmp; in __of_changeset_revert_entries()
809 list_for_each_entry_reverse(ce, &ocs->entries, node) { in __of_changeset_revert_entries()
813 list_for_each_entry_continue(ce, &ocs->entries, node) { in __of_changeset_revert_entries()
829 int __of_changeset_revert_notify(struct of_changeset *ocs) in __of_changeset_revert_notify()
832 int ret = 0, ret_tmp; in __of_changeset_revert_notify()
838 list_for_each_entry_reverse(ce, &ocs->entries, node) { in __of_changeset_revert_notify()
849 static int __of_changeset_revert(struct of_changeset *ocs) in __of_changeset_revert()
851 int ret, ret_reply; in __of_changeset_revert()
863 * of_changeset_revert - Reverts an applied changeset
869 * Any side-effects like creation/destruction of devices and
874 int of_changeset_revert(struct of_changeset *ocs) in of_changeset_revert()
876 int ret; in of_changeset_revert()
887 * of_changeset_action - Add an action to the tail of the changeset list
892 * @prop: Pointer to property
903 int of_changeset_action(struct of_changeset *ocs, unsigned long action, in of_changeset_action()
904 struct device_node *np, struct property *prop) in of_changeset_action()
909 return -EINVAL; in of_changeset_action()
913 return -ENOMEM; in of_changeset_action()
916 ce->action = action; in of_changeset_action()
917 ce->np = of_node_get(np); in of_changeset_action()
918 ce->prop = prop; in of_changeset_action()
921 list_add_tail(&ce->node, &ocs->entries); in of_changeset_action()
926 static int of_changeset_add_prop_helper(struct of_changeset *ocs, in of_changeset_add_prop_helper()
928 const struct property *pp) in of_changeset_add_prop_helper()
930 struct property *new_pp; in of_changeset_add_prop_helper()
931 int ret; in of_changeset_add_prop_helper()
935 return -ENOMEM; in of_changeset_add_prop_helper()
945 * of_changeset_add_prop_string - Add a string property to a changeset
949 * @prop_name: name of the property to be added
952 * Create a string property and add it to a changeset.
956 int of_changeset_add_prop_string(struct of_changeset *ocs, in of_changeset_add_prop_string()
960 struct property prop; in of_changeset_add_prop_string()
971 * of_changeset_add_prop_string_array - Add a string list property to
976 * @prop_name: name of the property to be added
980 * Create a string list property and add it to a changeset.
984 int of_changeset_add_prop_string_array(struct of_changeset *ocs, in of_changeset_add_prop_string_array()
989 struct property prop; in of_changeset_add_prop_string_array()
990 int i, ret; in of_changeset_add_prop_string_array()
1001 return -ENOMEM; in of_changeset_add_prop_string_array()
1005 vp += snprintf(vp, (char *)prop.value + prop.length - vp, "%s", in of_changeset_add_prop_string_array()
1016 * of_changeset_add_prop_u32_array - Add a property of 32 bit integers
1017 * property to a changeset
1021 * @prop_name: name of the property to be added
1025 * Create a property of 32 bit integers and add it to a changeset.
1029 int of_changeset_add_prop_u32_array(struct of_changeset *ocs, in of_changeset_add_prop_u32_array()
1034 struct property prop; in of_changeset_add_prop_u32_array()
1036 int i; in of_changeset_add_prop_u32_array()
1039 return -ENOMEM; in of_changeset_add_prop_u32_array()
1052 * of_changeset_add_prop_bool - Add a boolean property (i.e. a property without
1057 * @prop_name: name of the property to be added
1059 * Create a boolean property and add it to a changeset.
1063 int of_changeset_add_prop_bool(struct of_changeset *ocs, struct device_node *np, in of_changeset_add_prop_bool()
1066 struct property prop; in of_changeset_add_prop_bool()
1076 static int of_changeset_update_prop_helper(struct of_changeset *ocs, in of_changeset_update_prop_helper()
1078 const struct property *pp) in of_changeset_update_prop_helper()
1080 struct property *new_pp; in of_changeset_update_prop_helper()
1081 int ret; in of_changeset_update_prop_helper()
1085 return -ENOMEM; in of_changeset_update_prop_helper()
1095 * of_changeset_update_prop_string - Add a string property update to a changeset
1099 * @prop_name: name of the property to be updated
1102 * Create a string property to be updated and add it to a changeset.
1106 int of_changeset_update_prop_string(struct of_changeset *ocs, in of_changeset_update_prop_string()
1110 struct property prop = { in of_changeset_update_prop_string()