anchors.rst 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. USB Anchors
  2. ~~~~~~~~~~~
  3. What is anchor?
  4. ===============
  5. A USB driver needs to support some callbacks requiring
  6. a driver to cease all IO to an interface. To do so, a
  7. driver has to keep track of the URBs it has submitted
  8. to know they've all completed or to call usb_kill_urb
  9. for them. The anchor is a data structure takes care of
  10. keeping track of URBs and provides methods to deal with
  11. multiple URBs.
  12. Allocation and Initialisation
  13. =============================
  14. There's no API to allocate an anchor. It is simply declared
  15. as struct usb_anchor. :c:func:`init_usb_anchor` must be called to
  16. initialise the data structure.
  17. Deallocation
  18. ============
  19. Once it has no more URBs associated with it, the anchor can be
  20. freed with normal memory management operations.
  21. Association and disassociation of URBs with anchors
  22. ===================================================
  23. An association of URBs to an anchor is made by an explicit
  24. call to :c:func:`usb_anchor_urb`. The association is maintained until
  25. an URB is finished by (successful) completion. Thus disassociation
  26. is automatic. A function is provided to forcibly finish (kill)
  27. all URBs associated with an anchor.
  28. Furthermore, disassociation can be made with :c:func:`usb_unanchor_urb`
  29. Operations on multitudes of URBs
  30. ================================
  31. :c:func:`usb_kill_anchored_urbs`
  32. --------------------------------
  33. This function kills all URBs associated with an anchor. The URBs
  34. are called in the reverse temporal order they were submitted.
  35. This way no data can be reordered.
  36. :c:func:`usb_unlink_anchored_urbs`
  37. ----------------------------------
  38. This function unlinks all URBs associated with an anchor. The URBs
  39. are processed in the reverse temporal order they were submitted.
  40. This is similar to :c:func:`usb_kill_anchored_urbs`, but it will not sleep.
  41. Therefore no guarantee is made that the URBs have been unlinked when
  42. the call returns. They may be unlinked later but will be unlinked in
  43. finite time.
  44. :c:func:`usb_scuttle_anchored_urbs`
  45. -----------------------------------
  46. All URBs of an anchor are unanchored en masse.
  47. :c:func:`usb_wait_anchor_empty_timeout`
  48. ---------------------------------------
  49. This function waits for all URBs associated with an anchor to finish
  50. or a timeout, whichever comes first. Its return value will tell you
  51. whether the timeout was reached.
  52. :c:func:`usb_anchor_empty`
  53. --------------------------
  54. Returns true if no URBs are associated with an anchor. Locking
  55. is the caller's responsibility.
  56. :c:func:`usb_get_from_anchor`
  57. -----------------------------
  58. Returns the oldest anchored URB of an anchor. The URB is unanchored
  59. and returned with a reference. As you may mix URBs to several
  60. destinations in one anchor you have no guarantee the chronologically
  61. first submitted URB is returned.