Module Name:    src
Committed By:   bouyer
Date:           Sat Apr  7 18:05:08 UTC 2018

Modified Files:
        src/sys/dev/fdt: fdtbus.c fdtvar.h

Log Message:
Allow to remove entries from the fdt, either by handle or
by compatible string. Proposed on tech-kern and port-arm, ok jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/fdt/fdtbus.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/fdt/fdtvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/fdt/fdtbus.c
diff -u src/sys/dev/fdt/fdtbus.c:1.15 src/sys/dev/fdt/fdtbus.c:1.16
--- src/sys/dev/fdt/fdtbus.c:1.15	Sun Aug 27 19:13:31 2017
+++ src/sys/dev/fdt/fdtbus.c	Sat Apr  7 18:05:08 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtbus.c,v 1.15 2017/08/27 19:13:31 jmcneill Exp $ */
+/* $NetBSD: fdtbus.c,v 1.16 2018/04/07 18:05:08 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcne...@invisible.ca>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.15 2017/08/27 19:13:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.16 2018/04/07 18:05:08 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -265,6 +265,31 @@ fdt_add_node(struct fdt_node *new_node)
 	TAILQ_INSERT_TAIL(&fdt_nodes, new_node, n_nodes);
 }
 
+void
+fdt_remove_byhandle(int phandle)
+{
+	struct fdt_node *node;
+
+	TAILQ_FOREACH(node, &fdt_nodes, n_nodes) {
+		if (node->n_phandle == phandle) {
+			TAILQ_REMOVE(&fdt_nodes, node, n_nodes);
+			return;
+		}
+	}
+}
+
+void
+fdt_remove_bycompat(const char *compatible[])
+{
+	struct fdt_node *node, *next;
+
+	TAILQ_FOREACH_SAFE(node, &fdt_nodes, n_nodes, next) {
+		if (of_match_compatible(node->n_phandle, compatible)) {
+			TAILQ_REMOVE(&fdt_nodes, node, n_nodes);
+		}
+	}
+}
+
 static u_int
 fdt_get_order(int phandle)
 {

Index: src/sys/dev/fdt/fdtvar.h
diff -u src/sys/dev/fdt/fdtvar.h:1.28 src/sys/dev/fdt/fdtvar.h:1.29
--- src/sys/dev/fdt/fdtvar.h:1.28	Sun Dec 10 21:38:27 2017
+++ src/sys/dev/fdt/fdtvar.h	Sat Apr  7 18:05:08 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.28 2017/12/10 21:38:27 skrll Exp $ */
+/* $NetBSD: fdtvar.h,v 1.29 2018/04/07 18:05:08 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcne...@invisible.ca>
@@ -321,6 +321,8 @@ const void *	fdtbus_get_prop(int, const 
 const char *	fdtbus_get_string(int, const char *);
 const char *	fdtbus_get_string_index(int, const char *, u_int);
 
+void		fdt_remove_byhandle(int);
+void		fdt_remove_bycompat(const char *[]);
 int		fdtbus_print(void *, const char *);
 
 #endif /* _DEV_FDT_FDTVAR_H */

Reply via email to