From owner-svn-src-all@FreeBSD.ORG Sat Sep 6 15:26:04 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 0582D30E; Sat, 6 Sep 2014 15:26:04 +0000 (UTC) Received: from c.mail.sonic.net (c.mail.sonic.net [64.142.111.80]) (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 DF6BC1294; Sat, 6 Sep 2014 15:26:03 +0000 (UTC) Received: from zeppelin.tachypleus.net (polaris.tachypleus.net [75.101.50.44]) (authenticated bits=0) by c.mail.sonic.net (8.14.9/8.14.9) with ESMTP id s86FPtll018241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Sat, 6 Sep 2014 08:25:56 -0700 Message-ID: <540B2783.9020808@freebsd.org> Date: Sat, 06 Sep 2014 08:25:55 -0700 From: Nathan Whitehorn User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Ian Lepore , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r271190 - head/sys/dev/ofw References: <201409061511.s86FBZAB050025@svn.freebsd.org> In-Reply-To: <201409061511.s86FBZAB050025@svn.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Sonic-CAuth: UmFuZG9tSVZmO0r8jtSlUxk5DAZ5bcqgG2qZUG3YrdEg67GsWoEd2oizSIzS2d/Lbz+8EJ8dSMMvkneYTGJMY2+pl489d/ACxBt/+x0Ez7c= X-Sonic-ID: C;6GhBGNo15BGh9EpcoK8kYw== M;MuC7GNo15BGh9EpcoK8kYw== X-Spam-Flag: No X-Sonic-Spam-Details: 0.0/5.0 by cerberusd 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: Sat, 06 Sep 2014 15:26:04 -0000 What is this for? The way the specification works here explicitly requires this fallback. -Nathan On 09/06/14 08:11, Ian Lepore wrote: > Author: ian > Date: Sat Sep 6 15:11:35 2014 > New Revision: 271190 > URL: http://svnweb.freebsd.org/changeset/base/271190 > > Log: > Add OF_xref_from_node_strict() which returns -1 if there is no xref handle > for the node. The default routine returns the untranslated handle, which > is sometimes useful, but sometimes you really need to know there's no > entry in the xref<->node<->device translation table. > > 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 Sat Sep 6 13:21:07 2014 (r271189) > +++ head/sys/dev/ofw/openfirm.c Sat Sep 6 15:11:35 2014 (r271190) > @@ -554,15 +554,15 @@ OF_node_from_xref(phandle_t xref) > return (node); > } > > -phandle_t > -OF_xref_from_node(phandle_t node) > +static phandle_t > +xref_from_node(phandle_t node, phandle_t notfoundvalue) > { > struct xrefinfo *xi; > phandle_t xref; > > if (xref_init_done) { > if ((xi = xrefinfo_find(node, FIND_BY_NODE)) == NULL) > - return (node); > + return (notfoundvalue); > return (xi->xref); > } > > @@ -570,10 +570,24 @@ OF_xref_from_node(phandle_t node) > -1 && OF_getencprop(node, "ibm,phandle", &xref, > sizeof(xref)) == -1 && OF_getencprop(node, > "linux,phandle", &xref, sizeof(xref)) == -1) > - return (node); > + return (notfoundvalue); > return (xref); > } > > +phandle_t > +OF_xref_from_node(phandle_t node) > +{ > + > + return (xref_from_node(node, node)); > +} > + > +phandle_t > +OF_xref_from_node_strict(phandle_t node) > +{ > + > + return (xref_from_node(node, -1)); > +} > + > device_t > OF_device_from_xref(phandle_t xref) > { > > Modified: head/sys/dev/ofw/openfirm.h > ============================================================================== > --- head/sys/dev/ofw/openfirm.h Sat Sep 6 13:21:07 2014 (r271189) > +++ head/sys/dev/ofw/openfirm.h Sat Sep 6 15:11:35 2014 (r271190) > @@ -128,10 +128,12 @@ ssize_t OF_package_to_path(phandle_t no > * Some OF implementations (IBM, FDT) have a concept of effective phandles > * used for device-tree cross-references. Given one of these, returns the > * real phandle. If one can't be found (or running on OF implementations > - * without this property), returns its input. > + * without this property), OF_xref_from_node() returns its input, while the > + * strict version returns -1. > */ > phandle_t OF_node_from_xref(phandle_t xref); > phandle_t OF_xref_from_node(phandle_t node); > +phandle_t OF_xref_from_node_strict(phandle_t node); > > /* > * When properties contain references to other nodes using xref handles it is >