xref: /freebsd/share/man/man9/bus_child_present.9 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
19b89e63cSWarner Losh.\" -*- nroff -*-
29b89e63cSWarner Losh.\"
3*a339dcccSWarner Losh.\" Copyright (c) 2003 M. Warner Losh <imp@FreeBSD.org>
49b89e63cSWarner Losh.\"
59b89e63cSWarner Losh.\" Redistribution and use in source and binary forms, with or without
69b89e63cSWarner Losh.\" modification, are permitted provided that the following conditions
79b89e63cSWarner Losh.\" are met:
89b89e63cSWarner Losh.\" 1. Redistributions of source code must retain the above copyright
99b89e63cSWarner Losh.\"    notice, this list of conditions and the following disclaimer.
109b89e63cSWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright
119b89e63cSWarner Losh.\"    notice, this list of conditions and the following disclaimer in the
129b89e63cSWarner Losh.\"    documentation and/or other materials provided with the distribution.
139b89e63cSWarner Losh.\"
149b89e63cSWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
159b89e63cSWarner Losh.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
169b89e63cSWarner Losh.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
179b89e63cSWarner Losh.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
189b89e63cSWarner Losh.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
199b89e63cSWarner Losh.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
209b89e63cSWarner Losh.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
219b89e63cSWarner Losh.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
229b89e63cSWarner Losh.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
239b89e63cSWarner Losh.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
249b89e63cSWarner Losh.\"
259b89e63cSWarner Losh.Dd March 27, 2003
269b89e63cSWarner Losh.Dt BUS_CHILD_PRESENT 9
279b89e63cSWarner Losh.Os
289b89e63cSWarner Losh.Sh NAME
299b89e63cSWarner Losh.Nm bus_child_present
303e1cee04SRuslan Ermilov.Nd "ask the bus driver to see if this device is still really present"
319b89e63cSWarner Losh.Sh SYNOPSIS
329b89e63cSWarner Losh.In sys/param.h
339b89e63cSWarner Losh.In sys/bus.h
349b89e63cSWarner Losh.Pp
359b89e63cSWarner Losh.In machine/bus.h
369b89e63cSWarner Losh.In sys/rman.h
379b89e63cSWarner Losh.In machine/resource.h
389b89e63cSWarner Losh.Ft int
399b89e63cSWarner Losh.Fn bus_child_present "device_t dev"
409b89e63cSWarner Losh.Sh DESCRIPTION
413e1cee04SRuslan ErmilovThe
423e1cee04SRuslan Ermilov.Fn bus_child_present
433e1cee04SRuslan Ermilovfunction requests that the parent device driver of
449b89e63cSWarner Losh.Fa dev
459b89e63cSWarner Loshcheck to see if the
469b89e63cSWarner Loshhardware represented by
479b89e63cSWarner Losh.Fa dev
489b89e63cSWarner Loshis still physically accessible at this time.
499b89e63cSWarner LoshWhile the notion of accessible varies from bus to bus, generally
502988974bSMike Pritchardhardware that is not accessible cannot be accessed via the
513e1cee04SRuslan Ermilov.Fn bus_space*
523e1cee04SRuslan Ermilovmethods that would otherwise be used to access the device.
539b89e63cSWarner Losh.Pp
543e1cee04SRuslan ErmilovThis does not ask the question
553e1cee04SRuslan Ermilov.Dq does this device have children?
563e1cee04SRuslan Ermilovwhich can better be answered by
579b89e63cSWarner Losh.Xr device_get_children 9 .
589b89e63cSWarner Losh.Sh RETURN VALUES
599b89e63cSWarner LoshA zero return value indicates that the device is not present in the
609b89e63cSWarner Loshsystem.
619b89e63cSWarner LoshA non-zero return value indicates that the device is present in the
629b89e63cSWarner Loshsystem, or that the state of the device cannot be determined.
639b89e63cSWarner Losh.Sh EXAMPLES
649b89e63cSWarner LoshThis is some example code.
653e1cee04SRuslan ErmilovIt only calls stop when the
663e1cee04SRuslan Ermilov.Xr dc 4
673e1cee04SRuslan Ermilovdevice is actually present.
683e1cee04SRuslan Ermilov.Bd -literal -offset indent
699b89e63cSWarner Loshdevice_t dev;
709b89e63cSWarner Loshdc_softc *sc;
719b89e63cSWarner Losh
729b89e63cSWarner Loshsc = device_get_softc(dev);
739b89e63cSWarner Loshif (bus_child_present(dev))
749b89e63cSWarner Losh	dc_stop(sc);
759b89e63cSWarner Losh.Ed
769b89e63cSWarner Losh.Sh SEE ALSO
779b89e63cSWarner Losh.Xr device 9 ,
789b89e63cSWarner Losh.Xr driver 9
799b89e63cSWarner Losh.Sh AUTHORS
80571dba6eSHiten PandyaThis manual page was written by
818a7314fcSBaptiste Daroussin.An Warner Losh Aq Mt imp@FreeBSD.org .
82