xref: /openbsd-src/share/man/man9/config_attach.9 (revision 32956d1b6528c69fe7874edb648966d90bef5306)
1.\"     $OpenBSD: config_attach.9,v 1.3 2014/12/05 16:55:53 schwarze 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: December 5 2014 $
32.Dt CONFIG_ATTACH 9
33.Os
34.Sh NAME
35.Nm config_attach ,
36.Nm config_detach ,
37.Nm config_detach_children
38.Nd attach and detach devices
39.Sh SYNOPSIS
40.In sys/param.h
41.In sys/device.h
42.Ft "struct device *"
43.Fn config_attach "struct device *parent" "void *cf" "void *aux" \
44                  "cfprint_t print"
45.Ft "int"
46.Fn config_detach "struct device *dev" "int flags"
47.Ft "int"
48.Fn config_detach_children "struct device *parent" "int flags"
49.Sh DESCRIPTION
50The
51.Fn config_attach
52function attaches a found device.
53Memory is allocated for the
54.Em softc
55structure and the driver's attach function is called according to the
56configuration table.
57If successful,
58.Fn config_attach
59returns the
60.Em softc .
61If unsuccessful, it returns
62.Dv NULL .
63.Pp
64The
65.Fn config_detach
66function is called by the parent to detach the child device.
67The second argument
68.Fa flags
69contains detachment flags:
70.Bd -literal
71#define	DETACH_FORCE	0x01	/* Force detachment; hardware gone */
72#define	DETACH_QUIET	0x02	/* Don't print a notice */
73.Ed
74.Sh CONTEXT
75.Fn config_detach
76is always called from process context, allowing
77.Xr tsleep 9
78to be called while the device detaches itself (to deal with processes
79which have a device open).
80.Sh RETURN VALUES
81.Fn config_detach
82returns zero if successful and an error code otherwise.
83.Sh SEE ALSO
84.Xr config_found 9
85