svn commit: r213524 - user/weongyo/usb/sys/dev/usb

Weongyo Jeong weongyo at FreeBSD.org
Thu Oct 7 17:35:10 UTC 2010


Author: weongyo
Date: Thu Oct  7 17:35:10 2010
New Revision: 213524
URL: http://svn.freebsd.org/changeset/base/213524

Log:
  Removes recurse_1 and recurse_2 variables of `struct usb_xfer_queue'
  that it's replaced as `status'.

Modified:
  user/weongyo/usb/sys/dev/usb/usb_transfer.c
  user/weongyo/usb/sys/dev/usb/usbdi.h

Modified: user/weongyo/usb/sys/dev/usb/usb_transfer.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/usb_transfer.c	Thu Oct  7 17:26:22 2010	(r213523)
+++ user/weongyo/usb/sys/dev/usb/usb_transfer.c	Thu Oct  7 17:35:10 2010	(r213524)
@@ -1964,18 +1964,15 @@ usbd_callback_ss_done_defer(struct usb_x
 
 	if (pq->curr != xfer)
 		usbd_transfer_enqueue(pq, xfer);
-	if (!pq->recurse_1) {
+	if ((pq->status & USB_XFER_QUEUE_HOLD) == 0) {
 		/*
 		 * We have to postpone the callback due to the fact we
 		 * will have a Lock Order Reversal, LOR, if we try to
 		 * proceed !
 		 */
 		taskqueue_enqueue(info->done_tq, &info->done_task);
-	} else {
-		/* clear second recurse flag */
-		pq->recurse_2 = 0;
-	}
-	return;
+	} else
+		pq->status |= USB_XFER_QUEUE_CONTINUE;
 }
 
 /*------------------------------------------------------------------------*
@@ -2653,11 +2650,10 @@ usb_command_wrapper(struct usb_xfer_queu
 		pq->curr = NULL;
 	}
 
-	if (!pq->recurse_1) {
+	if ((pq->status & USB_XFER_QUEUE_HOLD) == 0) {
 		do {
-			/* set both recurse flags */
-			pq->recurse_1 = 1;
-			pq->recurse_2 = 1;
+			pq->status |= USB_XFER_QUEUE_HOLD;
+			pq->status &= ~USB_XFER_QUEUE_CONTINUE;
 
 			if (pq->curr == NULL) {
 				xfer = TAILQ_FIRST(&pq->head);
@@ -2672,14 +2668,11 @@ usb_command_wrapper(struct usb_xfer_queu
 			DPRINTFN(6, "cb %p (enter)\n", pq->curr);
 			(pq->command) (pq);
 			DPRINTFN(6, "cb %p (leave)\n", pq->curr);
-		} while (!pq->recurse_2);
+		} while ((pq->status & USB_XFER_QUEUE_CONTINUE) != 0);
 
-		/* clear first recurse flag */
-		pq->recurse_1 = 0;
-	} else {
-		/* clear second recurse flag */
-		pq->recurse_2 = 0;
-	}
+		pq->status &= ~USB_XFER_QUEUE_HOLD;
+	} else
+		pq->status |= USB_XFER_QUEUE_CONTINUE;
 }
 
 /*------------------------------------------------------------------------*

Modified: user/weongyo/usb/sys/dev/usb/usbdi.h
==============================================================================
--- user/weongyo/usb/sys/dev/usb/usbdi.h	Thu Oct  7 17:26:22 2010	(r213523)
+++ user/weongyo/usb/sys/dev/usb/usbdi.h	Thu Oct  7 17:35:10 2010	(r213524)
@@ -122,8 +122,16 @@ struct usb_xfer_queue {
 	TAILQ_HEAD(, usb_xfer) head;
 	struct usb_xfer *curr;		/* current USB transfer processed */
 	void    (*command) (struct usb_xfer_queue *pq);
-	uint8_t	recurse_1:1;
-	uint8_t	recurse_2:1;
+	int status;
+/*
+ * During this status is set any `info->done_task' wouldn't queued and
+ * `command' callback at above wouldn't called.  It's to avoid recursive calls.
+ *
+ * XXX need another approach to make easy to understand?
+ */
+#define	USB_XFER_QUEUE_HOLD	(1 << 0)
+/* If set, processing the xfer queue would be continue. */
+#define	USB_XFER_QUEUE_CONTINUE	(1 << 1)
 };
 
 /*


More information about the svn-src-user mailing list