svn commit: r187978 - user/thompsa/usb/sys/dev/usb2/ethernet
Andrew Thompson
thompsa at FreeBSD.org
Sat Jan 31 22:50:37 PST 2009
Author: thompsa
Date: Sun Feb 1 06:50:37 2009
New Revision: 187978
URL: http://svn.freebsd.org/changeset/base/187978
Log:
Rearrange things slightly to reduce gotos.
Modified:
user/thompsa/usb/sys/dev/usb2/ethernet/if_aue2.c
user/thompsa/usb/sys/dev/usb2/ethernet/if_axe2.c
user/thompsa/usb/sys/dev/usb2/ethernet/if_cue2.c
user/thompsa/usb/sys/dev/usb2/ethernet/if_kue2.c
user/thompsa/usb/sys/dev/usb2/ethernet/if_udav2.c
Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_aue2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_aue2.c Sun Feb 1 06:39:40 2009 (r187977)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_aue2.c Sun Feb 1 06:50:37 2009 (r187978)
@@ -382,10 +382,6 @@ aue_miibus_readreg(device_t dev, int phy
int i, locked;
uint16_t val = 0;
- locked = mtx_owned(&sc->sc_mtx);
- if (!locked)
- AUE_LOCK(sc);
-
/*
* The Am79C901 HomePNA PHY actually contains two transceivers: a 1Mbps
* HomePNA PHY and a 10Mbps full/half duplex ethernet PHY with NWAY
@@ -393,14 +389,13 @@ aue_miibus_readreg(device_t dev, int phy
* actually connected to anything, so we ignore the 10Mbps one. It
* happens to be configured for MII address 3, so we filter that out.
*/
- if (sc->sc_flags & AUE_FLAG_DUAL_PHY) {
- if (phy == 3)
- goto done;
-#if 0
- if (phy != 1)
- goto done;
-#endif
- }
+ if (sc->sc_flags & AUE_FLAG_DUAL_PHY && phy == 3)
+ return (0);
+
+ locked = mtx_owned(&sc->sc_mtx);
+ if (!locked)
+ AUE_LOCK(sc);
+
aue_csr_write_1(sc, AUE_PHY_ADDR, phy);
aue_csr_write_1(sc, AUE_PHY_CTL, reg | AUE_PHYCTL_READ);
@@ -414,7 +409,6 @@ aue_miibus_readreg(device_t dev, int phy
val = aue_csr_read_2(sc, AUE_PHY_DATA);
-done:
if (!locked)
AUE_UNLOCK(sc);
return (val);
Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_axe2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_axe2.c Sun Feb 1 06:39:40 2009 (r187977)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_axe2.c Sun Feb 1 06:50:37 2009 (r187978)
@@ -726,7 +726,7 @@ axe_bulk_read_callback(struct usb2_xfer
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
pos = 0;
- while (1) {
+ for (;;) {
if (sc->sc_flags & (AXE_FLAG_772 | AXE_FLAG_178)) {
if (xfer->actlen < sizeof(hdr)) {
/* too little data */
@@ -736,6 +736,7 @@ axe_bulk_read_callback(struct usb2_xfer
if ((hdr.len ^ hdr.ilen) != 0xFFFF) {
/* we lost sync */
+ ifp->if_ierrors++;
break;
}
xfer->actlen -= sizeof(hdr);
@@ -744,6 +745,7 @@ axe_bulk_read_callback(struct usb2_xfer
len = le16toh(hdr.len);
if (len > xfer->actlen) {
/* invalid length */
+ ifp->if_ierrors++;
break;
}
adjust = (len & 1);
@@ -761,18 +763,13 @@ axe_bulk_read_callback(struct usb2_xfer
if (xfer->actlen <= adjust) {
/* we are finished */
- goto tr_setup;
+ break;
}
pos += adjust;
xfer->actlen -= adjust;
}
-
- /* count an error */
- ifp->if_ierrors++;
-
/* FALLTHROUGH */
case USB_ST_SETUP:
-tr_setup:
xfer->frlengths[0] = xfer->max_data_length;
usb2_start_hardware(xfer);
usb2_ether_rxflush(ue);
@@ -805,23 +802,17 @@ axe_bulk_write_callback(struct usb2_xfer
/* FALLTHROUGH */
case USB_ST_SETUP:
- if ((sc->sc_flags & AXE_FLAG_LINK) == 0) {
- /*
- * don't send anything if there is no link !
- */
- goto done;
- }
- pos = 0;
+ if ((sc->sc_flags & AXE_FLAG_LINK) == 0)
+ return;
+ pos = 0;
while (1) {
-
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
-
if (m == NULL) {
if (pos > 0)
break; /* send out data */
else
- goto done;
+ return;
}
if (m->m_pkthdr.len > MCLBYTES) {
m->m_pkthdr.len = MCLBYTES;
@@ -869,8 +860,6 @@ axe_bulk_write_callback(struct usb2_xfer
xfer->frlengths[0] = pos;
usb2_start_hardware(xfer);
-
-done:
break;
default: /* Error */
Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_cue2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_cue2.c Sun Feb 1 06:39:40 2009 (r187977)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_cue2.c Sun Feb 1 06:50:37 2009 (r187978)
@@ -435,17 +435,16 @@ cue_bulk_read_callback(struct usb2_xfer
if (xfer->actlen <= (2 + sizeof(struct ether_header))) {
ifp->if_ierrors++;
- goto tr_setup;
- }
- usb2_copy_out(xfer->frbuffers, 0, buf, 2);
- xfer->actlen -= 2;
- len = buf[0] | (buf[1] << 8);
- len = min(xfer->actlen, len);
+ } else {
+ usb2_copy_out(xfer->frbuffers, 0, buf, 2);
+ xfer->actlen -= 2;
+ len = buf[0] | (buf[1] << 8);
+ len = min(xfer->actlen, len);
- usb2_ether_rxbuf(ue, xfer, 2, len);
+ usb2_ether_rxbuf(ue, xfer, 2, len);
+ }
/* FALLTHROUGH */
case USB_ST_SETUP:
-tr_setup:
xfer->frlengths[0] = xfer->max_data_length;
usb2_start_hardware(xfer);
usb2_ether_rxflush(ue);
@@ -457,8 +456,7 @@ tr_setup:
usb2_clear_endpoint_stall(xfer);
return;
}
- DPRINTF("bulk read error, %s\n",
- usb2_errstr(xfer->error));
+ DPRINTF("bulk read error, %s\n", usb2_errstr(xfer->error));
break;
}
}
Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_kue2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_kue2.c Sun Feb 1 06:39:40 2009 (r187977)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_kue2.c Sun Feb 1 06:50:37 2009 (r187978)
@@ -513,18 +513,16 @@ kue_bulk_read_callback(struct usb2_xfer
if (xfer->actlen <= (2 + sizeof(struct ether_header))) {
ifp->if_ierrors++;
- goto tr_setup;
- }
- usb2_copy_out(xfer->frbuffers, 0, buf, 2);
- xfer->actlen -= 2;
- len = buf[0] | (buf[1] << 8);
- len = min(xfer->actlen, len);
+ } else {
+ usb2_copy_out(xfer->frbuffers, 0, buf, 2);
+ xfer->actlen -= 2;
+ len = buf[0] | (buf[1] << 8);
+ len = min(xfer->actlen, len);
- usb2_ether_rxbuf(ue, xfer, 2, len);
+ usb2_ether_rxbuf(ue, xfer, 2, len);
+ }
/* FALLTHROUGH */
case USB_ST_SETUP:
-tr_setup:
-
xfer->frlengths[0] = xfer->max_data_length;
usb2_start_hardware(xfer);
usb2_ether_rxflush(ue);
@@ -538,7 +536,6 @@ tr_setup:
}
DPRINTF("bulk read error, %s\n", usb2_errstr(xfer->error));
break;
-
}
}
Modified: user/thompsa/usb/sys/dev/usb2/ethernet/if_udav2.c
==============================================================================
--- user/thompsa/usb/sys/dev/usb2/ethernet/if_udav2.c Sun Feb 1 06:39:40 2009 (r187977)
+++ user/thompsa/usb/sys/dev/usb2/ethernet/if_udav2.c Sun Feb 1 06:50:37 2009 (r187978)
@@ -557,12 +557,9 @@ udav_bulk_write_callback(struct usb2_xfe
/* FALLTHROUGH */
case USB_ST_SETUP:
- if ((sc->sc_flags & UDAV_FLAG_LINK) == 0) {
- /*
- * don't send anything if there is no link !
- */
- goto done;
- }
+ if ((sc->sc_flags & UDAV_FLAG_LINK) == 0)
+ break;
+
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
if (m == NULL)
break;
@@ -605,7 +602,6 @@ udav_bulk_write_callback(struct usb2_xfe
xfer->frlengths[0] = temp_len;
usb2_start_hardware(xfer);
-done:
break;
default: /* Error */
More information about the svn-src-user
mailing list