diff --git a/sys/dev/mii/atphy.c b/sys/dev/mii/atphy.c index 07847bea4598..6e261a52fb8c 100644 --- a/sys/dev/mii/atphy.c +++ b/sys/dev/mii/atphy.c @@ -187,9 +187,9 @@ atphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) } anar = atphy_anar(ife); - if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) { + if ((ife->ifm_media & IFM_FDX) != 0) { bmcr |= BMCR_FDX; - if (((ife->ifm_media & IFM_GMASK) & IFM_FLOW) != 0 || + if ((ife->ifm_media & IFM_FLOW) != 0 || (sc->mii_flags & MIIF_FORCEPAUSE) != 0) anar |= ANAR_PAUSE_TOWARDS; } @@ -371,7 +371,7 @@ atphy_anar(struct ifmedia_entry *ife) return (0); } - if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) { + if ((ife->ifm_media & IFM_FDX) != 0) { if (IFM_SUBTYPE(ife->ifm_media) == IFM_100_TX) anar |= ANAR_TX_FD; else @@ -387,13 +387,13 @@ atphy_setmedia(struct mii_softc *sc, int media) uint16_t anar; anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA; - if (((IFM_SUBTYPE(media) == IFM_AUTO || - ((media & IFM_GMASK) & IFM_FDX) != 0) && - ((media & IFM_GMASK) & IFM_FLOW) != 0) || - (sc->mii_flags & MIIF_FORCEPAUSE) != 0) + if ((IFM_SUBTYPE(media) == IFM_AUTO || (media & IFM_FDX) != 0) && + ((media & IFM_FLOW) != 0 || + (sc->mii_flags & MIIF_FORCEPAUSE) != 0)) anar |= ANAR_PAUSE_TOWARDS; PHY_WRITE(sc, MII_ANAR, anar); - if ((sc->mii_extcapabilities & (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0) + if ((sc->mii_extcapabilities & + (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0) PHY_WRITE(sc, MII_100T2CR, GTCR_ADV_1000TFDX | GTCR_ADV_1000THDX); PHY_WRITE(sc, MII_BMCR, BMCR_RESET | BMCR_AUTOEN | BMCR_STARTNEG); diff --git a/sys/dev/mii/e1000phy.c b/sys/dev/mii/e1000phy.c index 45fd4d033e80..bd54a1118dc4 100644 --- a/sys/dev/mii/e1000phy.c +++ b/sys/dev/mii/e1000phy.c @@ -358,7 +358,7 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) return (EINVAL); } - if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) { + if ((ife->ifm_media & IFM_FDX) != 0) { speed |= E1000_CR_FULL_DUPLEX; gig = E1000_1GCR_1000T_FD; } else @@ -372,10 +372,10 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) gig |= E1000_1GCR_MS_ENABLE; if ((ife->ifm_media & IFM_ETH_MASTER) != 0) gig |= E1000_1GCR_MS_VALUE; - PHY_WRITE(sc, E1000_1GCR, gig); } else if ((sc->mii_extcapabilities & (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0) - PHY_WRITE(sc, E1000_1GCR, 0); + gig = 0; + PHY_WRITE(sc, E1000_1GCR, gig); PHY_WRITE(sc, E1000_AR, E1000_AR_SELECTOR_FIELD); PHY_WRITE(sc, E1000_CR, speed | E1000_CR_RESET); done: diff --git a/sys/dev/mii/ip1000phy.c b/sys/dev/mii/ip1000phy.c index 571575740060..d8a5242f0ca7 100644 --- a/sys/dev/mii/ip1000phy.c +++ b/sys/dev/mii/ip1000phy.c @@ -186,22 +186,21 @@ ip1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) return (EINVAL); } - if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) { + if ((ife->ifm_media & IFM_FDX) != 0) { speed |= IP1000PHY_BMCR_FDX; gig = IP1000PHY_1000CR_1000T_FDX; } else gig = IP1000PHY_1000CR_1000T; - PHY_WRITE(sc, IP1000PHY_MII_1000CR, 0); - PHY_WRITE(sc, IP1000PHY_MII_BMCR, speed); - - if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) - break; - - gig |= IP1000PHY_1000CR_MASTER | IP1000PHY_1000CR_MANUAL; - if ((ife->ifm_media & IFM_ETH_MASTER) != 0) - gig |= IP1000PHY_1000CR_MMASTER; + if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) { + gig |= + IP1000PHY_1000CR_MASTER | IP1000PHY_1000CR_MANUAL; + if ((ife->ifm_media & IFM_ETH_MASTER) != 0) + gig |= IP1000PHY_1000CR_MMASTER; + } else + gig = 0; PHY_WRITE(sc, IP1000PHY_MII_1000CR, gig); + PHY_WRITE(sc, IP1000PHY_MII_BMCR, speed); done: break;