Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt Add fdt_add_bus_match, which is like fdt_add_bus...



details:   https://anonhg.NetBSD.org/src/rev/afb39ec7586f
branches:  trunk
changeset: 433358:afb39ec7586f
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Sep 09 21:14:04 2018 +0000

description:
Add fdt_add_bus_match, which is like fdt_add_bus but allows for the caller to filter child nodes on their own

diffstat:

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

diffs (65 lines):

diff -r 5e9e7dec2246 -r afb39ec7586f sys/dev/fdt/fdtbus.c
--- a/sys/dev/fdt/fdtbus.c      Sun Sep 09 19:17:21 2018 +0000
+++ b/sys/dev/fdt/fdtbus.c      Sun Sep 09 21:14:04 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtbus.c,v 1.22 2018/06/30 17:28:09 jmcneill Exp $ */
+/* $NetBSD: fdtbus.c,v 1.23 2018/09/09 21:14:04 jmcneill 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.22 2018/06/30 17:28:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.23 2018/09/09 21:14:04 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -157,14 +157,27 @@
        faa->faa_quiet = quiet;
 }
 
+static bool
+fdt_add_bus_stdmatch(void *arg, int child)
+{
+       return fdtbus_status_okay(child);
+}
+
 void
 fdt_add_bus(device_t bus, const int phandle, struct fdt_attach_args *faa)
 {
+       fdt_add_bus_match(bus, phandle, faa, fdt_add_bus_stdmatch, NULL);
+}
+
+void
+fdt_add_bus_match(device_t bus, const int phandle, struct fdt_attach_args *faa,
+    bool (*fn)(void *, int), void *fnarg)
+{
        struct fdt_node *node;
        int child;
 
        for (child = OF_child(phandle); child; child = OF_peer(child)) {
-               if (!fdtbus_status_okay(child))
+               if (fn && !fn(fnarg, child))
                        continue;
 
                /* Add the node to our device list */
diff -r 5e9e7dec2246 -r afb39ec7586f sys/dev/fdt/fdtvar.h
--- a/sys/dev/fdt/fdtvar.h      Sun Sep 09 19:17:21 2018 +0000
+++ b/sys/dev/fdt/fdtvar.h      Sun Sep 09 21:14:04 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.40 2018/09/09 07:21:18 aymeric Exp $ */
+/* $NetBSD: fdtvar.h,v 1.41 2018/09/09 21:14:04 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -358,6 +358,8 @@
 const char *   fdtbus_get_string_index(int, const char *, u_int);
 
 void           fdt_add_bus(device_t, int, struct fdt_attach_args *);
+void           fdt_add_bus_match(device_t, int, struct fdt_attach_args *,
+                                 bool (*)(void *, int), void *);
 
 void           fdt_remove_byhandle(int);
 void           fdt_remove_bycompat(const char *[]);



Home | Main Index | Thread Index | Old Index