162306a36Sopenharmony_ciUSB Anchors
262306a36Sopenharmony_ci~~~~~~~~~~~
362306a36Sopenharmony_ci
462306a36Sopenharmony_ciWhat is anchor?
562306a36Sopenharmony_ci===============
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciA USB driver needs to support some callbacks requiring
862306a36Sopenharmony_cia driver to cease all IO to an interface. To do so, a
962306a36Sopenharmony_cidriver has to keep track of the URBs it has submitted
1062306a36Sopenharmony_cito know they've all completed or to call usb_kill_urb
1162306a36Sopenharmony_cifor them. The anchor is a data structure takes care of
1262306a36Sopenharmony_cikeeping track of URBs and provides methods to deal with
1362306a36Sopenharmony_cimultiple URBs.
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciAllocation and Initialisation
1662306a36Sopenharmony_ci=============================
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ciThere's no API to allocate an anchor. It is simply declared
1962306a36Sopenharmony_cias struct usb_anchor. :c:func:`init_usb_anchor` must be called to
2062306a36Sopenharmony_ciinitialise the data structure.
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciDeallocation
2362306a36Sopenharmony_ci============
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ciOnce it has no more URBs associated with it, the anchor can be
2662306a36Sopenharmony_cifreed with normal memory management operations.
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ciAssociation and disassociation of URBs with anchors
2962306a36Sopenharmony_ci===================================================
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciAn association of URBs to an anchor is made by an explicit
3262306a36Sopenharmony_cicall to :c:func:`usb_anchor_urb`. The association is maintained until
3362306a36Sopenharmony_cian URB is finished by (successful) completion. Thus disassociation
3462306a36Sopenharmony_ciis automatic. A function is provided to forcibly finish (kill)
3562306a36Sopenharmony_ciall URBs associated with an anchor.
3662306a36Sopenharmony_ciFurthermore, disassociation can be made with :c:func:`usb_unanchor_urb`
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciOperations on multitudes of URBs
3962306a36Sopenharmony_ci================================
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci:c:func:`usb_kill_anchored_urbs`
4262306a36Sopenharmony_ci--------------------------------
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ciThis function kills all URBs associated with an anchor. The URBs
4562306a36Sopenharmony_ciare called in the reverse temporal order they were submitted.
4662306a36Sopenharmony_ciThis way no data can be reordered.
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci:c:func:`usb_unlink_anchored_urbs`
4962306a36Sopenharmony_ci----------------------------------
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciThis function unlinks all URBs associated with an anchor. The URBs
5362306a36Sopenharmony_ciare processed in the reverse temporal order they were submitted.
5462306a36Sopenharmony_ciThis is similar to :c:func:`usb_kill_anchored_urbs`, but it will not sleep.
5562306a36Sopenharmony_ciTherefore no guarantee is made that the URBs have been unlinked when
5662306a36Sopenharmony_cithe call returns. They may be unlinked later but will be unlinked in
5762306a36Sopenharmony_cifinite time.
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci:c:func:`usb_scuttle_anchored_urbs`
6062306a36Sopenharmony_ci-----------------------------------
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ciAll URBs of an anchor are unanchored en masse.
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci:c:func:`usb_wait_anchor_empty_timeout`
6562306a36Sopenharmony_ci---------------------------------------
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ciThis function waits for all URBs associated with an anchor to finish
6862306a36Sopenharmony_cior a timeout, whichever comes first. Its return value will tell you
6962306a36Sopenharmony_ciwhether the timeout was reached.
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci:c:func:`usb_anchor_empty`
7262306a36Sopenharmony_ci--------------------------
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ciReturns true if no URBs are associated with an anchor. Locking
7562306a36Sopenharmony_ciis the caller's responsibility.
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci:c:func:`usb_get_from_anchor`
7862306a36Sopenharmony_ci-----------------------------
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ciReturns the oldest anchored URB of an anchor. The URB is unanchored
8162306a36Sopenharmony_ciand returned with a reference. As you may mix URBs to several
8262306a36Sopenharmony_cidestinations in one anchor you have no guarantee the chronologically
8362306a36Sopenharmony_cifirst submitted URB is returned.
84