PERFORCE change 126804 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Tue Sep 25 14:41:29 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=126804
Change 126804 by hselasky at hselasky_laptop001 on 2007/09/25 21:41:18
Print out USB transfer status information per "ehci_non_isoc_done_sub()"
call. Don't access index "xfer->nframes" of "xfer->frlengths[]". Add explicit
check for this.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/ehci.c#39 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/ehci.c#39 (text+ko) ====
@@ -1069,7 +1069,7 @@
return(last);
}
-static uint32_t
+static usbd_status
ehci_non_isoc_done_sub(struct usbd_xfer *xfer)
{
ehci_qtd_t *td;
@@ -1100,7 +1100,7 @@
DPRINTFN(0, ("Invalid status length, "
"0x%04x/0x%04x bytes\n", len, td->len));
status |= EHCI_QTD_HALTED;
- } else {
+ } else if (xfer->aframes != xfer->nframes) {
xfer->frlengths[xfer->aframes] -= len;
}
@@ -1155,7 +1155,24 @@
xfer->pipe->toggle_next = last_toggle;
- return status;
+#ifdef USB_DEBUG
+ if (status & EHCI_QTD_STATERRS) {
+ DPRINTFN(10, ("error, addr=%d, endpt=0x%02x, frame=0x%02x"
+ "status=%s%s%s%s%s%s%s%s\n",
+ xfer->address, xfer->endpoint, xfer->aframes,
+ (status & EHCI_QTD_ACTIVE) ? "[ACTIVE]" : "[NOT_ACTIVE]",
+ (status & EHCI_QTD_HALTED) ? "[HALTED]" : "",
+ (status & EHCI_QTD_BUFERR) ? "[BUFERR]" : "",
+ (status & EHCI_QTD_BABBLE) ? "[BABBLE]" : "",
+ (status & EHCI_QTD_XACTERR) ? "[XACTERR]" : "",
+ (status & EHCI_QTD_MISSEDMICRO) ? "[MISSED]" : "",
+ (status & EHCI_QTD_SPLITXSTATE) ? "[SPLIT]" : "",
+ (status & EHCI_QTD_PINGSTATE) ? "[PING]" : ""));
+ }
+#endif
+
+ return ((status & EHCI_QTD_HALTED) ?
+ USBD_STALLED : USBD_NORMAL_COMPLETION);
}
static void
@@ -1164,7 +1181,7 @@
static void
ehci_non_isoc_done(struct usbd_xfer *xfer)
{
- u_int32_t status = 0;
+ usbd_status err = 0;
DPRINTFN(12, ("xfer=%p pipe=%p transfer done\n",
xfer, xfer->pipe));
@@ -1182,7 +1199,7 @@
if (xfer->flags_int.control_xfr &&
xfer->flags_int.control_hdr) {
- status = ehci_non_isoc_done_sub(xfer);
+ err = ehci_non_isoc_done_sub(xfer);
xfer->aframes = 1;
@@ -1196,7 +1213,7 @@
if ((!xfer->flags_int.control_xfr) ||
(xfer->frlengths[xfer->aframes] > 0)) {
- status = ehci_non_isoc_done_sub(xfer);
+ err = ehci_non_isoc_done_sub(xfer);
}
xfer->aframes ++;
@@ -1209,37 +1226,21 @@
if (xfer->flags_int.control_xfr &&
!xfer->flags_int.control_act) {
- status = ehci_non_isoc_done_sub(xfer);
+ err = ehci_non_isoc_done_sub(xfer);
}
done:
-
-#ifdef USB_DEBUG
- if (status & EHCI_QTD_STATERRS) {
- DPRINTFN(10,
- ("error, addr=%d, endpt=0x%02x, "
- "status=%s%s%s%s%s%s%s%s\n",
- xfer->address,
- xfer->endpoint,
- (status & EHCI_QTD_ACTIVE) ? "ACTIVE" : "NOT_ACTIVE",
- (status & EHCI_QTD_HALTED) ? "-HALTED" : "",
- (status & EHCI_QTD_BUFERR) ? "-BUFERR" : "",
- (status & EHCI_QTD_BABBLE) ? "-BABBLE" : "",
- (status & EHCI_QTD_XACTERR) ? "-XACTERR" : "",
- (status & EHCI_QTD_MISSEDMICRO) ? "-MISSED" : "",
- (status & EHCI_QTD_SPLITXSTATE) ? "-SPLIT" : "",
- (status & EHCI_QTD_PINGSTATE) ? "-PING" : ""));
- }
-#endif
- ehci_device_done(xfer, (status & EHCI_QTD_HALTED) ?
- USBD_STALLED :
- USBD_NORMAL_COMPLETION);
+ ehci_device_done(xfer, err);
return;
}
-/* returns one when transfer is finished
- * and callback must be called else zero
- */
+/*------------------------------------------------------------------------*
+ * ehci_check_transfer
+ *
+ * Return values:
+ * 0: USB transfer is not finished
+ * Else: USB transfer is finished
+ *------------------------------------------------------------------------*/
static u_int8_t
ehci_check_transfer(struct usbd_xfer *xfer, struct thread *ctd)
{
More information about the p4-projects
mailing list