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 a helper to search the tree for a node with ...
details: https://anonhg.NetBSD.org/src/rev/623cb0ac900d
branches: trunk
changeset: 448045:623cb0ac900d
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat Jan 19 20:50:48 2019 +0000
description:
Add a helper to search the tree for a node with the specified property
diffstat:
sys/dev/fdt/fdtbus.c | 22 ++++++++++++++++++++--
sys/dev/fdt/fdtvar.h | 3 ++-
2 files changed, 22 insertions(+), 3 deletions(-)
diffs (60 lines):
diff -r 6885120d7904 -r 623cb0ac900d sys/dev/fdt/fdtbus.c
--- a/sys/dev/fdt/fdtbus.c Sat Jan 19 20:42:54 2019 +0000
+++ b/sys/dev/fdt/fdtbus.c Sat Jan 19 20:50:48 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtbus.c,v 1.25 2019/01/02 14:54:54 jmcneill Exp $ */
+/* $NetBSD: fdtbus.c,v 1.26 2019/01/19 20:50:48 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.25 2019/01/02 14:54:54 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.26 2019/01/19 20:50:48 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -345,6 +345,24 @@
}
}
+int
+fdt_find_with_property(const char *prop, int *pindex)
+{
+ struct fdt_node *node;
+ int index = 0;
+
+ TAILQ_FOREACH(node, &fdt_nodes, n_nodes) {
+ if (index < *pindex)
+ continue;
+ if (of_hasprop(node->n_phandle, prop)) {
+ *pindex = index;
+ return node->n_phandle;
+ }
+ }
+
+ return -1;
+}
+
static u_int
fdt_get_order(int phandle)
{
diff -r 6885120d7904 -r 623cb0ac900d sys/dev/fdt/fdtvar.h
--- a/sys/dev/fdt/fdtvar.h Sat Jan 19 20:42:54 2019 +0000
+++ b/sys/dev/fdt/fdtvar.h Sat Jan 19 20:50:48 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.44 2019/01/02 18:38:43 jmcneill Exp $ */
+/* $NetBSD: fdtvar.h,v 1.45 2019/01/19 20:50:48 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -368,6 +368,7 @@
void fdt_remove_byhandle(int);
void fdt_remove_bycompat(const char *[]);
+int fdt_find_with_property(const char *, int *);
int fdtbus_print(void *, const char *);
#endif /* _DEV_FDT_FDTVAR_H */
Home |
Main Index |
Thread Index |
Old Index