Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/26693
Change subject: devicetree: Add method to delete property by name ......................................................................
devicetree: Add method to delete property by name
Change-Id: I7c58a2411206bca62d0e96fa627530e937383ac9 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/include/device_tree.h M src/lib/device_tree.c 2 files changed, 22 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/93/26693/1
diff --git a/src/include/device_tree.h b/src/include/device_tree.h index 107fcf6..8433ddf 100644 --- a/src/include/device_tree.h +++ b/src/include/device_tree.h @@ -149,6 +149,8 @@ void *data, size_t size); // Write src into *dest as a 'length'-byte big-endian integer. void dt_write_int(u8 *dest, u64 src, size_t length); +// Delete a property +void dt_delete_prop(struct device_tree_node *node, const char *name); // Add different kinds of properties to a node, or update existing ones. void dt_add_bin_prop(struct device_tree_node *node, const char *name, void *data, size_t size); diff --git a/src/lib/device_tree.c b/src/lib/device_tree.c index 0a88c1f..5edd729 100644 --- a/src/lib/device_tree.c +++ b/src/lib/device_tree.c @@ -748,6 +748,26 @@ * @param data The raw data blob to be stored in the property. * @param size The size of data in bytes. */ +void dt_delete_prop(struct device_tree_node *node, const char *name) +{ + struct device_tree_property *prop; + + list_for_each(prop, node->properties, list_node) { + if (!strcmp(prop->prop.name, name)) { + list_remove(&prop->list_node); + return; + } + } +} + +/* + * Add an arbitrary property to a node, or update it if it already exists. + * + * @param node The device tree node to add to. + * @param name The name of the new property. + * @param data The raw data blob to be stored in the property. + * @param size The size of data in bytes. + */ void dt_add_bin_prop(struct device_tree_node *node, const char *name, void *data, size_t size) {