diff options
author | marius <marius@FreeBSD.org> | 2006-12-02 19:36:25 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2006-12-02 19:36:25 +0000 |
commit | e88fd11fa63919f0d0ba952544f8abe033024e9e (patch) | |
tree | 0a8173ea0887896b2cd6a3f0ad42c1684b04c2b4 | |
parent | c4618bacd39ad5ce8f2fb96309c79e7c9983bdb6 (diff) | |
download | FreeBSD-src-e88fd11fa63919f0d0ba952544f8abe033024e9e.zip FreeBSD-src-e88fd11fa63919f0d0ba952544f8abe033024e9e.tar.gz |
Some style changes to a couple of PHY drivers:
- Fix some whitespace nits.
- Fix some spelling in comments.
- Use MII_ANEGTICKS instead of 5.
- Don't define variables in nested scope.
- Remove superfluous returns at the end of void functions.
- Remove unused static global rgephy_mii_model.
- Remove dupe $Id$ in tdkphy(4).
- Sort brgphys table.
MFC after: 2 weeks
-rw-r--r-- | sys/dev/mii/brgphy.c | 52 | ||||
-rw-r--r-- | sys/dev/mii/ciphy.c | 10 | ||||
-rw-r--r-- | sys/dev/mii/mlphy.c | 18 | ||||
-rw-r--r-- | sys/dev/mii/rgephy.c | 27 | ||||
-rw-r--r-- | sys/dev/mii/tdkphy.c | 10 | ||||
-rw-r--r-- | sys/dev/mii/tlphy.c | 19 | ||||
-rw-r--r-- | sys/dev/mii/xmphy.c | 11 |
7 files changed, 53 insertions, 94 deletions
diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index 3a90aa0..b2826e1 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$"); #include <sys/socket.h> #include <sys/bus.h> - #include <net/if.h> #include <net/ethernet.h> #include <net/if_media.h> @@ -102,16 +101,16 @@ static const struct mii_phydesc brgphys[] = { MII_PHY_DESC(xxBROADCOM, BCM5400), MII_PHY_DESC(xxBROADCOM, BCM5401), MII_PHY_DESC(xxBROADCOM, BCM5411), - MII_PHY_DESC(xxBROADCOM, BCM5752), MII_PHY_DESC(xxBROADCOM, BCM5701), MII_PHY_DESC(xxBROADCOM, BCM5703), MII_PHY_DESC(xxBROADCOM, BCM5704), MII_PHY_DESC(xxBROADCOM, BCM5705), - MII_PHY_DESC(xxBROADCOM, BCM5750), - MII_PHY_DESC(xxBROADCOM, BCM5714), - MII_PHY_DESC(xxBROADCOM, BCM5780), MII_PHY_DESC(xxBROADCOM, BCM5706C), MII_PHY_DESC(xxBROADCOM, BCM5708C), + MII_PHY_DESC(xxBROADCOM, BCM5714), + MII_PHY_DESC(xxBROADCOM, BCM5750), + MII_PHY_DESC(xxBROADCOM, BCM5752), + MII_PHY_DESC(xxBROADCOM, BCM5780), MII_PHY_END }; @@ -160,7 +159,6 @@ brgphy_attach(device_t dev) brgphy_mii_model = MII_MODEL(ma->mii_id2); brgphy_reset(sc); - sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; sc->mii_capabilities &= ~BMSR_ANEG; device_printf(dev, " "); @@ -197,7 +195,7 @@ brgphy_attach(device_t dev) #undef PRINT MIIBUS_MEDIAINIT(sc->mii_dev); - return(0); + return (0); } static int @@ -266,7 +264,7 @@ setit: PHY_WRITE(sc, BRGPHY_MII_BMCR, speed); PHY_WRITE(sc, BRGPHY_MII_ANAR, BRGPHY_SEL_TYPE); - if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) + if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) break; PHY_WRITE(sc, BRGPHY_MII_1000CTL, gig); @@ -277,7 +275,7 @@ setit: break; /* - * When settning the link manually, one side must + * When setting the link manually, one side must * be the master and the other the slave. However * ifmedia doesn't give us a good way to specify * this, so we fake it by using one of the LINK @@ -334,9 +332,9 @@ setit: /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->mii_ticks <= 5) + if (++sc->mii_ticks <= MII_ANEGTICKS) break; - + sc->mii_ticks = 0; brgphy_mii_phy_auto(sc); break; @@ -350,7 +348,7 @@ setit: * the DSP on the Broadcom PHYs if the media changes. * */ - if (sc->mii_media_active != mii->mii_media_active || + if (sc->mii_media_active != mii->mii_media_active || sc->mii_media_status != mii->mii_media_status || cmd == MII_MEDIACHG) { switch (brgphy_mii_model) { @@ -424,11 +422,8 @@ brgphy_status(struct mii_softc *sc) } mii->mii_media_active = ife->ifm_media; - - return; } - static int brgphy_mii_phy_auto(struct mii_softc *mii) { @@ -454,13 +449,11 @@ brgphy_mii_phy_auto(struct mii_softc *mii) static void brgphy_loop(struct mii_softc *sc) { - u_int32_t bmsr; int i; PHY_WRITE(sc, BRGPHY_MII_BMCR, BRGPHY_BMCR_LOOP); for (i = 0; i < 15000; i++) { - bmsr = PHY_READ(sc, BRGPHY_MII_BMSR); - if (!(bmsr & BRGPHY_BMSR_LINK)) { + if (!(PHY_READ(sc, BRGPHY_MII_BMSR) & BRGPHY_BMSR_LINK)) { #if 0 device_printf(sc->mii_dev, "looped %d\n", i); #endif @@ -637,31 +630,30 @@ brgphy_reset(struct mii_softc *sc) /* Enable Link LED on Dell boxes */ if (bge_sc->bge_flags & BGE_FLAG_NO3LED) { - PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL, - PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL) - & ~BRGPHY_PHY_EXTCTL_3_LED); + PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL, + PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL) & + ~BRGPHY_PHY_EXTCTL_3_LED); } } else if (bce_sc) { - /* Set or clear jumbo frame settings in the PHY. */ if (ifp->if_mtu > ETHER_MAX_LEN) { PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x7); val = PHY_READ(sc, BRGPHY_MII_AUXCTL); - PHY_WRITE(sc, BRGPHY_MII_AUXCTL, - val | BRGPHY_AUXCTL_LONG_PKT); + PHY_WRITE(sc, BRGPHY_MII_AUXCTL, + val | BRGPHY_AUXCTL_LONG_PKT); val = PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL); - PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL, - val | BRGPHY_PHY_EXTCTL_HIGH_LA); + PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL, + val | BRGPHY_PHY_EXTCTL_HIGH_LA); } else { PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x7); val = PHY_READ(sc, BRGPHY_MII_AUXCTL); - PHY_WRITE(sc, BRGPHY_MII_AUXCTL, - val & ~(BRGPHY_AUXCTL_LONG_PKT | 0x7)); + PHY_WRITE(sc, BRGPHY_MII_AUXCTL, + val & ~(BRGPHY_AUXCTL_LONG_PKT | 0x7)); val = PHY_READ(sc, BRGPHY_MII_PHY_EXTCTL); - PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL, - val & ~BRGPHY_PHY_EXTCTL_HIGH_LA); + PHY_WRITE(sc, BRGPHY_MII_PHY_EXTCTL, + val & ~BRGPHY_PHY_EXTCTL_HIGH_LA); } /* Enable Ethernet@Wirespeed */ diff --git a/sys/dev/mii/ciphy.c b/sys/dev/mii/ciphy.c index ed601ad..07eb5e0 100644 --- a/sys/dev/mii/ciphy.c +++ b/sys/dev/mii/ciphy.c @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include <sys/socket.h> #include <sys/bus.h> - #include <net/if.h> #include <net/if_arp.h> #include <net/if_media.h> @@ -265,7 +264,7 @@ setit: /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->mii_ticks <= 5/*10*/) + if (++sc->mii_ticks <= MII_ANEGTICKS) break; sc->mii_ticks = 0; @@ -335,17 +334,14 @@ ciphy_status(struct mii_softc *sc) if (bmsr & CIPHY_AUXCSR_FDX) mii->mii_media_active |= IFM_FDX; - - return; } static void ciphy_reset(struct mii_softc *sc) { + mii_phy_reset(sc); DELAY(1000); - - return; } #define PHY_SETBIT(x, y, z) \ @@ -405,6 +401,4 @@ ciphy_fixup(struct mii_softc *sc) model); break; } - - return; } diff --git a/sys/dev/mii/mlphy.c b/sys/dev/mii/mlphy.c index 05269f6..d0a549c 100644 --- a/sys/dev/mii/mlphy.c +++ b/sys/dev/mii/mlphy.c @@ -174,7 +174,7 @@ mlphy_attach(dev) printf("\n"); #undef ADD MIIBUS_MEDIAINIT(sc->mii_dev); - return(0); + return (0); } static int @@ -184,12 +184,11 @@ mlphy_service(xsc, mii, cmd) int cmd; { struct ifmedia_entry *ife = mii->mii_media.ifm_cur; - int reg; struct mii_softc *other = NULL; struct mlphy_softc *msc = (struct mlphy_softc *)xsc; struct mii_softc *sc = (struct mii_softc *)&msc->ml_mii; device_t *devlist; - int devs, i; + int devs, i, other_inst, reg; /* * See if there's another PHY on this bus with us. @@ -244,7 +243,7 @@ mlphy_service(xsc, mii, cmd) } (void) mii_phy_auto(sc); msc->ml_linked = 0; - return(0); + return (0); case IFM_10_T: /* * For 10baseT modes, reset and program the @@ -337,9 +336,9 @@ mlphy_service(xsc, mii, cmd) /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->mii_ticks <= 5) + if (++sc->mii_ticks <= MII_ANEGTICKS) break; - + sc->mii_ticks = 0; msc->ml_linked = 0; mii->mii_media_active = IFM_NONE; @@ -350,13 +349,12 @@ mlphy_service(xsc, mii, cmd) PHY_WRITE(other, MII_BMCR, BMCR_ISO); } mii_phy_auto(sc); - return(0); + return (0); } /* Update the media status. */ if (msc->ml_state == ML_STATE_AUTO_OTHER) { - int other_inst; other_inst = other->mii_inst; other->mii_inst = sc->mii_inst; (void) (*other->mii_service)(other, mii, MII_POLLSTAT); @@ -385,8 +383,6 @@ mlphy_reset(sc) reg = PHY_READ(sc, MII_BMCR); reg &= ~BMCR_AUTOEN; PHY_WRITE(sc, MII_BMCR, reg); - - return; } /* @@ -431,6 +427,4 @@ mlphy_status(sc) mii_phy_reset(other); mii_phy_auto(other); } - - return; } diff --git a/sys/dev/mii/rgephy.c b/sys/dev/mii/rgephy.c index c5c35a1..58c11ab 100644 --- a/sys/dev/mii/rgephy.c +++ b/sys/dev/mii/rgephy.c @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include <sys/socket.h> #include <sys/bus.h> - #include <net/if.h> #include <net/if_arp.h> #include <net/if_media.h> @@ -88,7 +87,6 @@ static int rgephy_mii_phy_auto(struct mii_softc *); static void rgephy_reset(struct mii_softc *); static void rgephy_loop(struct mii_softc *); static void rgephy_load_dspcode(struct mii_softc *); -static int rgephy_mii_model; static const struct mii_phydesc rgephys[] = { MII_PHY_DESC(xxREALTEK, RTL8169S), @@ -134,8 +132,6 @@ rgephy_attach(device_t dev) BMCR_LOOP|BMCR_S100); #endif - rgephy_mii_model = MII_MODEL(ma->mii_id2); - sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; sc->mii_capabilities &= ~BMSR_ANEG; @@ -155,7 +151,7 @@ rgephy_attach(device_t dev) rgephy_reset(sc); MIIBUS_MEDIAINIT(sc->mii_dev); - return(0); + return (0); } static int @@ -238,7 +234,7 @@ setit: } /* - * When settning the link manually, one side must + * When setting the link manually, one side must * be the master and the other the slave. However * ifmedia doesn't give us a good way to specify * this, so we fake it by using one of the LINK @@ -297,9 +293,9 @@ setit: /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->mii_ticks <= 5/*10*/) + if (++sc->mii_ticks <= MII_ANEGTICKS) break; - + sc->mii_ticks = 0; rgephy_mii_phy_auto(sc); return (0); @@ -313,7 +309,7 @@ setit: * the DSP on the RealTek PHYs if the media changes. * */ - if (sc->mii_media_active != mii->mii_media_active || + if (sc->mii_media_active != mii->mii_media_active || sc->mii_media_status != mii->mii_media_status || cmd == MII_MEDIACHG) { rgephy_load_dspcode(sc); @@ -361,14 +357,12 @@ rgephy_status(struct mii_softc *sc) mii->mii_media_active |= IFM_NONE; if (bmsr & RL_GMEDIASTAT_FDX) mii->mii_media_active |= IFM_FDX; - - return; } - static int rgephy_mii_phy_auto(struct mii_softc *mii) { + rgephy_loop(mii); rgephy_reset(mii); @@ -388,15 +382,13 @@ rgephy_mii_phy_auto(struct mii_softc *mii) static void rgephy_loop(struct mii_softc *sc) { - u_int32_t bmsr; int i; PHY_WRITE(sc, RGEPHY_MII_BMCR, RGEPHY_BMCR_PDOWN); DELAY(1000); for (i = 0; i < 15000; i++) { - bmsr = PHY_READ(sc, RGEPHY_MII_BMSR); - if (!(bmsr & RGEPHY_BMSR_LINK)) { + if (!(PHY_READ(sc, RGEPHY_MII_BMSR) & RGEPHY_BMSR_LINK)) { #if 0 device_printf(sc->mii_dev, "looped %d\n", i); #endif @@ -468,16 +460,15 @@ rgephy_load_dspcode(struct mii_softc *sc) PHY_SETBIT(sc, 4, 0x0800); PHY_CLRBIT(sc, 4, 0x0800); PHY_WRITE(sc, 31, 0x0000); - + DELAY(40); } static void rgephy_reset(struct mii_softc *sc) { + mii_phy_reset(sc); DELAY(1000); rgephy_load_dspcode(sc); - - return; } diff --git a/sys/dev/mii/tdkphy.c b/sys/dev/mii/tdkphy.c index 2e89c2d..66fc739 100644 --- a/sys/dev/mii/tdkphy.c +++ b/sys/dev/mii/tdkphy.c @@ -62,13 +62,6 @@ __FBSDID("$FreeBSD$"); #include "miibus_if.h" -#if 0 -#if !defined(lint) -static const char rcsid[] = - "$Id: tdkphy.c,v 1.18 2006/05/16 14:36:28 phk Exp $"; -#endif -#endif - static int tdkphy_probe(device_t); static int tdkphy_attach(device_t); @@ -151,8 +144,7 @@ tdkphy_attach(device_t dev) #undef ADD MIIBUS_MEDIAINIT(sc->mii_dev); - - return(0); + return (0); } static int diff --git a/sys/dev/mii/tlphy.c b/sys/dev/mii/tlphy.c index 7543d6c..d21fe7f 100644 --- a/sys/dev/mii/tlphy.c +++ b/sys/dev/mii/tlphy.c @@ -142,11 +142,13 @@ tlphy_probe(device_t dev) static int tlphy_attach(device_t dev) { + device_t *devlist; struct tlphy_softc *sc; + struct mii_softc *other; struct mii_attach_args *ma; struct mii_data *mii; const char *sep = ""; - int capmask = 0xFFFFFFFF; + int capmask, devs, i; sc = device_get_softc(dev); ma = device_get_ivars(dev); @@ -159,11 +161,8 @@ tlphy_attach(device_t dev) sc->sc_mii.mii_service = tlphy_service; sc->sc_mii.mii_pdata = mii; + capmask = 0xFFFFFFFF; if (mii->mii_instance) { - struct mii_softc *other; - device_t *devlist; - int devs, i; - device_get_children(sc->sc_mii.mii_dev, &devlist, &devs); for (i = 0; i < devs; i++) { if (strcmp(device_get_name(devlist[i]), "tlphy")) { @@ -216,7 +215,7 @@ tlphy_attach(device_t dev) #undef ADD #undef PRINT MIIBUS_MEDIAINIT(sc->sc_mii.mii_dev); - return(0); + return (0); } static int @@ -248,7 +247,7 @@ tlphy_service(struct mii_softc *self, struct mii_data *mii, int cmd) PHY_WRITE(&sc->sc_mii, MII_BMCR, reg | BMCR_ISO); return (0); } - + /* * If the interface is not up, don't do anything. */ @@ -313,7 +312,7 @@ tlphy_service(struct mii_softc *self, struct mii_data *mii, int cmd) /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->sc_mii.mii_ticks <= 5) + if (++sc->sc_mii.mii_ticks <= MII_ANEGTICKS) break; sc->sc_mii.mii_ticks = 0; @@ -342,7 +341,7 @@ tlphy_status(struct tlphy_softc *sc) bmcr = PHY_READ(&sc->sc_mii, MII_BMCR); if (bmcr & BMCR_ISO) { mii->mii_media_active |= IFM_NONE; - mii->mii_media_status = 0; + mii->mii_media_status = 0; return; } @@ -355,7 +354,7 @@ tlphy_status(struct tlphy_softc *sc) bmsr = PHY_READ(&sc->sc_mii, MII_BMSR) | PHY_READ(&sc->sc_mii, MII_BMSR); - if (bmsr & BMSR_LINK) + if (bmsr & BMSR_LINK) mii->mii_media_status |= IFM_ACTIVE; if (bmcr & BMCR_LOOP) diff --git a/sys/dev/mii/xmphy.c b/sys/dev/mii/xmphy.c index b7f5ae9..7beaae7 100644 --- a/sys/dev/mii/xmphy.c +++ b/sys/dev/mii/xmphy.c @@ -144,7 +144,7 @@ xmphy_attach(device_t dev) #undef PRINT MIIBUS_MEDIAINIT(sc->mii_dev); - return(0); + return (0); } static int @@ -239,14 +239,14 @@ xmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) /* * Only retry autonegotiation every 5 seconds. */ - if (++sc->mii_ticks <= 5) + if (++sc->mii_ticks <= MII_ANEGTICKS) break; - + sc->mii_ticks = 0; mii_phy_reset(sc); xmphy_mii_phy_auto(sc); - return(0); + return (0); } /* Update the media status. */ @@ -306,11 +306,8 @@ xmphy_status(struct mii_softc *sc) mii->mii_media_active |= IFM_FDX; else mii->mii_media_active |= IFM_HDX; - - return; } - static int xmphy_mii_phy_auto(struct mii_softc *mii) { |