1ac32b99cSOleksandr Tymoshenko.\" 2ac32b99cSOleksandr Tymoshenko.\" Copyright (c) 2018 Oleksandr Tymoshenko <gonzo@FreeBSD.org> 3ac32b99cSOleksandr Tymoshenko.\" 4ac32b99cSOleksandr Tymoshenko.\" All rights reserved. 5ac32b99cSOleksandr Tymoshenko.\" 6ac32b99cSOleksandr Tymoshenko.\" Redistribution and use in source and binary forms, with or without 7ac32b99cSOleksandr Tymoshenko.\" modification, are permitted provided that the following conditions 8ac32b99cSOleksandr Tymoshenko.\" are met: 9ac32b99cSOleksandr Tymoshenko.\" 1. Redistributions of source code must retain the above copyright 10ac32b99cSOleksandr Tymoshenko.\" notice, this list of conditions and the following disclaimer. 11ac32b99cSOleksandr Tymoshenko.\" 2. Redistributions in binary form must reproduce the above copyright 12ac32b99cSOleksandr Tymoshenko.\" notice, this list of conditions and the following disclaimer in the 13ac32b99cSOleksandr Tymoshenko.\" documentation and/or other materials provided with the distribution. 14ac32b99cSOleksandr Tymoshenko.\" 15ac32b99cSOleksandr Tymoshenko.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 16ac32b99cSOleksandr Tymoshenko.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17ac32b99cSOleksandr Tymoshenko.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18ac32b99cSOleksandr Tymoshenko.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 19ac32b99cSOleksandr Tymoshenko.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20ac32b99cSOleksandr Tymoshenko.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21ac32b99cSOleksandr Tymoshenko.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22ac32b99cSOleksandr Tymoshenko.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23ac32b99cSOleksandr Tymoshenko.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24ac32b99cSOleksandr Tymoshenko.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25ac32b99cSOleksandr Tymoshenko.\" 26ac32b99cSOleksandr Tymoshenko.Dd April 9, 2018 27ac32b99cSOleksandr Tymoshenko.Dt OF_FINDDEVICE 9 28ac32b99cSOleksandr Tymoshenko.Os 29ac32b99cSOleksandr Tymoshenko.Sh NAME 30ac32b99cSOleksandr Tymoshenko.Nm OF_finddevice 31ac32b99cSOleksandr Tymoshenko.Nd find node in device tree 32ac32b99cSOleksandr Tymoshenko.Sh SYNOPSIS 33ac32b99cSOleksandr Tymoshenko.In dev/ofw/ofw_bus.h 34ac32b99cSOleksandr Tymoshenko.In dev/ofw/ofw_bus_subr.h 35ac32b99cSOleksandr Tymoshenko.Ft phandle_t 36ac32b99cSOleksandr Tymoshenko.Fn OF_finddevice "const char *path" 37ac32b99cSOleksandr Tymoshenko.Sh DESCRIPTION 38ac32b99cSOleksandr Tymoshenko.Fn OF_finddevice 39ac32b99cSOleksandr Tymoshenkoreturns the phandle for the node specified by the 40ac32b99cSOleksandr Tymoshenko.Fa path . 41ac32b99cSOleksandr TymoshenkoReturns -1 if the path cannot be found in the tree. 42ac32b99cSOleksandr Tymoshenko.Sh EXAMPLES 43ac32b99cSOleksandr Tymoshenko.Bd -literal 44ac32b99cSOleksandr Tymoshenko phandle_t root, i2c; 45ac32b99cSOleksandr Tymoshenko 46ac32b99cSOleksandr Tymoshenko root = OF_finddevice("/"); 47ac32b99cSOleksandr Tymoshenko i2c = OF_finddevice("/soc/axi/i2c@a0e0000"); 48ac32b99cSOleksandr Tymoshenko if (i2c != -1) { 49ac32b99cSOleksandr Tymoshenko ... 50ac32b99cSOleksandr Tymoshenko } 51ac32b99cSOleksandr Tymoshenko.Ed 52ac32b99cSOleksandr Tymoshenko.Sh SEE ALSO 53*32068667SChristian Brueffer.Xr OF_child 9 , 54*32068667SChristian Brueffer.Xr OF_parent 9 , 55ac32b99cSOleksandr Tymoshenko.Xr OF_peer 9 56ac32b99cSOleksandr Tymoshenko.Sh AUTHORS 57ac32b99cSOleksandr Tymoshenko.An -nosplit 58ac32b99cSOleksandr TymoshenkoThis manual page was written by 59ac32b99cSOleksandr Tymoshenko.An Oleksandr Tymoshenko Aq Mt gonzo@FreeBSD.org . 603d265fceSGordon Bergling.Sh CAVEATS 613d265fceSGordon BerglingThe return value should only be checked with equality 623d265fceSGordon Berglingoperators (equal to, not equal to) and not relational comparison 633d265fceSGordon Bergling(less than, greater than ). 643d265fceSGordon BerglingThere is a discrepancy between IEEE 1275 standard and 653d265fceSGordon Bergling.Fx Ns 's 663d265fceSGordon Berglinginternal representation of a phandle: IEEE 1275 673d265fceSGordon Berglingrequires the return value of this function to be -1 if the path 683d265fceSGordon Berglingis not found. 693d265fceSGordon BerglingBut phandle_t is an unsigned type, so it cannot 703d265fceSGordon Berglingbe relationally compared with -1 or 0, this comparison 713d265fceSGordon Berglingis always true or always false. 72