From owner-svn-src-all@FreeBSD.ORG Tue Sep 2 03:45:02 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 7435E796; Tue, 2 Sep 2014 03:45:02 +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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4717E1CB5; Tue, 2 Sep 2014 03:45:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s823j2sS059015; Tue, 2 Sep 2014 03:45:02 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s823j1HW059013; Tue, 2 Sep 2014 03:45:01 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201409020345.s823j1HW059013@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Tue, 2 Sep 2014 03:45:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270958 - head/sys/dev/ofw 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.18-1 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: Tue, 02 Sep 2014 03:45:02 -0000 Author: ian Date: Tue Sep 2 03:45:01 2014 New Revision: 270958 URL: http://svnweb.freebsd.org/changeset/base/270958 Log: Add OF_xref_from_device() so that there's no need to have an intermediate call to ofw_bus_get_node() to lookup info that's already in the xreflist. Modified: head/sys/dev/ofw/openfirm.c head/sys/dev/ofw/openfirm.h Modified: head/sys/dev/ofw/openfirm.c ============================================================================== --- head/sys/dev/ofw/openfirm.c Tue Sep 2 03:23:05 2014 (r270957) +++ head/sys/dev/ofw/openfirm.c Tue Sep 2 03:45:01 2014 (r270958) @@ -96,6 +96,7 @@ static boolean_t xref_init_done; #define FIND_BY_XREF 0 #define FIND_BY_NODE 1 +#define FIND_BY_DEV 1 /* * xref-phandle-device lookup helper routines. @@ -152,6 +153,8 @@ xrefinfo_find(phandle_t phandle, int fin return (xi); else if (find_by == FIND_BY_NODE && phandle == xi->node) return (xi); + else if (find_by == FIND_BY_DEV && phandle == (uintptr_t)xi->dev) + return (xi); } return (NULL); } @@ -584,6 +587,19 @@ OF_device_from_xref(phandle_t xref) panic("Attempt to find device before xreflist_init"); } +phandle_t +OF_xref_from_device(device_t dev) +{ + struct xrefinfo *xi; + + if (xref_init_done) { + if ((xi = xrefinfo_find((uintptr_t)dev, FIND_BY_DEV)) == NULL) + return (0); + return (xi->xref); + } + panic("Attempt to find xref before xreflist_init"); +} + int OF_device_register_xref(phandle_t xref, device_t dev) { Modified: head/sys/dev/ofw/openfirm.h ============================================================================== --- head/sys/dev/ofw/openfirm.h Tue Sep 2 03:23:05 2014 (r270957) +++ head/sys/dev/ofw/openfirm.h Tue Sep 2 03:45:01 2014 (r270958) @@ -141,6 +141,7 @@ phandle_t OF_xref_from_node(phandle_t no * the device_t associated with an xref handle. */ device_t OF_device_from_xref(phandle_t xref); +phandle_t OF_xref_from_device(device_t dev); int OF_device_register_xref(phandle_t xref, device_t dev); /* Device I/O functions */