usb_request.c (31f57dc1) | usb_request.c (2df1e9a6) |
---|---|
1/* $FreeBSD$ */ 2/*- 3 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 4 * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 5 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 259 unchanged lines hidden (view full) --- 268 struct usb_xfer *xfer; 269 const void *desc; 270 int err = 0; 271 usb_ticks_t start_ticks; 272 usb_ticks_t delta_ticks; 273 usb_ticks_t max_ticks; 274 uint16_t length; 275 uint16_t temp; | 1/* $FreeBSD$ */ 2/*- 3 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 4 * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 5 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 259 unchanged lines hidden (view full) --- 268 struct usb_xfer *xfer; 269 const void *desc; 270 int err = 0; 271 usb_ticks_t start_ticks; 272 usb_ticks_t delta_ticks; 273 usb_ticks_t max_ticks; 274 uint16_t length; 275 uint16_t temp; |
276 uint8_t enum_locked; |
|
276 277 if (timeout < 50) { 278 /* timeout is too small */ 279 timeout = 50; 280 } 281 if (timeout > 30000) { 282 /* timeout is too big */ 283 timeout = 30000; 284 } 285 length = UGETW(req->wLength); 286 | 277 278 if (timeout < 50) { 279 /* timeout is too small */ 280 timeout = 50; 281 } 282 if (timeout > 30000) { 283 /* timeout is too big */ 284 timeout = 30000; 285 } 286 length = UGETW(req->wLength); 287 |
288 enum_locked = usbd_enum_is_locked(udev); 289 |
|
287 DPRINTFN(5, "udev=%p bmRequestType=0x%02x bRequest=0x%02x " 288 "wValue=0x%02x%02x wIndex=0x%02x%02x wLength=0x%02x%02x\n", 289 udev, req->bmRequestType, req->bRequest, 290 req->wValue[1], req->wValue[0], 291 req->wIndex[1], req->wIndex[0], 292 req->wLength[1], req->wLength[0]); 293 294 /* Check if the device is still alive */ --- 8 unchanged lines hidden (view full) --- 303 */ 304 if (actlen) 305 *actlen = 0; 306 307#if (USB_HAVE_USER_IO == 0) 308 if (flags & USB_USER_DATA_PTR) 309 return (USB_ERR_INVAL); 310#endif | 290 DPRINTFN(5, "udev=%p bmRequestType=0x%02x bRequest=0x%02x " 291 "wValue=0x%02x%02x wIndex=0x%02x%02x wLength=0x%02x%02x\n", 292 udev, req->bmRequestType, req->bRequest, 293 req->wValue[1], req->wValue[0], 294 req->wIndex[1], req->wIndex[0], 295 req->wLength[1], req->wLength[0]); 296 297 /* Check if the device is still alive */ --- 8 unchanged lines hidden (view full) --- 306 */ 307 if (actlen) 308 *actlen = 0; 309 310#if (USB_HAVE_USER_IO == 0) 311 if (flags & USB_USER_DATA_PTR) 312 return (USB_ERR_INVAL); 313#endif |
311 if (mtx) { | 314 if ((mtx != NULL) && (mtx != &Giant)) { |
312 mtx_unlock(mtx); | 315 mtx_unlock(mtx); |
313 if (mtx != &Giant) { 314 mtx_assert(mtx, MA_NOTOWNED); 315 } | 316 mtx_assert(mtx, MA_NOTOWNED); |
316 } | 317 } |
318 |
|
317 /* | 319 /* |
320 * We need to allow suspend and resume at this point, else the 321 * control transfer will timeout if the device is suspended! 322 */ 323 if (enum_locked) 324 usbd_sr_unlock(udev); 325 326 /* |
|
318 * Grab the default sx-lock so that serialisation 319 * is achieved when multiple threads are involved: 320 */ 321 322 sx_xlock(&udev->ctrl_sx); 323 324 hr_func = usbd_get_hr_func(udev); 325 --- 205 unchanged lines hidden (view full) --- 531 */ 532 usbd_transfer_stop(xfer); 533 } 534 USB_XFER_UNLOCK(xfer); 535 536done: 537 sx_xunlock(&udev->ctrl_sx); 538 | 327 * Grab the default sx-lock so that serialisation 328 * is achieved when multiple threads are involved: 329 */ 330 331 sx_xlock(&udev->ctrl_sx); 332 333 hr_func = usbd_get_hr_func(udev); 334 --- 205 unchanged lines hidden (view full) --- 540 */ 541 usbd_transfer_stop(xfer); 542 } 543 USB_XFER_UNLOCK(xfer); 544 545done: 546 sx_xunlock(&udev->ctrl_sx); 547 |
539 if (mtx) { | 548 if (enum_locked) 549 usbd_sr_lock(udev); 550 551 if ((mtx != NULL) && (mtx != &Giant)) |
540 mtx_lock(mtx); | 552 mtx_lock(mtx); |
541 } | 553 |
542 return ((usb_error_t)err); 543} 544 545/*------------------------------------------------------------------------* 546 * usbd_do_request_proc - factored out code 547 * 548 * This function is factored out code. It does basically the same like 549 * usbd_do_request_flags, except it will check the status of the --- 1069 unchanged lines hidden --- | 554 return ((usb_error_t)err); 555} 556 557/*------------------------------------------------------------------------* 558 * usbd_do_request_proc - factored out code 559 * 560 * This function is factored out code. It does basically the same like 561 * usbd_do_request_flags, except it will check the status of the --- 1069 unchanged lines hidden --- |