Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Jan 2008 19:45:03 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 133581 for review
Message-ID:  <200801181945.m0IJj39c052842@repoman.freebsd.org>

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

Change 133581 by hselasky@hselasky_laptop001 on 2008/01/18 19:44:16

	
	Factor out some code into a separate function in an attempt to avoid
	compiler warnings about variables being accessed uninitialized on
	FreeBSD 6.3 .

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#106 edit

Differences ...

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

@@ -2080,6 +2080,38 @@
 	return;
 }
 
+static void
+usbd_callback_intr_td_sub(struct usbd_xfer **xfer, uint8_t dropcount)
+{
+	struct usbd_memory_info *info = xfer[0]->usb_root;
+
+	mtx_unlock(info->usb_mtx);
+
+	/*
+	 * We exploit the fact that the mutex is the same for
+	 * all callbacks:
+	 */
+	mtx_lock(info->priv_mtx);
+
+	/* call callback(s) */
+	switch (dropcount) {
+	case 4:
+		usbd_callback_wrapper(xfer[3], info, USBD_CONTEXT_CALLBACK);
+	case 3:
+		usbd_callback_wrapper(xfer[2], info, USBD_CONTEXT_CALLBACK);
+	case 2:
+		usbd_callback_wrapper(xfer[1], info, USBD_CONTEXT_CALLBACK);
+	case 1:
+		usbd_callback_wrapper(xfer[0], info, USBD_CONTEXT_CALLBACK);
+	default:
+		break;
+	}
+	mtx_unlock(info->priv_mtx);
+	mtx_lock(info->usb_mtx);
+	info->memory_refcount -= dropcount;
+	return;
+}
+
 /*------------------------------------------------------------------------*
  *	usbd_callback_intr_td
  *
@@ -2093,7 +2125,6 @@
 	struct usbd_memory_info *info = arg;
 	struct usbd_xfer *xfer[4];
 	struct thread *td;
-	uint8_t dropcount;
 
 	/* adjust priority */
 	td = curthread;
@@ -2110,60 +2141,31 @@
 repeat:
 	xfer[0] = LIST_FIRST(&(info->done_head));
 	if (xfer[0]) {
-		do {
-			LIST_REMOVE(xfer[0], done_list);
-			xfer[0]->done_list.le_prev = NULL;
-			xfer[1] = LIST_FIRST(&(info->done_head));
-			if (xfer[1] == NULL) {
-				dropcount = 1;
-				break;
-			}
-			LIST_REMOVE(xfer[1], done_list);
-			xfer[1]->done_list.le_prev = NULL;
-			xfer[2] = LIST_FIRST(&(info->done_head));
-			if (xfer[2] == NULL) {
-				dropcount = 2;
-				break;
-			}
-			LIST_REMOVE(xfer[2], done_list);
-			xfer[2]->done_list.le_prev = NULL;
-			xfer[3] = LIST_FIRST(&(info->done_head));
-			if (xfer[3] == NULL) {
-				dropcount = 3;
-				break;
-			}
-			LIST_REMOVE(xfer[3], done_list);
-			xfer[3]->done_list.le_prev = NULL;
-			dropcount = 4;
-		} while (0);
-
-		mtx_unlock(info->usb_mtx);
-
-		/*
-		 * we exploit the fact that the mutex is the same for
-		 * all callbacks
-		 */
-		mtx_lock(info->priv_mtx);
-
-		/* call callback(s) */
-		switch (dropcount) {
-		case 4:
-			usbd_callback_wrapper(xfer[3], info, USBD_CONTEXT_CALLBACK);
-		case 3:
-			usbd_callback_wrapper(xfer[2], info, USBD_CONTEXT_CALLBACK);
-		case 2:
-			usbd_callback_wrapper(xfer[1], info, USBD_CONTEXT_CALLBACK);
-		case 1:
-			usbd_callback_wrapper(xfer[0], info, USBD_CONTEXT_CALLBACK);
-		default:
-			break;
+		LIST_REMOVE(xfer[0], done_list);
+		xfer[0]->done_list.le_prev = NULL;
+		xfer[1] = LIST_FIRST(&(info->done_head));
+		if (xfer[1] == NULL) {
+			usbd_callback_intr_td_sub(xfer, 1);
+			goto repeat;
+		}
+		LIST_REMOVE(xfer[1], done_list);
+		xfer[1]->done_list.le_prev = NULL;
+		xfer[2] = LIST_FIRST(&(info->done_head));
+		if (xfer[2] == NULL) {
+			usbd_callback_intr_td_sub(xfer, 2);
+			goto repeat;
+		}
+		LIST_REMOVE(xfer[2], done_list);
+		xfer[2]->done_list.le_prev = NULL;
+		xfer[3] = LIST_FIRST(&(info->done_head));
+		if (xfer[3] == NULL) {
+			usbd_callback_intr_td_sub(xfer, 3);
+			goto repeat;
 		}
-		mtx_unlock(info->priv_mtx);
-
-		mtx_lock(info->usb_mtx);
-		info->memory_refcount -= dropcount;
+		LIST_REMOVE(xfer[3], done_list);
+		xfer[3]->done_list.le_prev = NULL;
+		usbd_callback_intr_td_sub(xfer, 4);
 		goto repeat;
-
 	} else {
 		if (info->memory_refcount != 0) {
 			info->done_sleep = 1;



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