From owner-svn-src-all@FreeBSD.ORG Sun Feb 16 03:01:00 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0C154BA; Sun, 16 Feb 2014 03:01:00 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D18DD1180; Sun, 16 Feb 2014 03:00:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1G30xOB062906; Sun, 16 Feb 2014 03:00:59 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1G30xu8062904; Sun, 16 Feb 2014 03:00:59 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201402160300.s1G30xu8062904@svn.freebsd.org> From: Ian Lepore Date: Sun, 16 Feb 2014 03:00:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r261955 - head/sys/dev/fdt X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Feb 2014 03:01:00 -0000 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 **);