1998-09-03 21:52:05 +00:00
|
|
|
.\" -*- nroff -*-
|
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1998 Doug Rabson
|
|
|
|
.\"
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This program is free software.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1998-09-03 21:52:05 +00:00
|
|
|
.\"
|
2015-10-28 19:11:06 +00:00
|
|
|
.Dd October 28, 2015
|
1999-08-15 10:48:36 +00:00
|
|
|
.Dt DEVICE_ADD_CHILD 9
|
2001-07-10 15:31:11 +00:00
|
|
|
.Os
|
1998-09-03 21:52:05 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm device_add_child ,
|
1999-09-04 12:37:21 +00:00
|
|
|
.Nm device_add_child_ordered
|
2000-05-09 14:02:06 +00:00
|
|
|
.Nd "add a new device as a child of an existing device"
|
1998-09-03 21:52:05 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/param.h
|
|
|
|
.In sys/bus.h
|
1999-12-23 17:39:45 +00:00
|
|
|
.Ft device_t
|
1999-12-03 11:22:28 +00:00
|
|
|
.Fn device_add_child "device_t dev" "const char *name" "int unit"
|
1999-12-23 17:39:45 +00:00
|
|
|
.Ft device_t
|
1999-12-03 11:22:28 +00:00
|
|
|
.Fn device_add_child_ordered "device_t dev" "int order" "const char *name" "int unit"
|
1998-09-03 21:52:05 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
Create a new child device of
|
|
|
|
.Fa dev .
|
|
|
|
The
|
|
|
|
.Fa name
|
|
|
|
and
|
|
|
|
.Fa unit
|
|
|
|
arguments specify the name and unit number of the device.
|
|
|
|
If the name is unknown then the caller should pass
|
|
|
|
.Dv NULL .
|
2001-07-14 19:41:16 +00:00
|
|
|
If the unit is unknown then the caller should pass
|
1998-09-03 21:52:05 +00:00
|
|
|
.Dv -1
|
|
|
|
and the system will choose the next available unit number.
|
|
|
|
.Pp
|
|
|
|
The name of the device is used to determine which drivers might be
|
2003-10-23 01:54:06 +00:00
|
|
|
appropriate for the device.
|
|
|
|
If a name is specified then only drivers of that name are probed.
|
2004-05-13 20:29:40 +00:00
|
|
|
If no name is given then all drivers for the owning bus are probed.
|
|
|
|
In any event, only the name of the device is stored so that one may
|
|
|
|
safely unload/load a driver bound to that name.
|
1998-09-03 21:52:05 +00:00
|
|
|
.Pp
|
|
|
|
This allows busses which can uniquely identify device instances (such
|
|
|
|
as PCI) to allow each driver to check each device instance for a
|
2003-10-23 01:54:06 +00:00
|
|
|
match.
|
|
|
|
For busses which rely on supplied probe hints where only one
|
2005-08-09 10:30:25 +00:00
|
|
|
driver can have a chance of probing the device, the driver name should
|
|
|
|
be specified as the device name.
|
1998-09-03 21:52:05 +00:00
|
|
|
.Pp
|
2001-07-14 19:41:16 +00:00
|
|
|
Normally unit numbers will be chosen automatically by the system and a
|
1998-09-03 21:52:05 +00:00
|
|
|
unit number of
|
|
|
|
.Dv -1
|
|
|
|
should be given.
|
2015-10-28 19:11:06 +00:00
|
|
|
When a specific unit number is desired (e.g.,\& for wiring a particular
|
1998-09-03 21:52:05 +00:00
|
|
|
piece of hardware to a pre-configured unit number), that unit should
|
2003-10-23 01:54:06 +00:00
|
|
|
be passed.
|
|
|
|
If the specified unit number is already allocated, a new
|
1998-09-03 21:52:05 +00:00
|
|
|
unit will be allocated and a diagnostic message printed.
|
|
|
|
.Pp
|
|
|
|
If the devices attached to a bus must be probed in a specific order
|
2015-10-28 19:11:06 +00:00
|
|
|
(e.g.,\& for the ISA bus some devices are sensitive to failed probe attempts
|
1999-05-28 09:38:25 +00:00
|
|
|
of unrelated drivers and therefore must be probed first),
|
|
|
|
the
|
|
|
|
.Fa order
|
1998-09-03 21:52:05 +00:00
|
|
|
argument of
|
2002-12-24 13:41:48 +00:00
|
|
|
.Fn device_add_child_ordered
|
1999-05-28 09:38:25 +00:00
|
|
|
should be used to specify a partial ordering.
|
2001-07-14 19:41:16 +00:00
|
|
|
The new device will be added before any existing device with a greater
|
1999-05-28 09:38:25 +00:00
|
|
|
order.
|
2001-07-14 19:41:16 +00:00
|
|
|
If
|
2002-12-24 13:41:48 +00:00
|
|
|
.Fn device_add_child
|
1999-05-28 09:38:25 +00:00
|
|
|
is used, then the new child will be added as if its order was zero.
|
2004-05-13 20:29:40 +00:00
|
|
|
.Pp
|
|
|
|
When adding a device in the context of
|
|
|
|
.Xr DEVICE_IDENTIFY 9
|
2005-08-09 11:14:21 +00:00
|
|
|
routine, the
|
2006-01-13 11:24:08 +00:00
|
|
|
.Xr device_find_child 9
|
2005-08-09 11:14:21 +00:00
|
|
|
routine should be used to ensure that the device has not already been
|
|
|
|
added to the tree.
|
2004-05-13 20:29:40 +00:00
|
|
|
Because the device name and
|
2004-06-16 08:33:57 +00:00
|
|
|
.Vt devclass_t
|
2004-05-13 20:29:40 +00:00
|
|
|
are associated at probe time (not child addition time), previous
|
|
|
|
instances of the driver (say in a module that was later unloaded) may
|
|
|
|
have already added the instance.
|
|
|
|
Authors of bus drivers must likewise be careful when adding children
|
|
|
|
when they are loaded and unloaded to avoid duplication of children
|
|
|
|
devices.
|
2006-09-11 22:17:18 +00:00
|
|
|
.Pp
|
2015-10-28 19:11:06 +00:00
|
|
|
When adding a child to another device node, such as in an identify
|
|
|
|
routine, use
|
2006-09-11 22:17:18 +00:00
|
|
|
.Xr BUS_ADD_CHILD 9
|
|
|
|
instead of
|
|
|
|
.Xr device_add_child 9 .
|
2015-10-28 19:11:06 +00:00
|
|
|
.Xr BUS_ADD_CHILD 9
|
|
|
|
will call
|
|
|
|
.Xr device_add_child 9
|
|
|
|
and add the proper bus-specific data to the new child.
|
|
|
|
.Fn device_add_child
|
|
|
|
does not call
|
|
|
|
.Xr BUS_ADD_CHILD 9 .
|
1998-09-03 21:52:05 +00:00
|
|
|
.Sh RETURN VALUES
|
|
|
|
The new device if successful, NULL otherwise.
|
|
|
|
.Sh SEE ALSO
|
2006-09-11 22:17:18 +00:00
|
|
|
.Xr BUS_ADD_CHILD 9 ,
|
2005-11-18 10:56:28 +00:00
|
|
|
.Xr device 9 ,
|
2006-01-13 11:24:08 +00:00
|
|
|
.Xr device_find_child 9 ,
|
2005-08-09 11:14:21 +00:00
|
|
|
.Xr DEVICE_IDENTIFY 9
|
1998-09-03 21:52:05 +00:00
|
|
|
.Sh AUTHORS
|
2003-10-23 06:24:55 +00:00
|
|
|
This manual page was written by
|
1998-09-03 21:52:05 +00:00
|
|
|
.An Doug Rabson .
|