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.\" $FreeBSD$ 27ac32b99cSOleksandr Tymoshenko.\" 28ac32b99cSOleksandr Tymoshenko.Dd April 9, 2018 29ac32b99cSOleksandr Tymoshenko.Dt OF_FINDDEVICE 9 30ac32b99cSOleksandr Tymoshenko.Os 31ac32b99cSOleksandr Tymoshenko.Sh NAME 32ac32b99cSOleksandr Tymoshenko.Nm OF_finddevice 33ac32b99cSOleksandr Tymoshenko.Nd find node in device tree 34ac32b99cSOleksandr Tymoshenko.Sh SYNOPSIS 35ac32b99cSOleksandr Tymoshenko.In dev/ofw/ofw_bus.h 36ac32b99cSOleksandr Tymoshenko.In dev/ofw/ofw_bus_subr.h 37ac32b99cSOleksandr Tymoshenko.Ft phandle_t 38ac32b99cSOleksandr Tymoshenko.Fn OF_finddevice "const char *path" 39ac32b99cSOleksandr Tymoshenko.Sh DESCRIPTION 40ac32b99cSOleksandr Tymoshenko.Fn OF_finddevice 41ac32b99cSOleksandr Tymoshenkoreturns the phandle for the node specified by the 42ac32b99cSOleksandr Tymoshenko.Fa path . 43ac32b99cSOleksandr TymoshenkoReturns -1 if the path cannot be found in the tree. 44ac32b99cSOleksandr Tymoshenko.Sh EXAMPLES 45ac32b99cSOleksandr Tymoshenko.Bd -literal 46ac32b99cSOleksandr Tymoshenko phandle_t root, i2c; 47ac32b99cSOleksandr Tymoshenko 48ac32b99cSOleksandr Tymoshenko root = OF_finddevice("/"); 49ac32b99cSOleksandr Tymoshenko i2c = OF_finddevice("/soc/axi/i2c@a0e0000"); 50ac32b99cSOleksandr Tymoshenko if (i2c != -1) { 51ac32b99cSOleksandr Tymoshenko ... 52ac32b99cSOleksandr Tymoshenko } 53ac32b99cSOleksandr Tymoshenko.Ed 54ac32b99cSOleksandr Tymoshenko.Sh SEE ALSO 55ac32b99cSOleksandr Tymoshenko.Xr OF_child 9 56ac32b99cSOleksandr Tymoshenko.Xr OF_parent 9 57ac32b99cSOleksandr Tymoshenko.Xr OF_peer 9 58ac32b99cSOleksandr Tymoshenko.Sh AUTHORS 59ac32b99cSOleksandr Tymoshenko.An -nosplit 60ac32b99cSOleksandr TymoshenkoThis manual page was written by 61ac32b99cSOleksandr Tymoshenko.An Oleksandr Tymoshenko Aq Mt gonzo@FreeBSD.org . 62*3d265fceSGordon Bergling.Sh CAVEATS 63*3d265fceSGordon BerglingThe return value should only be checked with equality 64*3d265fceSGordon Berglingoperators (equal to, not equal to) and not relational comparison 65*3d265fceSGordon Bergling(less than, greater than ). 66*3d265fceSGordon BerglingThere is a discrepancy between IEEE 1275 standard and 67*3d265fceSGordon Bergling.Fx Ns 's 68*3d265fceSGordon Berglinginternal representation of a phandle: IEEE 1275 69*3d265fceSGordon Berglingrequires the return value of this function to be -1 if the path 70*3d265fceSGordon Berglingis not found. 71*3d265fceSGordon BerglingBut phandle_t is an unsigned type, so it cannot 72*3d265fceSGordon Berglingbe relationally compared with -1 or 0, this comparison 73*3d265fceSGordon Berglingis always true or always false. 74