xref: /dragonfly/share/man/man9/device_add_child.9 (revision a3f29142)
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.\"
29.Dd June 16, 1998
30.Dt DEVICE_ADD_CHILD 9
31.Os
32.Sh NAME
33.Nm device_add_child ,
34.Nm device_add_child_ordered
35.Nd "add a new device as a child of an existing device"
36.Sh SYNOPSIS
37.In sys/param.h
38.In sys/bus.h
39.Ft device_t
40.Fn device_add_child "device_t dev" "const char *name" "int unit"
41.Ft device_t
42.Fn device_add_child_ordered "device_t dev" "int order" "const char *name" "int unit"
43.Sh DESCRIPTION
44Create a new child device of
45.Fa dev .
46The
47.Fa name
48and
49.Fa unit
50arguments specify the name and unit number of the device.
51If the name is unknown then the caller should pass
52.Dv NULL .
53If the unit is unknown then the caller should pass
54.Dv -1
55and the system will choose the next available unit number.
56.Pp
57The name of the device is used to determine which drivers might be
58appropriate for the device.  If a name is specified then only drivers
59of that name are probed.  If no name is given then all drivers for the
60owning bus are probed.
61.Pp
62This allows busses which can uniquely identify device instances (such
63as PCI) to allow each driver to check each device instance for a
64match.  For busses which rely on supplied probe hints where only one
65driver can have a chance of probing the device, the driver name should
66be specified as the device name.
67.Pp
68Normally unit numbers will be chosen automatically by the system and a
69unit number of
70.Dv -1
71should be given.
72When a specific unit number is desired (e.g. for wiring a particular
73piece of hardware to a pre-configured unit number), that unit should
74be passed.  If the specified unit number is already allocated, a new
75unit will be allocated and a diagnostic message printed.
76.Pp
77If the devices attached to a bus must be probed in a specific order
78(e.g. for the ISA bus some devices are sensitive to failed probe attempts
79of unrelated drivers and therefore must be probed first),
80the
81.Fa order
82argument of
83.Fn device_add_child_ordered
84should be used to specify a partial ordering.
85The new device will be added before any existing device with a greater
86order.
87If
88.Fn device_add_child
89is used, then the new child will be added as if its order was zero.
90.Sh RETURN VALUES
91The new device if successful, NULL otherwise.
92.Sh SEE ALSO
93.Xr BUS_ADD_CHILD 9 ,
94.Xr device 9
95.Sh AUTHORS
96This man page was written by
97.An Doug Rabson .
98