xhci: Clean up cycle bit math used during stalls.
authorSarah Sharp <sarah.a.sharp@linux.intel.com>
Thu, 24 Feb 2011 02:13:43 +0000 (18:13 -0800)
committerSarah Sharp <sarah.a.sharp@linux.intel.com>
Mon, 14 Mar 2011 01:23:56 +0000 (18:23 -0700)
Use XOR to invert the cycle bit, instead of a more complicated
calculation.  Eliminate a check for the link TRB type in find_trb_seg().
We know that there will always be a link TRB at the end of a segment, so
xhci_segment->trbs[TRBS_PER_SEGMENT - 1] will always have a link TRB type.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Tested-by: Takashi Iwai <tiwai@suse.de>
drivers/usb/host/xhci-ring.c

index cf86eb70a62e8173e54a7558b95089a0339a0328..032af7e8a6bfc60bcd28f82d071238da541f7a5a 100644 (file)
@@ -380,10 +380,8 @@ static struct xhci_segment *find_trb_seg(
        while (cur_seg->trbs > trb ||
                        &cur_seg->trbs[TRBS_PER_SEGMENT - 1] < trb) {
                generic_trb = &cur_seg->trbs[TRBS_PER_SEGMENT - 1].generic;
-               if ((generic_trb->field[3] & TRB_TYPE_BITMASK) ==
-                               TRB_TYPE(TRB_LINK) &&
-                               (generic_trb->field[3] & LINK_TOGGLE))
-                       *cycle_state = ~(*cycle_state) & 0x1;
+               if (generic_trb->field[3] & LINK_TOGGLE)
+                       *cycle_state ^= 0x1;
                cur_seg = cur_seg->next;
                if (cur_seg == start_seg)
                        /* Looped over the entire list.  Oops! */
@@ -492,7 +490,7 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
        trb = &state->new_deq_ptr->generic;
        if ((trb->field[3] & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK) &&
                                (trb->field[3] & LINK_TOGGLE))
-               state->new_cycle_state = ~(state->new_cycle_state) & 0x1;
+               state->new_cycle_state ^= 0x1;
        next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr);
 
        /*