Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Jun 2009 17:31:59 +0000 (UTC)
From:      Andrew Thompson <thompsa@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r193318 - head/sys/dev/usb
Message-ID:  <200906021731.n52HVx9K022334@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: thompsa
Date: Tue Jun  2 17:31:59 2009
New Revision: 193318
URL: http://svn.freebsd.org/changeset/base/193318

Log:
  Reorgansise the logic for tranversing the pipe list.
  
  Submitted by:	Hans Petter Selasky

Modified:
  head/sys/dev/usb/usb_request.c

Modified: head/sys/dev/usb/usb_request.c
==============================================================================
--- head/sys/dev/usb/usb_request.c	Tue Jun  2 17:31:16 2009	(r193317)
+++ head/sys/dev/usb/usb_request.c	Tue Jun  2 17:31:59 2009	(r193318)
@@ -109,11 +109,11 @@ usb2_do_clear_stall_callback(struct usb_
 	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 @@ usb2_do_clear_stall_callback(struct usb_
 
 	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 @@ tr_setup:
 			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?200906021731.n52HVx9K022334>