Lines Matching +full:string +full:- +full:array +full:- +full:property

1 // SPDX-License-Identifier: GPL-2.0
15 #include <linux/string.h>
26 * of_node_get() - Increment refcount of a node
35 kobject_get(&node->kobj); in of_node_get()
41 * of_node_put() - Decrement refcount of a node
48 kobject_put(&node->kobj); in of_node_put()
76 func("changeset: " prefix "%-15s %pOF%s%s\n", \
78 prop ? ":" : "", prop ? prop->name : ""); \
88 of_changeset_action_debug("notify: ", action, pr->dn, pr->prop); in of_reconfig_notify()
95 * of_reconfig_get_state_change() - Returns new state of device
96 * @action - action of the of notifier
97 * @arg - argument of the of notifier
107 struct property *prop, *old_prop = NULL; in of_reconfig_get_state_change()
114 prop = of_find_property(pr->dn, "status", NULL); in of_reconfig_get_state_change()
118 prop = pr->prop; in of_reconfig_get_state_change()
121 prop = pr->prop; in of_reconfig_get_state_change()
122 old_prop = pr->old_prop; in of_reconfig_get_state_change()
129 status_state = -1; in of_reconfig_get_state_change()
130 old_status_state = -1; in of_reconfig_get_state_change()
131 prev_state = -1; in of_reconfig_get_state_change()
132 new_state = -1; in of_reconfig_get_state_change()
134 if (prop && !strcmp(prop->name, "status")) { in of_reconfig_get_state_change()
136 status_state = !strcmp(prop->value, "okay") || in of_reconfig_get_state_change()
137 !strcmp(prop->value, "ok"); in of_reconfig_get_state_change()
139 old_status_state = !strcmp(old_prop->value, "okay") || in of_reconfig_get_state_change()
140 !strcmp(old_prop->value, "ok"); in of_reconfig_get_state_change()
146 /* -1 & 0 status either missing or okay */ in of_reconfig_get_state_change()
150 /* -1 & 0 status either missing or okay */ in of_reconfig_get_state_change()
156 /* no status property -> enabled (legacy) */ in of_reconfig_get_state_change()
164 /* no status property -> enabled (legacy) */ in of_reconfig_get_state_change()
184 struct property *prop, struct property *oldprop) in of_property_notify()
207 np->name = __of_get_property(np, "name", NULL); in __of_attach_node()
208 if (!np->name) in __of_attach_node()
209 np->name = "<NULL>"; in __of_attach_node()
217 np->phandle = be32_to_cpup(phandle); in __of_attach_node()
219 np->phandle = 0; in __of_attach_node()
222 np->child = NULL; in __of_attach_node()
223 np->sibling = np->parent->child; in __of_attach_node()
224 np->parent->child = np; in __of_attach_node()
226 np->fwnode.flags |= FWNODE_FLAG_NOT_DEVICE; in __of_attach_node()
234 * of_attach_node() - Plug a device node into the tree and global list.
260 parent = np->parent; in __of_detach_node()
266 if (parent->child == np) in __of_detach_node()
267 parent->child = np->sibling; in __of_detach_node()
270 for (prevsib = np->parent->child; in __of_detach_node()
271 prevsib->sibling != np; in __of_detach_node()
272 prevsib = prevsib->sibling) in __of_detach_node()
274 prevsib->sibling = np->sibling; in __of_detach_node()
280 __of_phandle_cache_inv_entry(np->phandle); in __of_detach_node()
288 * of_detach_node() - "Unplug" a node from the device tree.
308 static void property_list_free(struct property *prop_list) in property_list_free()
310 struct property *prop, *next; in property_list_free()
313 next = prop->next; in property_list_free()
314 kfree(prop->name); in property_list_free()
315 kfree(prop->value); in property_list_free()
321 * of_node_release() - release a dynamically allocated node
340 __func__, node->parent, node->full_name); in of_node_release()
349 strcmp(node->parent->full_name, "testcase-data")) { in of_node_release()
351 …e_put() on this node will result in a kobject warning 'refcount_t: underflow; use-after-free.'\n"); in of_node_release()
369 * If node->properties non-empty then properties were added in of_node_release()
371 * yet been removed, or by a non-overlay mechanism. in of_node_release()
373 if (node->properties) in of_node_release()
378 if (node->child) in of_node_release()
380 __func__, node->parent, node->full_name); in of_node_release()
382 property_list_free(node->properties); in of_node_release()
383 property_list_free(node->deadprops); in of_node_release()
386 kfree(node->full_name); in of_node_release()
387 kfree(node->data); in of_node_release()
392 * __of_prop_dup - Copy a property dynamically.
393 * @prop: Property to copy
396 * Copy a property by dynamically allocating the memory of both the
397 * property structure and the property name & contents. The property's
401 * Return: The newly allocated property or NULL on out of memory error.
403 struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags) in __of_prop_dup()
405 struct property *new; in __of_prop_dup()
413 * In case of a boolean property, this will allocate a value in __of_prop_dup()
417 new->name = kstrdup(prop->name, allocflags); in __of_prop_dup()
418 new->value = kmemdup(prop->value, prop->length, allocflags); in __of_prop_dup()
419 new->length = prop->length; in __of_prop_dup()
420 if (!new->name || !new->value) in __of_prop_dup()
423 /* mark the property as dynamic */ in __of_prop_dup()
429 kfree(new->name); in __of_prop_dup()
430 kfree(new->value); in __of_prop_dup()
436 * __of_node_dup() - Duplicate or create an empty device node dynamically.
438 * @full_name: string value to be duplicated into new node's full_name field
455 node->full_name = kstrdup(full_name, GFP_KERNEL); in __of_node_dup()
456 if (!node->full_name) { in __of_node_dup()
467 struct property *pp, *new_pp; in __of_node_dup()
473 kfree(new_pp->name); in __of_node_dup()
474 kfree(new_pp->value); in __of_node_dup()
488 * of_changeset_create_node - Dynamically create a device node and attach to
507 np->parent = parent; in of_changeset_create_node()
521 if (ce->action == OF_RECONFIG_ATTACH_NODE && in __of_changeset_entry_destroy()
522 of_node_check_flag(ce->np, OF_OVERLAY)) { in __of_changeset_entry_destroy()
523 if (kref_read(&ce->np->kobj.kref) > 1) { in __of_changeset_entry_destroy()
524 …, expected refcount 1 instead of %d, of_node_get()/of_node_put() unbalanced - destroy cset entry: … in __of_changeset_entry_destroy()
525 kref_read(&ce->np->kobj.kref), ce->np); in __of_changeset_entry_destroy()
527 of_node_set_flag(ce->np, OF_OVERLAY_FREE_CSET); in __of_changeset_entry_destroy()
531 of_node_put(ce->np); in __of_changeset_entry_destroy()
532 list_del(&ce->node); in __of_changeset_entry_destroy()
541 switch (ce->action) { in __of_changeset_entry_invert()
543 rce->action = OF_RECONFIG_DETACH_NODE; in __of_changeset_entry_invert()
546 rce->action = OF_RECONFIG_ATTACH_NODE; in __of_changeset_entry_invert()
549 rce->action = OF_RECONFIG_REMOVE_PROPERTY; in __of_changeset_entry_invert()
552 rce->action = OF_RECONFIG_ADD_PROPERTY; in __of_changeset_entry_invert()
555 rce->old_prop = ce->prop; in __of_changeset_entry_invert()
556 rce->prop = ce->old_prop; in __of_changeset_entry_invert()
557 /* update was used but original property did not exist */ in __of_changeset_entry_invert()
558 if (!rce->prop) { in __of_changeset_entry_invert()
559 rce->action = OF_RECONFIG_REMOVE_PROPERTY; in __of_changeset_entry_invert()
560 rce->prop = ce->prop; in __of_changeset_entry_invert()
578 switch (ce->action) { in __of_changeset_entry_notify()
582 rd.dn = ce->np; in __of_changeset_entry_notify()
583 ret = of_reconfig_notify(ce->action, &rd); in __of_changeset_entry_notify()
588 ret = of_property_notify(ce->action, ce->np, ce->prop, ce->old_prop); in __of_changeset_entry_notify()
592 (int)ce->action); in __of_changeset_entry_notify()
593 ret = -EINVAL; in __of_changeset_entry_notify()
597 pr_err("changeset notifier error @%pOF\n", ce->np); in __of_changeset_entry_notify()
605 of_changeset_action_debug("apply: ", ce->action, ce->np, ce->prop); in __of_changeset_entry_apply()
607 switch (ce->action) { in __of_changeset_entry_apply()
609 __of_attach_node(ce->np); in __of_changeset_entry_apply()
612 __of_detach_node(ce->np); in __of_changeset_entry_apply()
615 ret = __of_add_property(ce->np, ce->prop); in __of_changeset_entry_apply()
618 ret = __of_remove_property(ce->np, ce->prop); in __of_changeset_entry_apply()
622 ret = __of_update_property(ce->np, ce->prop, &ce->old_prop); in __of_changeset_entry_apply()
625 ret = -EINVAL; in __of_changeset_entry_apply()
629 of_changeset_action_err("apply failed: ", ce->action, ce->np, ce->prop); in __of_changeset_entry_apply()
645 * of_changeset_init - Initialize a changeset for use
654 INIT_LIST_HEAD(&ocs->entries); in of_changeset_init()
659 * of_changeset_destroy - Destroy a changeset
670 list_for_each_entry_safe_reverse(ce, cen, &ocs->entries, node) in of_changeset_destroy()
691 list_for_each_entry(ce, &ocs->entries, node) { in __of_changeset_apply_entries()
695 list_for_each_entry_continue_reverse(ce, &ocs->entries, in __of_changeset_apply_entries()
723 list_for_each_entry(ce, &ocs->entries, node) { in __of_changeset_apply_notify()
754 * of_changeset_apply - Applies a changeset
759 * Any side-effects of live tree state changes are applied here on
760 * success, like creation/destruction of devices and side-effects
780 * If revert fails, an attempt is made to re-apply the entries that were
783 * If multiple re-apply errors occur then only the final apply error is
795 list_for_each_entry_reverse(ce, &ocs->entries, node) { in __of_changeset_revert_entries()
799 list_for_each_entry_continue(ce, &ocs->entries, node) { in __of_changeset_revert_entries()
824 list_for_each_entry_reverse(ce, &ocs->entries, node) { in __of_changeset_revert_notify()
849 * of_changeset_revert - Reverts an applied changeset
855 * Any side-effects like creation/destruction of devices and
873 * of_changeset_action - Add an action to the tail of the changeset list
878 * @prop: Pointer to property
890 struct device_node *np, struct property *prop) in of_changeset_action()
895 return -EINVAL; in of_changeset_action()
899 return -ENOMEM; in of_changeset_action()
902 ce->action = action; in of_changeset_action()
903 ce->np = of_node_get(np); in of_changeset_action()
904 ce->prop = prop; in of_changeset_action()
907 list_add_tail(&ce->node, &ocs->entries); in of_changeset_action()
914 const struct property *pp) in of_changeset_add_prop_helper()
916 struct property *new_pp; in of_changeset_add_prop_helper()
921 return -ENOMEM; in of_changeset_add_prop_helper()
925 kfree(new_pp->name); in of_changeset_add_prop_helper()
926 kfree(new_pp->value); in of_changeset_add_prop_helper()
934 * of_changeset_add_prop_string - Add a string property to a changeset
938 * @prop_name: name of the property to be added
939 * @str: pointer to null terminated string
941 * Create a string property and add it to a changeset.
949 struct property prop; in of_changeset_add_prop_string()
960 * of_changeset_add_prop_string_array - Add a string list property to
965 * @prop_name: name of the property to be added
966 * @str_array: pointer to an array of null terminated strings
967 * @sz: number of string array elements
969 * Create a string list property and add it to a changeset.
978 struct property prop; in of_changeset_add_prop_string_array()
990 return -ENOMEM; in of_changeset_add_prop_string_array()
994 vp += snprintf(vp, (char *)prop.value + prop.length - vp, "%s", in of_changeset_add_prop_string_array()
1005 * of_changeset_add_prop_u32_array - Add a property of 32 bit integers
1006 * property to a changeset
1010 * @prop_name: name of the property to be added
1011 * @array: pointer to an array of 32 bit integers
1012 * @sz: number of array elements
1014 * Create a property of 32 bit integers and add it to a changeset.
1021 const u32 *array, size_t sz) in of_changeset_add_prop_u32_array() argument
1023 struct property prop; in of_changeset_add_prop_u32_array()
1029 return -ENOMEM; in of_changeset_add_prop_u32_array()
1032 val[i] = cpu_to_be32(array[i]); in of_changeset_add_prop_u32_array()