Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ofw Add of_find_bycompat helper to search a tree for...
details: https://anonhg.NetBSD.org/src/rev/3d60fa241981
branches: trunk
changeset: 936043:3d60fa241981
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Thu Jul 16 21:32:44 2020 +0000
description:
Add of_find_bycompat helper to search a tree for a node by compat string.
diffstat:
sys/dev/ofw/ofw_subr.c | 24 ++++++++++++++++++++++--
sys/dev/ofw/openfirm.h | 3 ++-
2 files changed, 24 insertions(+), 3 deletions(-)
diffs (62 lines):
diff -r 8283c4361595 -r 3d60fa241981 sys/dev/ofw/ofw_subr.c
--- a/sys/dev/ofw/ofw_subr.c Thu Jul 16 18:39:18 2020 +0000
+++ b/sys/dev/ofw/ofw_subr.c Thu Jul 16 21:32:44 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_subr.c,v 1.39 2020/06/26 10:14:32 martin Exp $ */
+/* $NetBSD: ofw_subr.c,v 1.40 2020/07/16 21:32:44 jmcneill Exp $ */
/*
* Copyright 1998
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.39 2020/06/26 10:14:32 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.40 2020/07/16 21:32:44 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -337,6 +337,26 @@
}
/*
+ * Find a child node that is compatible with str. Recurses, starting at node.
+ */
+int
+of_find_bycompat(int node, const char *str)
+{
+ const char * compatible[] = { str, NULL };
+ int child, ret;
+
+ for (child = OF_child(node); child; child = OF_peer(child)) {
+ if (of_match_compatible(child, compatible) != 0)
+ return child;
+ ret = of_find_bycompat(child, str);
+ if (ret != -1)
+ return ret;
+ }
+
+ return -1;
+}
+
+/*
* Find a give node by name. Recurses, and seems to walk upwards too.
*/
diff -r 8283c4361595 -r 3d60fa241981 sys/dev/ofw/openfirm.h
--- a/sys/dev/ofw/openfirm.h Thu Jul 16 18:39:18 2020 +0000
+++ b/sys/dev/ofw/openfirm.h Thu Jul 16 21:32:44 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: openfirm.h,v 1.38 2019/08/06 18:17:52 tnn Exp $ */
+/* $NetBSD: openfirm.h,v 1.39 2020/07/16 21:32:44 jmcneill Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -116,6 +116,7 @@
int of_decode_int(const unsigned char *);
int of_packagename(int, char *, int);
int of_find_firstchild_byname(int, const char *);
+int of_find_bycompat(int, const char *);
int of_getnode_byname(int, const char *);
boolean_t of_to_uint32_prop(prop_dictionary_t, int, const char *,
const char *);
Home |
Main Index |
Thread Index |
Old Index