aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/device_tree.h2
-rw-r--r--src/lib/device_tree.c18
2 files changed, 20 insertions, 0 deletions
diff --git a/src/include/device_tree.h b/src/include/device_tree.h
index 54aecb98b8..7f725e4d74 100644
--- a/src/include/device_tree.h
+++ b/src/include/device_tree.h
@@ -151,6 +151,8 @@ struct device_tree_node *dt_find_prop_value(struct device_tree_node *parent, con
uint32_t dt_get_phandle(struct device_tree_node *node);
// 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 de14c15536..21916598c5 100644
--- a/src/lib/device_tree.c
+++ b/src/lib/device_tree.c
@@ -763,6 +763,24 @@ void dt_write_int(u8 *dest, u64 src, size_t length)
}
/*
+ * Delete a property by name in a given node if it exists.
+ *
+ * @param node The device tree node to operate on.
+ * @param name The name of the property to delete.
+ */
+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.