Module Name: src
Committed By: jmcneill
Date: Sun Sep 9 21:14:04 UTC 2018
Modified Files:
src/sys/dev/fdt: fdtbus.c fdtvar.h
Log Message:
Add fdt_add_bus_match, which is like fdt_add_bus but allows for the caller to
filter child nodes on their own
To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/fdt/fdtbus.c
cvs rdiff -u -r1.40 -r1.41 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.22 src/sys/dev/fdt/fdtbus.c:1.23
--- src/sys/dev/fdt/fdtbus.c:1.22 Sat Jun 30 17:28:09 2018
+++ src/sys/dev/fdt/fdtbus.c Sun Sep 9 21:14:04 2018
@@ -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 <[email protected]>
@@ -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 @@ fdt_init_attach_args(const struct fdt_at
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 */
Index: src/sys/dev/fdt/fdtvar.h
diff -u src/sys/dev/fdt/fdtvar.h:1.40 src/sys/dev/fdt/fdtvar.h:1.41
--- src/sys/dev/fdt/fdtvar.h:1.40 Sun Sep 9 07:21:18 2018
+++ src/sys/dev/fdt/fdtvar.h Sun Sep 9 21:14:04 2018
@@ -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 <[email protected]>
@@ -358,6 +358,8 @@ const char * fdtbus_get_string(int, cons
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 *[]);