Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 May 2009 12:10:52 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 162771 for review
Message-ID:  <200905261210.n4QCAq1F060121@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=162771

Change 162771 by hselasky@hselasky_laptop001 on 2009/05/26 12:10:17

	
	USB core: Improve clear stall logic.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb/usb_request.c#17 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb/usb_request.c#17 (text+ko) ====

@@ -109,11 +109,11 @@
 	pipe_end = udev->pipes + udev->pipes_max;
 	pipe_first = udev->pipes;
 	to = udev->pipes_max;
-	if (pipe == NULL) {
-		pipe = pipe_first;
-	}
+
 	switch (USB_GET_STATE(xfer)) {
 	case USB_ST_TRANSFERRED:
+		if (pipe == NULL)
+			goto tr_setup;		/* device was unconfigured */
 		if (pipe->edesc &&
 		    pipe->is_stalled) {
 			pipe->toggle_next = 0;
@@ -126,9 +126,10 @@
 
 	case USB_ST_SETUP:
 tr_setup:
-		if (pipe == pipe_end) {
-			pipe = pipe_first;
-		}
+		if (to == 0)
+			break;			/* no pipes - nothing to do */
+		if ((pipe < pipe_first) || (pipe >= pipe_end))
+			pipe = pipe_first;	/* pipe wrapped around */
 		if (pipe->edesc &&
 		    pipe->is_stalled) {
 
@@ -156,9 +157,8 @@
 			break;
 		}
 		pipe++;
-		if (--to)
-			goto tr_setup;
-		break;
+		to--;
+		goto tr_setup;
 
 	default:
 		if (xfer->error == USB_ERR_CANCELLED) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905261210.n4QCAq1F060121>