Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: uhci: don't use pseudo negative values

The code in uhci-q.c doesn't have to use pseudo-negative values. I did
it that way because it was easy and because it would give the expected
output during debugging. But it doesn't have to work that way. Here's
another approach.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
7ea0a2bc 66760169

+7 -8
+3 -1
drivers/usb/host/uhci-debug.c
··· 118 118 } 119 119 120 120 out += sprintf(out, "%s%s", ptype, (urbp->fsbr ? " FSBR" : "")); 121 - out += sprintf(out, " Actlen=%d", urbp->urb->actual_length); 121 + out += sprintf(out, " Actlen=%d%s", urbp->urb->actual_length, 122 + (urbp->qh->type == USB_ENDPOINT_XFER_CONTROL ? 123 + "-8" : "")); 122 124 123 125 if (urbp->urb->unlinked) 124 126 out += sprintf(out, " Unlinked=%d", urbp->urb->unlinked);
+4 -7
drivers/usb/host/uhci-q.c
··· 899 899 } 900 900 if (qh->state != QH_STATE_ACTIVE) 901 901 qh->skel = skel; 902 - 903 - urb->actual_length = -8; /* Account for the SETUP packet */ 904 902 return 0; 905 903 906 904 nomem: ··· 1492 1494 1493 1495 if (qh->type == USB_ENDPOINT_XFER_CONTROL) { 1494 1496 1495 - /* urb->actual_length < 0 means the setup transaction didn't 1496 - * complete successfully. Either it failed or the URB was 1497 - * unlinked first. Regardless, don't confuse people with a 1498 - * negative length. */ 1499 - urb->actual_length = max(urb->actual_length, 0); 1497 + /* Subtract off the length of the SETUP packet from 1498 + * urb->actual_length. 1499 + */ 1500 + urb->actual_length -= min_t(u32, 8, urb->actual_length); 1500 1501 } 1501 1502 1502 1503 /* When giving back the first URB in an Isochronous queue,