Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/fdt Allow to remove entries from the fdt, either by ...



details:   https://anonhg.NetBSD.org/src/rev/d381ad077ca2
branches:  trunk
changeset: 831598:d381ad077ca2
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Apr 07 18:05:08 2018 +0000

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

diffstat:

 sys/dev/fdt/fdtbus.c |  29 +++++++++++++++++++++++++++--
 sys/dev/fdt/fdtvar.h |   4 +++-
 2 files changed, 30 insertions(+), 3 deletions(-)

diffs (68 lines):

diff -r 0b7e2d89c57d -r d381ad077ca2 sys/dev/fdt/fdtbus.c
--- a/sys/dev/fdt/fdtbus.c      Sat Apr 07 15:50:58 2018 +0000
+++ b/sys/dev/fdt/fdtbus.c      Sat Apr 07 18:05:08 2018 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
        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)
 {
diff -r 0b7e2d89c57d -r d381ad077ca2 sys/dev/fdt/fdtvar.h
--- a/sys/dev/fdt/fdtvar.h      Sat Apr 07 15:50:58 2018 +0000
+++ b/sys/dev/fdt/fdtvar.h      Sat Apr 07 18:05:08 2018 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -321,6 +321,8 @@
 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 */



Home | Main Index | Thread Index | Old Index