xref: /freebsd/share/man/man9/device_get_children.9 (revision 9978553d0199e7ec0bdd1c44fc7f6c7b0c11e43b)
1.\" -*- nroff -*-
2.\"
3.\" Copyright (c) 1998 Doug Rabson
4.\" Copyright (c) 2025 Dag-Erling Smørgrav <des@FreeBSD.org>
5.\"
6.\" All rights reserved.
7.\"
8.\" This program is free software.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
20.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
23.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd November 28, 2025
31.Dt DEVICE_GET_CHILDREN 9
32.Os
33.Sh NAME
34.Nm device_get_children ,
35.Nm device_has_children
36.Nd examine devices connected to a device
37.Sh SYNOPSIS
38.In sys/param.h
39.In sys/bus.h
40.Ft int
41.Fn device_get_children "device_t dev" "device_t **devlistp" "int *devcountp"
42.Ft bool
43.Fn device_has_children "device_t dev"
44.Sh DESCRIPTION
45The
46.Nm device_get_children
47function retrieves a list of all device instances currently connected
48to
49.Fa dev .
50It returns the list in
51.Fa *devlistp
52and the count in
53.Fa *devcountp .
54The memory allocated for the list should be freed using
55.Fn free "*devlistp" "M_TEMP" .
56.Fa devlistp
57and
58.Fa devcountp
59are not changed when an error is returned.
60.Pp
61As a special case, if
62.Fa devlistp
63is null, no memory is allocated but the count is still returned in
64.Fa *devcountp .
65.Pp
66The
67.Nm device_has_children
68function returns
69.Dv true
70if
71.Fa dev
72has at least one child and
73.Dv false
74if it has none.
75.Sh RETURN VALUES
76The
77.Nm device_get_children
78function returns zero on success and an appropriate error otherwise.
79The
80.Nm device_has_children
81function returns true if the specified device has at least one child
82and false otherwise.
83.Sh SEE ALSO
84.Xr devclass 9 ,
85.Xr device 9
86.Sh AUTHORS
87.An -nosplit
88This manual page was written by
89.An Doug Rabson Aq Mt dfr@FreeBSD.org
90and
91.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
92