uipaq.c revision 1.1.6.2 1 1.1.6.2 skrll /* $NetBSD: uipaq.c,v 1.1.6.2 2005/11/10 14:08:05 skrll Exp $ */
2 1.1.6.2 skrll /* $OpenBSD: uipaq.c,v 1.1 2005/06/17 23:50:33 deraadt Exp $ */
3 1.1.6.2 skrll
4 1.1.6.2 skrll /*
5 1.1.6.2 skrll * Copyright (c) 2000-2005 The NetBSD Foundation, Inc.
6 1.1.6.2 skrll * All rights reserved.
7 1.1.6.2 skrll *
8 1.1.6.2 skrll * This code is derived from software contributed to The NetBSD Foundation
9 1.1.6.2 skrll * by Lennart Augustsson (lennart (at) augustsson.net) at
10 1.1.6.2 skrll * Carlstedt Research & Technology.
11 1.1.6.2 skrll *
12 1.1.6.2 skrll * Redistribution and use in source and binary forms, with or without
13 1.1.6.2 skrll * modification, are permitted provided that the following conditions
14 1.1.6.2 skrll * are met:
15 1.1.6.2 skrll * 1. Redistributions of source code must retain the above copyright
16 1.1.6.2 skrll * notice, this list of conditions and the following disclaimer.
17 1.1.6.2 skrll * 2. Redistributions in binary form must reproduce the above copyright
18 1.1.6.2 skrll * notice, this list of conditions and the following disclaimer in the
19 1.1.6.2 skrll * documentation and/or other materials provided with the distribution.
20 1.1.6.2 skrll * 3. All advertising materials mentioning features or use of this software
21 1.1.6.2 skrll * must display the following acknowledgement:
22 1.1.6.2 skrll * This product includes software developed by the NetBSD
23 1.1.6.2 skrll * Foundation, Inc. and its contributors.
24 1.1.6.2 skrll * 4. Neither the name of The NetBSD Foundation nor the names of its
25 1.1.6.2 skrll * contributors may be used to endorse or promote products derived
26 1.1.6.2 skrll * from this software without specific prior written permission.
27 1.1.6.2 skrll *
28 1.1.6.2 skrll * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
29 1.1.6.2 skrll * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
30 1.1.6.2 skrll * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 1.1.6.2 skrll * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
32 1.1.6.2 skrll * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 1.1.6.2 skrll * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 1.1.6.2 skrll * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 1.1.6.2 skrll * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 1.1.6.2 skrll * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 1.1.6.2 skrll * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 1.1.6.2 skrll * POSSIBILITY OF SUCH DAMAGE.
39 1.1.6.2 skrll */
40 1.1.6.2 skrll
41 1.1.6.2 skrll /*
42 1.1.6.2 skrll * iPAQ driver
43 1.1.6.2 skrll *
44 1.1.6.2 skrll * 19 July 2003: Incorporated changes suggested by Sam Lawrance from
45 1.1.6.2 skrll * the uppc module
46 1.1.6.2 skrll *
47 1.1.6.2 skrll *
48 1.1.6.2 skrll * Contact isis (at) cs.umd.edu if you have any questions/comments about this driver
49 1.1.6.2 skrll */
50 1.1.6.2 skrll
51 1.1.6.2 skrll #include <sys/param.h>
52 1.1.6.2 skrll #include <sys/systm.h>
53 1.1.6.2 skrll #include <sys/kernel.h>
54 1.1.6.2 skrll #include <sys/device.h>
55 1.1.6.2 skrll #include <sys/conf.h>
56 1.1.6.2 skrll #include <sys/tty.h>
57 1.1.6.2 skrll
58 1.1.6.2 skrll #include <dev/usb/usb.h>
59 1.1.6.2 skrll #include <dev/usb/usbhid.h>
60 1.1.6.2 skrll
61 1.1.6.2 skrll #include <dev/usb/usbcdc.h> /*UCDC_* stuff */
62 1.1.6.2 skrll
63 1.1.6.2 skrll #include <dev/usb/usbdi.h>
64 1.1.6.2 skrll #include <dev/usb/usbdi_util.h>
65 1.1.6.2 skrll #include <dev/usb/usbdevs.h>
66 1.1.6.2 skrll
67 1.1.6.2 skrll #include <dev/usb/ucomvar.h>
68 1.1.6.2 skrll
69 1.1.6.2 skrll #ifdef UIPAQ_DEBUG
70 1.1.6.2 skrll #define DPRINTF(x) if (uipaqdebug) printf x
71 1.1.6.2 skrll #define DPRINTFN(n,x) if (uipaqdebug>(n)) printf x
72 1.1.6.2 skrll int uipaqdebug = 0;
73 1.1.6.2 skrll #else
74 1.1.6.2 skrll #define DPRINTF(x)
75 1.1.6.2 skrll #define DPRINTFN(n,x)
76 1.1.6.2 skrll #endif
77 1.1.6.2 skrll
78 1.1.6.2 skrll #define UIPAQ_CONFIG_NO 1
79 1.1.6.2 skrll #define UIPAQ_IFACE_INDEX 0
80 1.1.6.2 skrll
81 1.1.6.2 skrll #define UIPAQIBUFSIZE 1024
82 1.1.6.2 skrll #define UIPAQOBUFSIZE 1024
83 1.1.6.2 skrll
84 1.1.6.2 skrll struct uipaq_softc {
85 1.1.6.2 skrll USBBASEDEVICE sc_dev; /* base device */
86 1.1.6.2 skrll usbd_device_handle sc_udev; /* device */
87 1.1.6.2 skrll usbd_interface_handle sc_iface; /* interface */
88 1.1.6.2 skrll
89 1.1.6.2 skrll device_ptr_t sc_subdev; /* ucom uses that */
90 1.1.6.2 skrll u_int16_t sc_lcr; /* state for DTR/RTS */
91 1.1.6.2 skrll
92 1.1.6.2 skrll u_int16_t sc_flags;
93 1.1.6.2 skrll
94 1.1.6.2 skrll u_char sc_dying;
95 1.1.6.2 skrll };
96 1.1.6.2 skrll
97 1.1.6.2 skrll /* Callback routines */
98 1.1.6.2 skrll Static void uipaq_set(void *, int, int, int);
99 1.1.6.2 skrll
100 1.1.6.2 skrll
101 1.1.6.2 skrll /* Support routines. */
102 1.1.6.2 skrll /* based on uppc module by Sam Lawrance */
103 1.1.6.2 skrll Static void uipaq_dtr(struct uipaq_softc *sc, int onoff);
104 1.1.6.2 skrll Static void uipaq_rts(struct uipaq_softc *sc, int onoff);
105 1.1.6.2 skrll Static void uipaq_break(struct uipaq_softc* sc, int onoff);
106 1.1.6.2 skrll
107 1.1.6.2 skrll
108 1.1.6.2 skrll struct ucom_methods uipaq_methods = {
109 1.1.6.2 skrll NULL,
110 1.1.6.2 skrll uipaq_set,
111 1.1.6.2 skrll NULL,
112 1.1.6.2 skrll NULL,
113 1.1.6.2 skrll NULL, /*open*/
114 1.1.6.2 skrll NULL, /*close*/
115 1.1.6.2 skrll NULL,
116 1.1.6.2 skrll NULL
117 1.1.6.2 skrll };
118 1.1.6.2 skrll
119 1.1.6.2 skrll struct uipaq_type {
120 1.1.6.2 skrll struct usb_devno uv_dev;
121 1.1.6.2 skrll u_int16_t uv_flags;
122 1.1.6.2 skrll };
123 1.1.6.2 skrll
124 1.1.6.2 skrll static const struct uipaq_type uipaq_devs[] = {
125 1.1.6.2 skrll {{ USB_VENDOR_HP, USB_PRODUCT_HP_2215 }, 0 },
126 1.1.6.2 skrll {{ USB_VENDOR_HP, USB_PRODUCT_HP_568J }, 0},
127 1.1.6.2 skrll {{ USB_VENDOR_COMPAQ, USB_PRODUCT_COMPAQ_IPAQPOCKETPC} , 0},
128 1.1.6.2 skrll {{ USB_VENDOR_CASIO, USB_PRODUCT_CASIO_BE300} , 0}
129 1.1.6.2 skrll };
130 1.1.6.2 skrll
131 1.1.6.2 skrll #define uipaq_lookup(v, p) ((const struct uipaq_type *)usb_lookup(uipaq_devs, v, p))
132 1.1.6.2 skrll
133 1.1.6.2 skrll USB_DECLARE_DRIVER(uipaq);
134 1.1.6.2 skrll
135 1.1.6.2 skrll USB_MATCH(uipaq)
136 1.1.6.2 skrll {
137 1.1.6.2 skrll USB_MATCH_START(uipaq, uaa);
138 1.1.6.2 skrll
139 1.1.6.2 skrll if (uaa->iface != NULL)
140 1.1.6.2 skrll return (UMATCH_NONE);
141 1.1.6.2 skrll
142 1.1.6.2 skrll DPRINTFN(20,("uipaq: vendor=0x%x, product=0x%x\n",
143 1.1.6.2 skrll uaa->vendor, uaa->product));
144 1.1.6.2 skrll
145 1.1.6.2 skrll return (uipaq_lookup(uaa->vendor, uaa->product) != NULL ?
146 1.1.6.2 skrll UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
147 1.1.6.2 skrll }
148 1.1.6.2 skrll
149 1.1.6.2 skrll USB_ATTACH(uipaq)
150 1.1.6.2 skrll {
151 1.1.6.2 skrll USB_ATTACH_START(uipaq, sc, uaa);
152 1.1.6.2 skrll usbd_device_handle dev = uaa->device;
153 1.1.6.2 skrll usbd_interface_handle iface;
154 1.1.6.2 skrll usb_interface_descriptor_t *id;
155 1.1.6.2 skrll usb_endpoint_descriptor_t *ed;
156 1.1.6.2 skrll char *devinfop;
157 1.1.6.2 skrll char *devname = USBDEVNAME(sc->sc_dev);
158 1.1.6.2 skrll int i;
159 1.1.6.2 skrll usbd_status err;
160 1.1.6.2 skrll struct ucom_attach_args uca;
161 1.1.6.2 skrll
162 1.1.6.2 skrll DPRINTFN(10,("\nuipaq_attach: sc=%p\n", sc));
163 1.1.6.2 skrll
164 1.1.6.2 skrll /* Move the device into the configured state. */
165 1.1.6.2 skrll err = usbd_set_config_no(dev, UIPAQ_CONFIG_NO, 1);
166 1.1.6.2 skrll if (err) {
167 1.1.6.2 skrll printf("\n%s: failed to set configuration, err=%s\n",
168 1.1.6.2 skrll devname, usbd_errstr(err));
169 1.1.6.2 skrll goto bad;
170 1.1.6.2 skrll }
171 1.1.6.2 skrll
172 1.1.6.2 skrll err = usbd_device2interface_handle(dev, UIPAQ_IFACE_INDEX, &iface);
173 1.1.6.2 skrll if (err) {
174 1.1.6.2 skrll printf("\n%s: failed to get interface, err=%s\n",
175 1.1.6.2 skrll devname, usbd_errstr(err));
176 1.1.6.2 skrll goto bad;
177 1.1.6.2 skrll }
178 1.1.6.2 skrll
179 1.1.6.2 skrll devinfop = usbd_devinfo_alloc(dev, 0);
180 1.1.6.2 skrll USB_ATTACH_SETUP;
181 1.1.6.2 skrll printf("%s: %s\n", devname, devinfop);
182 1.1.6.2 skrll usbd_devinfo_free(devinfop);
183 1.1.6.2 skrll
184 1.1.6.2 skrll sc->sc_flags = uipaq_lookup(uaa->vendor, uaa->product)->uv_flags;
185 1.1.6.2 skrll
186 1.1.6.2 skrll id = usbd_get_interface_descriptor(iface);
187 1.1.6.2 skrll
188 1.1.6.2 skrll sc->sc_udev = dev;
189 1.1.6.2 skrll sc->sc_iface = iface;
190 1.1.6.2 skrll
191 1.1.6.2 skrll uca.ibufsize = UIPAQIBUFSIZE;
192 1.1.6.2 skrll uca.obufsize = UIPAQOBUFSIZE;
193 1.1.6.2 skrll uca.ibufsizepad = UIPAQIBUFSIZE;
194 1.1.6.2 skrll uca.opkthdrlen = 0;
195 1.1.6.2 skrll uca.device = dev;
196 1.1.6.2 skrll uca.iface = iface;
197 1.1.6.2 skrll uca.methods = &uipaq_methods;
198 1.1.6.2 skrll uca.arg = sc;
199 1.1.6.2 skrll uca.portno = UCOM_UNK_PORTNO;
200 1.1.6.2 skrll uca.info = "Generic";
201 1.1.6.2 skrll
202 1.1.6.2 skrll /* err = uipaq_init(sc);
203 1.1.6.2 skrll if (err) {
204 1.1.6.2 skrll printf("%s: init failed, %s\n", USBDEVNAME(sc->sc_dev),
205 1.1.6.2 skrll usbd_errstr(err));
206 1.1.6.2 skrll goto bad;
207 1.1.6.2 skrll }*/
208 1.1.6.2 skrll
209 1.1.6.2 skrll usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
210 1.1.6.2 skrll USBDEV(sc->sc_dev));
211 1.1.6.2 skrll
212 1.1.6.2 skrll uca.bulkin = uca.bulkout = -1;
213 1.1.6.2 skrll for (i=0; i<id->bNumEndpoints; i++) {
214 1.1.6.2 skrll ed = usbd_interface2endpoint_descriptor(iface, i);
215 1.1.6.2 skrll if (ed == NULL) {
216 1.1.6.2 skrll printf("%s: no endpoint descriptor for %d\n",
217 1.1.6.2 skrll devname,i);
218 1.1.6.2 skrll goto bad;
219 1.1.6.2 skrll }
220 1.1.6.2 skrll if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
221 1.1.6.2 skrll (ed->bmAttributes & UE_XFERTYPE) == UE_BULK) {
222 1.1.6.2 skrll uca.bulkin = ed->bEndpointAddress;
223 1.1.6.2 skrll } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
224 1.1.6.2 skrll (ed->bmAttributes & UE_XFERTYPE) == UE_BULK) {
225 1.1.6.2 skrll uca.bulkout = ed->bEndpointAddress;
226 1.1.6.2 skrll }
227 1.1.6.2 skrll }
228 1.1.6.2 skrll if (uca.bulkin == -1 || uca.bulkout == -1) {
229 1.1.6.2 skrll printf("%s: no proper endpoints found (%d,%d) \n",
230 1.1.6.2 skrll devname, uca.bulkin, uca.bulkout);
231 1.1.6.2 skrll USB_ATTACH_ERROR_RETURN;
232 1.1.6.2 skrll }
233 1.1.6.2 skrll
234 1.1.6.2 skrll sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, &uca,
235 1.1.6.2 skrll ucomprint, ucomsubmatch);
236 1.1.6.2 skrll
237 1.1.6.2 skrll USB_ATTACH_SUCCESS_RETURN;
238 1.1.6.2 skrll
239 1.1.6.2 skrll bad:
240 1.1.6.2 skrll DPRINTF(("uipaq_attach: ATTACH ERROR\n"));
241 1.1.6.2 skrll sc->sc_dying = 1;
242 1.1.6.2 skrll USB_ATTACH_ERROR_RETURN;
243 1.1.6.2 skrll }
244 1.1.6.2 skrll
245 1.1.6.2 skrll
246 1.1.6.2 skrll void
247 1.1.6.2 skrll uipaq_dtr(struct uipaq_softc* sc, int onoff)
248 1.1.6.2 skrll {
249 1.1.6.2 skrll usb_device_request_t req;
250 1.1.6.2 skrll usbd_status err;
251 1.1.6.2 skrll int retries = 3;
252 1.1.6.2 skrll
253 1.1.6.2 skrll DPRINTF(("%s: uipaq_dtr: onoff=%x\n", USBDEVNAME(sc->sc_dev), onoff));
254 1.1.6.2 skrll
255 1.1.6.2 skrll /* Avoid sending unnecessary requests */
256 1.1.6.2 skrll if (onoff && (sc->sc_lcr & UCDC_LINE_DTR))
257 1.1.6.2 skrll return;
258 1.1.6.2 skrll if (!onoff && !(sc->sc_lcr & UCDC_LINE_DTR))
259 1.1.6.2 skrll return;
260 1.1.6.2 skrll
261 1.1.6.2 skrll /* Other parameters depend on reg */
262 1.1.6.2 skrll req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
263 1.1.6.2 skrll req.bRequest = UCDC_SET_CONTROL_LINE_STATE;
264 1.1.6.2 skrll sc->sc_lcr = onoff ? sc->sc_lcr | UCDC_LINE_DTR : sc->sc_lcr & ~UCDC_LINE_DTR;
265 1.1.6.2 skrll USETW(req.wValue, sc->sc_lcr);
266 1.1.6.2 skrll USETW(req.wIndex, 0x0);
267 1.1.6.2 skrll USETW(req.wLength, 0);
268 1.1.6.2 skrll
269 1.1.6.2 skrll /* Fire off the request a few times if necessary */
270 1.1.6.2 skrll while (retries) {
271 1.1.6.2 skrll err = usbd_do_request(sc->sc_udev, &req, NULL);
272 1.1.6.2 skrll if (!err)
273 1.1.6.2 skrll break;
274 1.1.6.2 skrll retries--;
275 1.1.6.2 skrll }
276 1.1.6.2 skrll }
277 1.1.6.2 skrll
278 1.1.6.2 skrll
279 1.1.6.2 skrll void
280 1.1.6.2 skrll uipaq_rts(struct uipaq_softc* sc, int onoff)
281 1.1.6.2 skrll {
282 1.1.6.2 skrll usb_device_request_t req;
283 1.1.6.2 skrll usbd_status err;
284 1.1.6.2 skrll int retries = 3;
285 1.1.6.2 skrll
286 1.1.6.2 skrll DPRINTF(("%s: uipaq_rts: onoff=%x\n", USBDEVNAME(sc->sc_dev), onoff));
287 1.1.6.2 skrll
288 1.1.6.2 skrll /* Avoid sending unnecessary requests */
289 1.1.6.2 skrll if (onoff && (sc->sc_lcr & UCDC_LINE_RTS)) return;
290 1.1.6.2 skrll if (!onoff && !(sc->sc_lcr & UCDC_LINE_RTS)) return;
291 1.1.6.2 skrll
292 1.1.6.2 skrll req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
293 1.1.6.2 skrll req.bRequest = UCDC_SET_CONTROL_LINE_STATE;
294 1.1.6.2 skrll sc->sc_lcr = onoff ? sc->sc_lcr | UCDC_LINE_RTS : sc->sc_lcr & ~UCDC_LINE_RTS;
295 1.1.6.2 skrll USETW(req.wValue, sc->sc_lcr);
296 1.1.6.2 skrll USETW(req.wIndex, 0x0);
297 1.1.6.2 skrll USETW(req.wLength, 0);
298 1.1.6.2 skrll
299 1.1.6.2 skrll while (retries) {
300 1.1.6.2 skrll err = usbd_do_request(sc->sc_udev, &req, NULL);
301 1.1.6.2 skrll if (!err)
302 1.1.6.2 skrll break;
303 1.1.6.2 skrll retries--;
304 1.1.6.2 skrll }
305 1.1.6.2 skrll }
306 1.1.6.2 skrll
307 1.1.6.2 skrll
308 1.1.6.2 skrll void
309 1.1.6.2 skrll uipaq_break(struct uipaq_softc* sc, int onoff)
310 1.1.6.2 skrll {
311 1.1.6.2 skrll usb_device_request_t req;
312 1.1.6.2 skrll usbd_status err;
313 1.1.6.2 skrll int retries = 3;
314 1.1.6.2 skrll
315 1.1.6.2 skrll DPRINTF(("%s: uipaq_break: onoff=%x\n", USBDEVNAME(sc->sc_dev), onoff));
316 1.1.6.2 skrll
317 1.1.6.2 skrll req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
318 1.1.6.2 skrll req.bRequest = UCDC_SEND_BREAK;
319 1.1.6.2 skrll
320 1.1.6.2 skrll USETW(req.wValue, onoff ? UCDC_BREAK_ON : UCDC_BREAK_OFF);
321 1.1.6.2 skrll USETW(req.wIndex, 0x0);
322 1.1.6.2 skrll USETW(req.wLength, 0);
323 1.1.6.2 skrll
324 1.1.6.2 skrll while (retries) {
325 1.1.6.2 skrll err = usbd_do_request(sc->sc_udev, &req, NULL);
326 1.1.6.2 skrll if (!err)
327 1.1.6.2 skrll break;
328 1.1.6.2 skrll retries--;
329 1.1.6.2 skrll }
330 1.1.6.2 skrll }
331 1.1.6.2 skrll
332 1.1.6.2 skrll
333 1.1.6.2 skrll void
334 1.1.6.2 skrll uipaq_set(void *addr, int portno, int reg, int onoff)
335 1.1.6.2 skrll {
336 1.1.6.2 skrll struct uipaq_softc* sc = addr;
337 1.1.6.2 skrll
338 1.1.6.2 skrll switch (reg) {
339 1.1.6.2 skrll case UCOM_SET_DTR:
340 1.1.6.2 skrll uipaq_dtr(addr, onoff);
341 1.1.6.2 skrll break;
342 1.1.6.2 skrll case UCOM_SET_RTS:
343 1.1.6.2 skrll uipaq_rts(addr, onoff);
344 1.1.6.2 skrll break;
345 1.1.6.2 skrll case UCOM_SET_BREAK:
346 1.1.6.2 skrll uipaq_break(addr, onoff);
347 1.1.6.2 skrll break;
348 1.1.6.2 skrll default:
349 1.1.6.2 skrll printf("%s: unhandled set request: reg=%x onoff=%x\n",
350 1.1.6.2 skrll USBDEVNAME(sc->sc_dev), reg, onoff);
351 1.1.6.2 skrll return;
352 1.1.6.2 skrll }
353 1.1.6.2 skrll }
354 1.1.6.2 skrll
355 1.1.6.2 skrll
356 1.1.6.2 skrll int
357 1.1.6.2 skrll uipaq_activate(device_ptr_t self, enum devact act)
358 1.1.6.2 skrll {
359 1.1.6.2 skrll struct uipaq_softc *sc = (struct uipaq_softc *)self;
360 1.1.6.2 skrll int rv = 0;
361 1.1.6.2 skrll
362 1.1.6.2 skrll switch (act) {
363 1.1.6.2 skrll case DVACT_ACTIVATE:
364 1.1.6.2 skrll return (EOPNOTSUPP);
365 1.1.6.2 skrll break;
366 1.1.6.2 skrll
367 1.1.6.2 skrll case DVACT_DEACTIVATE:
368 1.1.6.2 skrll if (sc->sc_subdev != NULL)
369 1.1.6.2 skrll rv = config_deactivate(sc->sc_subdev);
370 1.1.6.2 skrll sc->sc_dying = 1;
371 1.1.6.2 skrll break;
372 1.1.6.2 skrll }
373 1.1.6.2 skrll return (rv);
374 1.1.6.2 skrll }
375 1.1.6.2 skrll
376 1.1.6.2 skrll int
377 1.1.6.2 skrll uipaq_detach(device_ptr_t self, int flags)
378 1.1.6.2 skrll {
379 1.1.6.2 skrll struct uipaq_softc *sc = (struct uipaq_softc *)self;
380 1.1.6.2 skrll int rv = 0;
381 1.1.6.2 skrll
382 1.1.6.2 skrll DPRINTF(("uipaq_detach: sc=%p flags=%d\n", sc, flags));
383 1.1.6.2 skrll sc->sc_dying = 1;
384 1.1.6.2 skrll if (sc->sc_subdev != NULL) {
385 1.1.6.2 skrll rv |= config_detach(sc->sc_subdev, flags);
386 1.1.6.2 skrll sc->sc_subdev = NULL;
387 1.1.6.2 skrll }
388 1.1.6.2 skrll
389 1.1.6.2 skrll usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
390 1.1.6.2 skrll USBDEV(sc->sc_dev));
391 1.1.6.2 skrll
392 1.1.6.2 skrll return (rv);
393 1.1.6.2 skrll }
394 1.1.6.2 skrll
395