diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2005-06-19 19:30:15 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2005-06-19 19:30:15 +0000 |
commit | c852b2c50dabb159ccf9a6dec103e0f5798ecc0f (patch) | |
tree | 7a382f333cbeea94eefc9a1721b3f6de78feb25f | |
parent | 9dfb608c70ddcf83e073ac8297b39055ab310446 (diff) |
- some clean up
- for consistency fix order of operations for MII_TICK switch case in eephy
-rw-r--r-- | sys/dev/mii/eephy.c | 46 | ||||
-rw-r--r-- | sys/dev/mii/xmphy.c | 4 |
2 files changed, 21 insertions, 29 deletions
diff --git a/sys/dev/mii/eephy.c b/sys/dev/mii/eephy.c index ef59f2da4ed..5e4d888206b 100644 --- a/sys/dev/mii/eephy.c +++ b/sys/dev/mii/eephy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eephy.c,v 1.17 2005/03/26 04:40:09 krw Exp $ */ +/* $OpenBSD: eephy.c,v 1.18 2005/06/19 19:30:14 brad Exp $ */ /* * Principal Author: Parag Patel * Copyright (c) 2001 @@ -108,7 +108,7 @@ eephymatch(struct device *parent, void *match, void *aux) if (mii_phy_match(ma, eephys) != NULL) return (10); - return(0); + return (0); } void @@ -140,7 +140,6 @@ eephyattach(struct device *parent, struct device *self, void *aux) #define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) - if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) { ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, IFM_FDX, sc->mii_inst), E1000_CR_SPEED_1000 | E1000_CR_FULL_DUPLEX); @@ -238,9 +237,8 @@ eephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) /* * If the interface is not up, don't do anything. */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) { + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; - } switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: @@ -251,7 +249,7 @@ eephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) return (0); } PHY_RESET(sc); - (void)eephy_mii_phy_auto(sc, 1); + (void) eephy_mii_phy_auto(sc, 1); break; case IFM_1000_SX: @@ -269,7 +267,7 @@ eephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) PHY_RESET(sc); /* TODO - any other way to force 1000BT? */ - (void)eephy_mii_phy_auto(sc, 1); + (void) eephy_mii_phy_auto(sc, 1); break; case IFM_100_TX: @@ -309,31 +307,20 @@ eephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) /* * If we're not currently selected, just return. */ - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { - return (0); - } - - /* - * Only used for autonegotiation. - */ - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) { + if (IFM_INST(ife->ifm_media) != sc->mii_inst) return (0); - } /* * Is the interface even up? */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) { + if ((mii->mii_ifp->if_flags & IFF_UP) == 0) return (0); - } /* - * Only retry autonegotiation every mii_anegticks seconds. + * Only used for autonegotiation. */ - if (++sc->mii_ticks <= sc->mii_anegticks) { - return (0); - } - sc->mii_ticks = 0; + if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) + break; /* * Check to see if we have link. If we do, we don't @@ -341,15 +328,20 @@ eephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) * the BMSR twice in case it's latched. */ reg = PHY_READ(sc, E1000_SR) | PHY_READ(sc, E1000_SR); - if (reg & E1000_SR_LINK_STATUS) break; + /* + * Only retry autonegotiation every mii_anegticks seconds. + */ + if (++sc->mii_ticks <= sc->mii_anegticks) + break; + + sc->mii_ticks = 0; PHY_RESET(sc); - if (eephy_mii_phy_auto(sc, 0) == EJUSTRETURN) { - return(0); - } + if (eephy_mii_phy_auto(sc, 0) == EJUSTRETURN) + return (0); break; } diff --git a/sys/dev/mii/xmphy.c b/sys/dev/mii/xmphy.c index f90d0869bda..f28388265b1 100644 --- a/sys/dev/mii/xmphy.c +++ b/sys/dev/mii/xmphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xmphy.c,v 1.13 2005/06/19 17:08:14 brad Exp $ */ +/* $OpenBSD: xmphy.c,v 1.14 2005/06/19 19:30:14 brad Exp $ */ /* * Copyright (c) 2000 @@ -232,11 +232,11 @@ xmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) break; sc->mii_ticks = 0; - PHY_RESET(sc); if (xmphy_mii_phy_auto(sc, 0) == EJUSTRETURN) return (0); + break; } |