Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: documentation update for usb_unlink_urb

This patch (as936) updates the kerneldoc for usb_unlink_urb. The
explanation of how endpoint queues are meant to work is now clearer
and in better agreement with reality.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
beafef07 e7e7c360

+41 -39
+41 -39
drivers/usb/core/urb.c
··· 440 440 * @urb: pointer to urb describing a previously submitted request, 441 441 * may be NULL 442 442 * 443 - * This routine cancels an in-progress request. URBs complete only 444 - * once per submission, and may be canceled only once per submission. 445 - * Successful cancellation means the requests's completion handler will 446 - * be called with a status code indicating that the request has been 447 - * canceled (rather than any other code) and will quickly be removed 448 - * from host controller data structures. 443 + * This routine cancels an in-progress request. URBs complete only once 444 + * per submission, and may be canceled only once per submission. 445 + * Successful cancellation means termination of @urb will be expedited 446 + * and the completion handler will be called with a status code 447 + * indicating that the request has been canceled (rather than any other 448 + * code). 449 449 * 450 - * This request is always asynchronous. 451 - * Success is indicated by returning -EINPROGRESS, 452 - * at which time the URB will normally have been unlinked but not yet 453 - * given back to the device driver. When it is called, the completion 454 - * function will see urb->status == -ECONNRESET. Failure is indicated 455 - * by any other return value. Unlinking will fail when the URB is not 456 - * currently "linked" (i.e., it was never submitted, or it was unlinked 457 - * before, or the hardware is already finished with it), even if the 458 - * completion handler has not yet run. 450 + * This request is always asynchronous. Success is indicated by 451 + * returning -EINPROGRESS, at which time the URB will probably not yet 452 + * have been given back to the device driver. When it is eventually 453 + * called, the completion function will see @urb->status == -ECONNRESET. 454 + * Failure is indicated by usb_unlink_urb() returning any other value. 455 + * Unlinking will fail when @urb is not currently "linked" (i.e., it was 456 + * never submitted, or it was unlinked before, or the hardware is already 457 + * finished with it), even if the completion handler has not yet run. 459 458 * 460 459 * Unlinking and Endpoint Queues: 460 + * 461 + * [The behaviors and guarantees described below do not apply to virtual 462 + * root hubs but only to endpoint queues for physical USB devices.] 461 463 * 462 464 * Host Controller Drivers (HCDs) place all the URBs for a particular 463 465 * endpoint in a queue. Normally the queue advances as the controller 464 466 * hardware processes each request. But when an URB terminates with an 465 - * error its queue stops, at least until that URB's completion routine 466 - * returns. It is guaranteed that the queue will not restart until all 467 - * its unlinked URBs have been fully retired, with their completion 468 - * routines run, even if that's not until some time after the original 469 - * completion handler returns. Normally the same behavior and guarantees 470 - * apply when an URB terminates because it was unlinked; however if an 471 - * URB is unlinked before the hardware has started to execute it, then 472 - * its queue is not guaranteed to stop until all the preceding URBs have 473 - * completed. 467 + * error its queue generally stops (see below), at least until that URB's 468 + * completion routine returns. It is guaranteed that a stopped queue 469 + * will not restart until all its unlinked URBs have been fully retired, 470 + * with their completion routines run, even if that's not until some time 471 + * after the original completion handler returns. The same behavior and 472 + * guarantee apply when an URB terminates because it was unlinked. 474 473 * 475 - * This means that USB device drivers can safely build deep queues for 476 - * large or complex transfers, and clean them up reliably after any sort 477 - * of aborted transfer by unlinking all pending URBs at the first fault. 474 + * Bulk and interrupt endpoint queues are guaranteed to stop whenever an 475 + * URB terminates with any sort of error, including -ECONNRESET, -ENOENT, 476 + * and -EREMOTEIO. Control endpoint queues behave the same way except 477 + * that they are not guaranteed to stop for -EREMOTEIO errors. Queues 478 + * for isochronous endpoints are treated differently, because they must 479 + * advance at fixed rates. Such queues do not stop when an URB 480 + * encounters an error or is unlinked. An unlinked isochronous URB may 481 + * leave a gap in the stream of packets; it is undefined whether such 482 + * gaps can be filled in. 478 483 * 479 - * Note that an URB terminating early because a short packet was received 480 - * will count as an error if and only if the URB_SHORT_NOT_OK flag is set. 481 - * Also, that all unlinks performed in any URB completion handler must 482 - * be asynchronous. 484 + * Note that early termination of an URB because a short packet was 485 + * received will generate a -EREMOTEIO error if and only if the 486 + * URB_SHORT_NOT_OK flag is set. By setting this flag, USB device 487 + * drivers can build deep queues for large or complex bulk transfers 488 + * and clean them up reliably after any sort of aborted transfer by 489 + * unlinking all pending URBs at the first fault. 483 490 * 484 - * Queues for isochronous endpoints are treated differently, because they 485 - * advance at fixed rates. Such queues do not stop when an URB is unlinked. 486 - * An unlinked URB may leave a gap in the stream of packets. It is undefined 487 - * whether such gaps can be filled in. 488 - * 489 - * When a control URB terminates with an error, it is likely that the 490 - * status stage of the transfer will not take place, even if it is merely 491 - * a soft error resulting from a short-packet with URB_SHORT_NOT_OK set. 491 + * When a control URB terminates with an error other than -EREMOTEIO, it 492 + * is quite likely that the status stage of the transfer will not take 493 + * place. 492 494 */ 493 495 int usb_unlink_urb(struct urb *urb) 494 496 {