xref: /dragonfly/share/man/man9/device_add_child.9 (revision 6e278935)
1.\" Copyright (c) 1998 Doug Rabson
2.\"
3.\" All rights reserved.
4.\"
5.\" This program is free software.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26.\"
27.\" $FreeBSD: src/share/man/man9/device_add_child.9,v 1.8.2.5 2001/12/17 11:30:18 ru Exp $
28.\" $DragonFly: src/share/man/man9/device_add_child.9,v 1.3 2004/06/01 11:36:53 hmp Exp $
29.\"
30.Dd June 16, 1998
31.Dt DEVICE_ADD_CHILD 9
32.Os
33.Sh NAME
34.Nm device_add_child ,
35.Nm device_add_child_ordered
36.Nd "add a new device as a child of an existing device"
37.Sh SYNOPSIS
38.In sys/param.h
39.In sys/bus.h
40.Ft device_t
41.Fn device_add_child "device_t dev" "const char *name" "int unit"
42.Ft device_t
43.Fn device_add_child_ordered "device_t dev" "int order" "const char *name" "int unit"
44.Sh DESCRIPTION
45Create a new child device of
46.Fa dev .
47The
48.Fa name
49and
50.Fa unit
51arguments specify the name and unit number of the device.
52If the name is unknown then the caller should pass
53.Dv NULL .
54If the unit is unknown then the caller should pass
55.Dv -1
56and the system will choose the next available unit number.
57.Pp
58The name of the device is used to determine which drivers might be
59appropriate for the device.  If a name is specified then only drivers
60of that name are probed.  If no name is given then all drivers for the
61owning bus are probed.
62.Pp
63This allows busses which can uniquely identify device instances (such
64as PCI) to allow each driver to check each device instance for a
65match.  For busses which rely on supplied probe hints where only one
66driver can have a chance of probing the device, the driver name should
67be specified as the device name.
68.Pp
69Normally unit numbers will be chosen automatically by the system and a
70unit number of
71.Dv -1
72should be given.
73When a specific unit number is desired (e.g. for wiring a particular
74piece of hardware to a pre-configured unit number), that unit should
75be passed.  If the specified unit number is already allocated, a new
76unit will be allocated and a diagnostic message printed.
77.Pp
78If the devices attached to a bus must be probed in a specific order
79(e.g. for the ISA bus some devices are sensitive to failed probe attempts
80of unrelated drivers and therefore must be probed first),
81the
82.Fa order
83argument of
84.Xr device_add_child_ordered 9
85should be used to specify a partial ordering.
86The new device will be added before any existing device with a greater
87order.
88If
89.Xr device_add_child 9
90is used, then the new child will be added as if its order was zero.
91.Sh RETURN VALUES
92The new device if successful, NULL otherwise.
93.Sh SEE ALSO
94.Xr BUS_ADD_CHILD 9 ,
95.Xr device 9
96.Sh AUTHORS
97This man page was written by
98.An Doug Rabson .
99