Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Sep 2008 18:44:28 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 149072 for review
Message-ID:  <200809021844.m82IiSis056933@repoman.freebsd.org>

index | next in thread | raw e-mail

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

Change 149072 by hselasky@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);
 


help

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