PERFORCE change 149072 for review

Hans Petter Selasky hselasky at FreeBSD.org
Tue Sep 2 18:44:29 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=149072

Change 149072 by hselasky at hselasky_laptop001 on 2008/09/02 18:43:52

	
	Fix two bugs.
	
	1) The system factored out clear-stall function
	   was not iterating the USB pipes correctly.
	
	2) When re-enumerating an USB device, the device
	   address must be restored a little bit earlier.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_request.c#14 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_request.c#14 (text+ko) ====

@@ -96,7 +96,7 @@
 	struct usb2_pipe *pipe;
 	struct usb2_pipe *pipe_end;
 	struct usb2_pipe *pipe_first;
-	struct usb2_pipe *pipe_start;
+	uint8_t to = USB_EP_MAX;
 
 	mtx_lock(xfer->usb2_mtx);
 
@@ -107,9 +107,6 @@
 	pipe_first = xfer->udev->pipes;
 	if (pipe == NULL) {
 		pipe = pipe_first;
-		pipe_start = pipe_first;
-	} else {
-		pipe_start = pipe;
 	}
 
 	switch (USB_GET_STATE(xfer)) {
@@ -126,14 +123,9 @@
 
 	case USB_ST_SETUP:
 tr_setup:
-		while (1) {
 			if (pipe == pipe_end) {
 				pipe = pipe_first;
 			}
-			if (pipe == pipe_start) {
-				/* nothing to do */
-				break;
-			}
 			if (pipe->edesc &&
 			    pipe->is_stalled) {
 
@@ -161,7 +153,8 @@
 				break;
 			}
 			pipe++;
-		}
+			if (--to) 
+				goto tr_setup;
 		break;
 
 	default:
@@ -1312,6 +1305,9 @@
 		    old_addr);
 		err = 0;
 	}
+	/* restore device address */
+	udev->address = old_addr;
+
 	/* allow device time to set new address */
 	usb2_pause_mtx(mtx, USB_SET_ADDRESS_SETTLE);
 


More information about the p4-projects mailing list