diff mbox series

[v2,2/3] of: Add of_alias_destroy()

Message ID 20241110-of-alias-v2-2-16da9844a93e@beagleboard.org
State Changes Requested
Headers show
Series Update aliases when added or removed | expand

Checks

Context Check Description
robh/patch-applied fail build log
robh/checkpatch success

Commit Message

Ayush Singh Nov. 9, 2024, 7:51 p.m. UTC
Add a helper function to find an alias, remove it from the list of
aliases, and destroy it.

Co-developed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
---
 drivers/of/base.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/drivers/of/base.c b/drivers/of/base.c
index e5cd75fca95132060334aa8547c58951d2132cfb..1cfb3cd4493e17d16868981288115798c6a6a151 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -221,6 +221,20 @@  static void of_alias_create(const struct property *pp,
 	of_alias_add(ap, np, id, start, len);
 }
 
+static void of_alias_destroy(const char *name, void (*dt_free)(void *))
+{
+	struct alias_prop *ap;
+
+	list_for_each_entry(ap, &aliases_lookup, link) {
+		if (strcmp(ap->alias, name))
+			continue;
+
+		list_del(&ap->link);
+		dt_free(ap);
+		return;
+	}
+}
+
 void __init of_core_init(void)
 {
 	struct device_node *np;