xref: /openbsd/share/man/man9/config_attach.9 (revision a6445c1d)
1.\"     $OpenBSD: config_attach.9,v 1.2 2014/07/13 10:09:12 jmc Exp $
2.\"     $NetBSD: autoconf.9,v 1.9 2002/02/13 08:18:35 ross Exp $
3.\"
4.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
5.\" All rights reserved.
6.\"
7.\" This code is derived from software contributed to The NetBSD Foundation
8.\" by Gregory McGarry.
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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29.\" POSSIBILITY OF SUCH DAMAGE.
30.\"
31.Dd $Mdocdate: July 13 2014 $
32.Dt CONFIG_ATTACH 9
33.Os
34.Sh NAME
35.Nm config_attach, config_detach, config_detach_children
36.Nd attach and detach devices
37.Sh SYNOPSIS
38.In sys/param.h
39.In sys/device.h
40.Ft "struct device *"
41.Fn config_attach "struct device *parent" "void *cf" "void *aux" \
42                  "cfprint_t print"
43.Ft "int"
44.Fn config_detach "struct device *dev" "int flags"
45.Ft "int"
46.Fn config_detach_children "struct device *parent" "int flags"
47.Sh DESCRIPTION
48The
49.Fn config_attach
50function attaches a found device.
51Memory is allocated for the
52.Em softc
53structure and the driver's attach function is called according to the
54configuration table.
55If successful,
56.Fn config_attach
57returns the
58.Em softc .
59If unsuccessful, it returns
60.Dv NULL .
61.Pp
62The
63.Fn config_detach
64function is called by the parent to detach the child device.
65The second argument
66.Fa flags
67contains detachment flags:
68.Bd -literal
69#define	DETACH_FORCE	0x01	/* Force detachment; hardware gone */
70#define	DETACH_QUIET	0x02	/* Don't print a notice */
71.Ed
72.Sh CONTEXT
73.Fn config_detach
74is always called from process context, allowing
75.Xr tsleep 9
76to be called while the device detaches itself (to deal with processes
77which have a device open).
78.Sh RETURN VALUES
79.Fn config_detach
80returns zero if successful and an error code otherwise.
81.Sh SEE ALSO
82.Xr config_found 9
83