/* See Cycle bit rules. SW is the consumer for the event ring only. Don't make a ring full of link TRBs. That would be dumb and this would loop. */
static void inc_deq(struct xhci_ctrl *ctrl, struct xhci_ring *ring)
/* See Cycle bit rules. SW is the consumer for the event ring only. Don't make a ring full of link TRBs. That would be dumb and this would loop. */
static void inc_deq(struct xhci_ctrl *ctrl, struct xhci_ring *ring)
{
	do {
		if (last_trb(ctrl, ring, ring->deq_seg, ring->dequeue)) {
			if (ring == ctrl->event_ring &&
					last_trb_on_last_seg(ctrl, ring,
						ring->deq_seg, ring->dequeue)) {
				ring->cycle_state = (ring->cycle_state ? 0 : 1);
			}
			ring->deq_seg = ring->deq_seg->next;
			ring->dequeue = ring->deq_seg->trbs;
		} else {
			ring->dequeue++;
		}
	} while (last_trb(ctrl, ring, ring->deq_seg, ring->dequeue));
}