svn commit: r261955 - head/sys/dev/fdt

Ian Lepore ian at FreeBSD.org
Sun Feb 16 03:01:00 UTC 2014


Author: ian
Date: Sun Feb 16 03:00:59 2014
New Revision: 261955
URL: http://svnweb.freebsd.org/changeset/base/261955

Log:
  Add a helper routine to depth-search the device tree for a node with a
  matching 'compatible' property.  This probably has a short half-life (as
  do most of the fdt_ functions), but it helps solve some near-term needs
  until we work out the larger problems of device instantiation order
  versus the order of things in the fdt data.

Modified:
  head/sys/dev/fdt/fdt_common.c
  head/sys/dev/fdt/fdt_common.h

Modified: head/sys/dev/fdt/fdt_common.c
==============================================================================
--- head/sys/dev/fdt/fdt_common.c	Sun Feb 16 02:33:59 2014	(r261954)
+++ head/sys/dev/fdt/fdt_common.c	Sun Feb 16 03:00:59 2014	(r261955)
@@ -223,6 +223,27 @@ fdt_find_compatible(phandle_t start, con
 	return (0);
 }
 
+phandle_t
+fdt_depth_search_compatible(phandle_t start, const char *compat, int strict)
+{
+	phandle_t child, node;
+
+	/*
+	 * Depth-search all descendants of 'start' node, and find first with
+	 * matching 'compatible' property.
+	 */
+	for (node = OF_child(start); node != 0; node = OF_peer(node)) {
+		if (fdt_is_compatible(node, compat) && 
+		    (strict == 0 || fdt_is_compatible_strict(node, compat))) {
+			return (node);
+		}
+		child = fdt_search_compatible(node, compat, strict);
+		if (child != 0)
+			return (child);
+	}
+	return (0);
+}
+
 int
 fdt_is_enabled(phandle_t node)
 {

Modified: head/sys/dev/fdt/fdt_common.h
==============================================================================
--- head/sys/dev/fdt/fdt_common.h	Sun Feb 16 02:33:59 2014	(r261954)
+++ head/sys/dev/fdt/fdt_common.h	Sun Feb 16 03:00:59 2014	(r261955)
@@ -81,6 +81,7 @@ u_long fdt_data_get(void *, int);
 int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *);
 int fdt_data_verify(void *, int);
 phandle_t fdt_find_compatible(phandle_t, const char *, int);
+phandle_t fdt_depth_search_compatible(phandle_t, const char *, int);
 int fdt_get_mem_regions(struct mem_region *, int *, uint32_t *);
 int fdt_get_reserved_regions(struct mem_region *, int *);
 int fdt_get_phyaddr(phandle_t, device_t, int *, void **);


More information about the svn-src-head mailing list