1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc.,
.\" All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH USB_REGISTER_HOTPLUG_CBS 9F "Aug 17, 2004"
.SH NAME
usb_register_hotplug_cbs, usb_unregister_hotplug_cbs \- Register/unregister for
notification of device hotplug events
.SH SYNOPSIS
.LP
.nf
#include <sys/usb/usba.h>
\fB\fR\fBint\fR \fBusb_register_hotplug_cbs\fR(\fBdev_info_t *\fR\fIdip\fR,
\fBint\fR \fI(*disconnection_event_handler)\fR(dev_info_t *\fIdip\fR,
\fBint\fR \fI(*reconnection_event_handler)\fR(dev_info_t *\fIdip\fR);
.fi
.LP
.nf
\fBvoid\fR \fB\fR\fBusb_unregister_hotplug_cbs\fR(\fBdev_info_t *\fR\fIdip\fR);
.fi
.SH INTERFACE LEVEL
.sp
.LP
Solaris DDI specific (Solaris DDI)
.SH PARAMETERS
.sp
.LP
For \fBusb_register_hotplug_cbs()\fR
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.sp .6
.RS 4n
Pointer to the device's \fBdev_info\fR structure.
.RE
.sp
.ne 2
.na
\fB\fIdisconnection_event_handler\fR\fR
.ad
.sp .6
.RS 4n
Called when device is disconnected. This handler takes a dev_info_t as an
argument (representing the device being disconnected) and always returns
USB_SUCCESS.
.RE
.sp
.ne 2
.na
\fB\fIreconnection_event_handler\fR\fR
.ad
.sp .6
.RS 4n
Called when device is reconnected. This handler takes a dev_info_t as an
argument (representing the device being reconnected) and always returns
USB_SUCCESS.
.RE
.sp
.LP
For \fBusb_unregister_hotplug_cbs()\fR:
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 7n
Pointer to the device's \fBdev_info\fR structure.
.RE
.SH DESCRIPTION
.sp
.LP
The \fBusb_register_hotplug_cbs()\fR function registers callbacks to be
executed when the USB device represented by \fIdip\fR is hotplugged or removed.
.sp
.LP
The \fBusb_unregister_hotplug_cbs()\fR function unregisters or disengages
callbacks from executing when the USB device represented by \fIdip\fR is
hotplugged or removed.
.SH RETURN VALUES
.sp
.LP
For \fBusb_register_hotplug_cbs()\fR:
.sp
.ne 2
.na
\fBUSB_SUCCESS\fR
.ad
.RS 15n
Callbacks were successfully registered.
.RE
.sp
.ne 2
.na
\fBUSB_FAILURE\fR
.ad
.RS 15n
One or more arguments were NULL.
.sp
Callbacks could not be successfully registered.
.RE
.sp
.LP
For \fBusb_unregister_hotplug_cbs()\fR: None
.SH CONTEXT
.sp
.LP
The \fBusb_register_hotplug_cbs()\fR function may be called only from
\fBattach\fR(9E).
.sp
.LP
The \fBusb_unregister_hotplug_cbs()\fR function may be called only from
\fBdetach\fR(9E).
.sp
.LP
Registered callback handlers requiring the use of any DDI (section 9F) function
(except ddi_taskq_* functions), should launch a separate thread using
ddi_taskq_* routines for processing their event, to avoid deadlocks. The new
thread can then safely call any DDI function it needs to handle the event.
.sp
.LP
The registered callback handlers execute in kernel context.
.SH EXAMPLES
.sp
.in +2
.nf
int remove_device(dev_info_t *)
{
...
...
return (USB_SUCCESS);
}
int accommodate_device(dev_info_t *)
{
...
...
return (USB_SUCCESS);
}
if (usb_register_hotplug_cbs(
dip, remove_device, accommodate_device) == USB_FAILURE) {
cmn_err (CE_WARN,
"%s%d: Could not register hotplug handlers.",
ddi_driver_name(dip), ddi_get_instance(dip));
}
.fi
.in -2
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Architecture PCI-based systems
_
Interface stability Committed
.TE
.SH SEE ALSO
.sp
.LP
\fBattributes\fR(5), \fBattach\fR(9E), \fBdetach\fR(9E),
\fBusb_get_status\fR(9F)
|