Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / usb_register_hotplug_cbs.9f
blob57642a40b82d51aa26b568241c4d0d295e8b617d
1 '\" te
2 .\" Copyright (c) 2004, Sun Microsystems, Inc.,
3 .\" All Rights Reserved
4 .\" 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.
5 .\" 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.
6 .\" 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]
7 .TH USB_REGISTER_HOTPLUG_CBS 9F "Aug 17, 2004"
8 .SH NAME
9 usb_register_hotplug_cbs, usb_unregister_hotplug_cbs \- Register/unregister for
10 notification of device hotplug events
11 .SH SYNOPSIS
12 .LP
13 .nf
14 #include <sys/usb/usba.h>
18 \fB\fR\fBint\fR \fBusb_register_hotplug_cbs\fR(\fBdev_info_t *\fR\fIdip\fR,
19      \fBint\fR \fI(*disconnection_event_handler)\fR(dev_info_t *\fIdip\fR,
20      \fBint\fR \fI(*reconnection_event_handler)\fR(dev_info_t *\fIdip\fR);
21 .fi
23 .LP
24 .nf
25  \fBvoid\fR \fB\fR\fBusb_unregister_hotplug_cbs\fR(\fBdev_info_t *\fR\fIdip\fR);
26 .fi
28 .SH INTERFACE LEVEL
29 .sp
30 .LP
31 Solaris DDI specific (Solaris DDI)
32 .SH PARAMETERS
33 .sp
34 .LP
35 For \fBusb_register_hotplug_cbs()\fR
36 .sp
37 .ne 2
38 .na
39 \fB\fIdip\fR\fR
40 .ad
41 .sp .6
42 .RS 4n
43 Pointer to the device's \fBdev_info\fR structure.
44 .RE
46 .sp
47 .ne 2
48 .na
49 \fB\fIdisconnection_event_handler\fR\fR
50 .ad
51 .sp .6
52 .RS 4n
53 Called when device is disconnected. This handler takes a dev_info_t as an
54 argument (representing the device being disconnected) and always returns
55 USB_SUCCESS.
56 .RE
58 .sp
59 .ne 2
60 .na
61 \fB\fIreconnection_event_handler\fR\fR
62 .ad
63 .sp .6
64 .RS 4n
65 Called when device is reconnected. This handler takes a dev_info_t as an
66 argument (representing the device being reconnected) and always returns
67 USB_SUCCESS.
68 .RE
70 .sp
71 .LP
72 For \fBusb_unregister_hotplug_cbs()\fR:
73 .sp
74 .ne 2
75 .na
76 \fB\fIdip\fR\fR
77 .ad
78 .RS 7n
79 Pointer to the device's \fBdev_info\fR structure.
80 .RE
82 .SH DESCRIPTION
83 .sp
84 .LP
85 The \fBusb_register_hotplug_cbs()\fR function registers callbacks to be
86 executed when the USB device represented by \fIdip\fR is hotplugged or removed.
87 .sp
88 .LP
89 The \fBusb_unregister_hotplug_cbs()\fR function unregisters or disengages
90 callbacks from executing when the USB device represented by \fIdip\fR is
91 hotplugged or removed.
92 .SH RETURN VALUES
93 .sp
94 .LP
95 For \fBusb_register_hotplug_cbs()\fR:
96 .sp
97 .ne 2
98 .na
99 \fBUSB_SUCCESS\fR
101 .RS 15n
102 Callbacks were successfully registered.
106 .ne 2
108 \fBUSB_FAILURE\fR
110 .RS 15n
111 One or more arguments were NULL.
113 Callbacks could not be successfully registered.
118 For \fBusb_unregister_hotplug_cbs()\fR: None
119 .SH CONTEXT
122 The \fBusb_register_hotplug_cbs()\fR function may be called only from
123 \fBattach\fR(9E).
126 The \fBusb_unregister_hotplug_cbs()\fR function may be called only from
127 \fBdetach\fR(9E).
130 Registered callback handlers requiring the use of any DDI (section 9F) function
131 (except ddi_taskq_* functions), should launch a separate thread using
132 ddi_taskq_* routines for processing their event, to avoid deadlocks. The new
133 thread can then safely call any DDI function it needs to handle the event.
136 The registered callback handlers execute in kernel context.
137 .SH EXAMPLES
139 .in +2
142     int remove_device(dev_info_t *)
143     {
144             ...
145             ...
146             return (USB_SUCCESS);
147     }
149     int accommodate_device(dev_info_t *)
150     {
151             ...
152             ...
153             return (USB_SUCCESS);
154     }
156     if (usb_register_hotplug_cbs(
157         dip, remove_device, accommodate_device) == USB_FAILURE) {
158             cmn_err (CE_WARN,
159                 "%s%d: Could not register hotplug handlers.",
160                 ddi_driver_name(dip), ddi_get_instance(dip));
161     }
164 .in -2
166 .SH ATTRIBUTES
169 See \fBattributes\fR(5) for descriptions of the following attributes:
174 box;
175 c | c
176 l | l .
177 ATTRIBUTE TYPE  ATTRIBUTE VALUE
179 Architecture    PCI-based systems
181 Interface stability     Committed
184 .SH SEE ALSO
187 \fBattributes\fR(5), \fBattach\fR(9E), \fBdetach\fR(9E),
188 \fBusb_get_status\fR(9F)