Index: freebsd-mos-driver/if_mos.c
===================================================================
--- freebsd-mos-driver/if_mos.c	(revision 177)
+++ freebsd-mos-driver/if_mos.c	(revision 199)
@@ -367,5 +367,4 @@
 
 	if (err) {
-		DPRINTF("mos_readmac error");
 		return (-1);
 	}
@@ -424,5 +423,4 @@
 	uWord			val;
 	int			i,res, locked;
-	DPRINTF("%s enter\n", __func__);
 
 	USETW(val, 0);
@@ -720,10 +718,8 @@
 
 
-	DPRINTF("%s:", "mos");
-
 	if (sc->mos_flags & MCS7730) {
-		DPRINTF(" MCS7730");
+		DPRINTF("model: MCS7730\n");
 	} else if (sc->mos_flags & MCS7830) {
-		DPRINTF(" MCS7830");
+		DPRINTF("model: MCS7830\n");
 	}
 
@@ -791,5 +787,4 @@
 	u_int16_t		pktlen = 0;
 	struct mbuf		*stat;
-	uint8_t status;
 	struct usb_page_cache *pc;
 
@@ -799,58 +794,62 @@
 	pc = usbd_xfer_get_frame(xfer, 0);
 
-	status = USB_GET_STATE(xfer);
-	if (status != USB_ST_SETUP) {
-		if (status == USB_ST_TRANSFERRED) {
-			if (actlen <= 1)
-				goto done;
-
-			usbd_copy_out(pc, actlen - sizeof(stat), &stat,
-			    sizeof(stat));
-
-			/* evaluate status byte at the end */
-			pktlen = actlen - 1;
-			//rxstat = stat[pktlen] & MOS_RXSTS_MASK;
-			m_freem(stat);
-
-			if (rxstat != MOS_RXSTS_VALID) {
-				DPRINTF("%s: erroneous frame received: ", 
-				    "mos");
-				if (rxstat & MOS_RXSTS_SHORT_FRAME)
-					DPRINTF("frame size less than 64 bytes\n");
-				if (rxstat & MOS_RXSTS_LARGE_FRAME)
-					DPRINTF("frame size larger than 1532 bytes\n");
-				if (rxstat & MOS_RXSTS_CRC_ERROR)
-					DPRINTF("CRC error\n");
-				if (rxstat & MOS_RXSTS_ALIGN_ERROR)
-					DPRINTF("alignment error\n");
-				ifp->if_ierrors++;
-				goto done;
-			}
-
-			if ( pktlen < sizeof(struct ether_header) ) {
-				ifp->if_ierrors++;
-				goto done;
-			}
-
-			uether_rxbuf(ue, pc, 0, actlen);
-
-		} else { 
-			DPRINTF("bulk read error, %s\n", usbd_errstr(error));
-			if (error == USB_ERR_CANCELLED) {
-				return;
-			} else {
-				/* try to clear stall first */
-				usbd_xfer_set_stall(xfer);
-				goto done;
-			}
+	switch (USB_GET_STATE(xfer)) {
+	case USB_ST_TRANSFERRED:
+		DPRINTF("read_callback actlen : %d\n", actlen);
+		if (actlen <= 1)
+ 			ifp->if_ierrors++;
+			goto tr_setup;
+
+		usbd_copy_out(pc, actlen - sizeof(stat), &stat,
+		    sizeof(stat));
+
+		/* evaluate status byte at the end */
+		pktlen = actlen - 1;
+		//rxstat = stat[pktlen] & MOS_RXSTS_MASK;
+		if (stat != NULL) {
+		  m_freem(stat);
+		} else {
+		  DPRINTF("Potential NULL error\n");
 		}
-	}
-done:
-	usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
-	usbd_transfer_submit(xfer);
-	uether_rxflush(ue);
-	DPRINTF("%s: %s: start rx\n", "mos", __func__);
-
-	return;
+
+		if (rxstat != MOS_RXSTS_VALID) {
+			DPRINTF("%s: erroneous frame received: ", 
+			    "mos");
+			if (rxstat & MOS_RXSTS_SHORT_FRAME)
+				DPRINTF("frame size less than 64 bytes\n");
+			if (rxstat & MOS_RXSTS_LARGE_FRAME)
+				DPRINTF("frame size larger than 1532 bytes\n");
+			if (rxstat & MOS_RXSTS_CRC_ERROR)
+				DPRINTF("CRC error\n");
+			if (rxstat & MOS_RXSTS_ALIGN_ERROR)
+				DPRINTF("alignment error\n");
+			ifp->if_ierrors++;
+			goto tr_setup;
+		}
+
+		if ( pktlen < sizeof(struct ether_header) ) {
+			ifp->if_ierrors++;
+			goto tr_setup;
+		}
+
+		uether_rxbuf(ue, pc, 0, actlen);
+
+  /* FALLTHROUGH */
+	case USB_ST_SETUP:
+tr_setup:
+		usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
+		usbd_transfer_submit(xfer);
+		uether_rxflush(ue);
+		return;
+	default: /* Error */
+		DPRINTF("bulk read error, %s\n", usbd_errstr(error));
+		if (error != USB_ERR_CANCELLED) {
+			/* try to clear stall first */
+			usbd_xfer_set_stall(xfer);
+			goto tr_setup;
+		}
+		DPRINTF("start rx %i\n", usbd_xfer_max_len(xfer));
+		return;
+	}
 }
 
