anchors.rst 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_scuttle_anchored_urbs`
  37. -----------------------------------
  38. All URBs of an anchor are unanchored en masse.
  39. :c:func:`usb_wait_anchor_empty_timeout`
  40. ---------------------------------------
  41. This function waits for all URBs associated with an anchor to finish
  42. or a timeout, whichever comes first. Its return value will tell you
  43. whether the timeout was reached.
  44. :c:func:`usb_anchor_empty`
  45. --------------------------
  46. Returns true if no URBs are associated with an anchor. Locking
  47. is the caller's responsibility.
  48. :c:func:`usb_get_from_anchor`
  49. -----------------------------
  50. Returns the oldest anchored URB of an anchor. The URB is unanchored
  51. and returned with a reference. As you may mix URBs to several
  52. destinations in one anchor you have no guarantee the chronologically
  53. first submitted URB is returned.