xref: /openbsd/share/man/man9/config_attach.9 (revision 32956d1b)
1*32956d1bSschwarze.\"     $OpenBSD: config_attach.9,v 1.3 2014/12/05 16:55:53 schwarze Exp $
2c45c5a4eSmpi.\"     $NetBSD: autoconf.9,v 1.9 2002/02/13 08:18:35 ross Exp $
3c45c5a4eSmpi.\"
4c45c5a4eSmpi.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
5c45c5a4eSmpi.\" All rights reserved.
6c45c5a4eSmpi.\"
7c45c5a4eSmpi.\" This code is derived from software contributed to The NetBSD Foundation
8c45c5a4eSmpi.\" by Gregory McGarry.
9c45c5a4eSmpi.\"
10c45c5a4eSmpi.\" Redistribution and use in source and binary forms, with or without
11c45c5a4eSmpi.\" modification, are permitted provided that the following conditions
12c45c5a4eSmpi.\" are met:
13c45c5a4eSmpi.\" 1. Redistributions of source code must retain the above copyright
14c45c5a4eSmpi.\"    notice, this list of conditions and the following disclaimer.
15c45c5a4eSmpi.\" 2. Redistributions in binary form must reproduce the above copyright
16c45c5a4eSmpi.\"    notice, this list of conditions and the following disclaimer in the
17c45c5a4eSmpi.\"    documentation and/or other materials provided with the distribution.
18c45c5a4eSmpi.\"
19c45c5a4eSmpi.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20c45c5a4eSmpi.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21c45c5a4eSmpi.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22c45c5a4eSmpi.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23c45c5a4eSmpi.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24c45c5a4eSmpi.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25c45c5a4eSmpi.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26c45c5a4eSmpi.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27c45c5a4eSmpi.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28c45c5a4eSmpi.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29c45c5a4eSmpi.\" POSSIBILITY OF SUCH DAMAGE.
30c45c5a4eSmpi.\"
31*32956d1bSschwarze.Dd $Mdocdate: December 5 2014 $
32c45c5a4eSmpi.Dt CONFIG_ATTACH 9
33c45c5a4eSmpi.Os
34c45c5a4eSmpi.Sh NAME
35*32956d1bSschwarze.Nm config_attach ,
36*32956d1bSschwarze.Nm config_detach ,
37*32956d1bSschwarze.Nm config_detach_children
38c45c5a4eSmpi.Nd attach and detach devices
39c45c5a4eSmpi.Sh SYNOPSIS
40c45c5a4eSmpi.In sys/param.h
41c45c5a4eSmpi.In sys/device.h
42c45c5a4eSmpi.Ft "struct device *"
43c45c5a4eSmpi.Fn config_attach "struct device *parent" "void *cf" "void *aux" \
44c45c5a4eSmpi                  "cfprint_t print"
45c45c5a4eSmpi.Ft "int"
46c45c5a4eSmpi.Fn config_detach "struct device *dev" "int flags"
47c45c5a4eSmpi.Ft "int"
48c45c5a4eSmpi.Fn config_detach_children "struct device *parent" "int flags"
49c45c5a4eSmpi.Sh DESCRIPTION
50c45c5a4eSmpiThe
51c45c5a4eSmpi.Fn config_attach
52c45c5a4eSmpifunction attaches a found device.
53c45c5a4eSmpiMemory is allocated for the
54c45c5a4eSmpi.Em softc
55c45c5a4eSmpistructure and the driver's attach function is called according to the
56c45c5a4eSmpiconfiguration table.
57c45c5a4eSmpiIf successful,
58c45c5a4eSmpi.Fn config_attach
59c45c5a4eSmpireturns the
60c45c5a4eSmpi.Em softc .
61c45c5a4eSmpiIf unsuccessful, it returns
62c45c5a4eSmpi.Dv NULL .
63c45c5a4eSmpi.Pp
64c45c5a4eSmpiThe
65c45c5a4eSmpi.Fn config_detach
66c45c5a4eSmpifunction is called by the parent to detach the child device.
67c45c5a4eSmpiThe second argument
68c45c5a4eSmpi.Fa flags
69c45c5a4eSmpicontains detachment flags:
70c45c5a4eSmpi.Bd -literal
71c45c5a4eSmpi#define	DETACH_FORCE	0x01	/* Force detachment; hardware gone */
72c45c5a4eSmpi#define	DETACH_QUIET	0x02	/* Don't print a notice */
73c45c5a4eSmpi.Ed
74c45c5a4eSmpi.Sh CONTEXT
75c45c5a4eSmpi.Fn config_detach
76c45c5a4eSmpiis always called from process context, allowing
77c45c5a4eSmpi.Xr tsleep 9
78c45c5a4eSmpito be called while the device detaches itself (to deal with processes
79c45c5a4eSmpiwhich have a device open).
80c45c5a4eSmpi.Sh RETURN VALUES
81c45c5a4eSmpi.Fn config_detach
82c45c5a4eSmpireturns zero if successful and an error code otherwise.
83c45c5a4eSmpi.Sh SEE ALSO
84c45c5a4eSmpi.Xr config_found 9
85