@@ -867,43 +866,49 @@
 	struct usb_page_cache *pc;
 	struct mbuf *m;
-	uint8_t status;
 	int actlen;
+
+	DPRINTF("%s: %s: enter\n", "mos",__func__);
 
 	usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
 	pc = usbd_xfer_get_frame(xfer, 0);
 
-	status = USB_GET_STATE(xfer);
-
-	if (status != USB_ST_SETUP) {
-		if (status == USB_ST_TRANSFERRED) {
-			DPRINTF("transfer of %d bytes complete\n", actlen);
-			ifp->if_opackets++;
-		} else {
-			DPRINTF("%s: usb error on tx: %s\n", "mos", usbd_errstr(status));
+	switch (USB_GET_STATE(xfer)) {
+	case USB_ST_TRANSFERRED:
+		DPRINTF("transfer of %d bytes complete\n", actlen);
+		ifp->if_opackets++;
+		/* FALLTHROUGH */
+	case USB_ST_SETUP:
+tr_setup:
+		/*
+		 * XXX: don't send anything if there is no link?
+		 */
+		IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
+
+		usbd_xfer_set_frame_len(xfer, 0, m->m_pkthdr.len);
+
+		usbd_m_copy_in(pc, 0, m, 0, m->m_pkthdr.len);
+
+		/*
+		 * if there's a BPF listener, bounce a copy
+		 * of this frame to him:
+		 */
+		BPF_MTAP(ifp, m);
+
+		m_freem(m);
+
+		usbd_transfer_submit(xfer);
+
+		ifp->if_opackets++;
+		return;
+  default: /* Error */
+			DPRINTF("%s: usb error on tx: %s\n", "mos", usbd_errstr(error));
 			ifp->if_oerrors++;
-			if (error == USB_ERR_CANCELLED) {
-				return;
+			if (error != USB_ERR_CANCELLED) {
+			  /* try to clear stall first */
+			  usbd_xfer_set_stall(xfer);
+			  goto tr_setup;
 			}
-		}
-	}
-
-	IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
-
-	usbd_xfer_set_frame_len(xfer, 0, m->m_pkthdr.len);
-
-	usbd_m_copy_in(pc, 0, m, 0, m->m_pkthdr.len);
-
-	/*
-	 * if there's a BPF listener, bounce a copy
-	 * of this frame to him:
-	 */
-	BPF_MTAP(ifp, m);
-
-	m_freem(m);
-
-	usbd_transfer_submit(xfer);
-
-	ifp->if_opackets++;
-	return;
+      return;
+	}
 }
 
@@ -1015,6 +1020,4 @@
 	mos_setmulti(ue);
 
-	usbd_xfer_set_stall(sc->sc_xfer[MOS_ENDPT_TX]);
-
 	ifp->if_flags |= IFF_DRV_RUNNING;
 	mos_start(ue);
