Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Feb 2014 03:00:59 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r261955 - head/sys/dev/fdt
Message-ID:  <201402160300.s1G30xu8062904@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 **);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402160300.s1G30xu8062904>