diff options
author | Marius Strobl <marius@FreeBSD.org> | 2010-10-02 18:53:12 +0000 |
---|---|---|
committer | Marius Strobl <marius@FreeBSD.org> | 2010-10-02 18:53:12 +0000 |
commit | de1add1e459b22ec054bac16dd34fe5dff0d6704 (patch) | |
tree | be43fedc87f2ffc4b3d13f6ff4002bb017799ac5 /sys/dev/mii/truephy.c | |
parent | a03e344a7fbc52b843ac362b6d1929bde4947a9a (diff) | |
download | src-de1add1e459b22ec054bac16dd34fe5dff0d6704.tar.gz src-de1add1e459b22ec054bac16dd34fe5dff0d6704.zip |
- In the spirit of previous simplifications factor out the checks for a
different PHY instance being selected and isolation out into the wrappers
around the service methods rather than duplicating them over and over
again (besides, a PHY driver shouldn't need to care about which instance
it actually is).
- Centralize the check for the need to isolate a non-zero PHY instance not
supporting isolation in mii_mediachg() and just ignore it rather than
panicing, which should sufficient given that a) things are likely to
just work anyway if one doesn't plug in more than one port at a time and
b) refusing to attach in this case just leaves us in a unknown but most
likely also not exactly correct configuration (besides several drivers
setting MIIF_NOISOLATE didn't care about these anyway, probably due to
setting this flag for no real reason).
- Minor fixes like removing unnecessary setting of sc->mii_anegticks,
using sc->mii_anegticks instead of hardcoded values etc.
Notes
Notes:
svn path=/head/; revision=213364
Diffstat (limited to 'sys/dev/mii/truephy.c')
-rw-r--r-- | sys/dev/mii/truephy.c | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/sys/dev/mii/truephy.c b/sys/dev/mii/truephy.c index 93ea449a350e..c83398383dd6 100644 --- a/sys/dev/mii/truephy.c +++ b/sys/dev/mii/truephy.c @@ -147,21 +147,17 @@ truephy_attach(device_t dev) ma = device_get_ivars(dev); sc->mii_phy = ma->mii_phyno; - if (sc->mii_anegticks == 0) - sc->mii_anegticks = MII_ANEGTICKS; sc->mii_dev = device_get_parent(dev); mii = ma->mii_data; LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); - sc->mii_inst = mii->mii_instance; + sc->mii_inst = mii->mii_instance++; sc->mii_phy = ma->mii_phyno; sc->mii_service = truephy_service; sc->mii_pdata = mii; sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP; - mii->mii_instance++; - if (MII_MODEL(ma->mii_id2) == MII_MODEL_AGERE_ET1011) mii_phy_reset(sc); else @@ -175,15 +171,11 @@ truephy_attach(device_t dev) } device_printf(dev, " "); - if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 && - (sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0) - printf("no media present"); - else - mii_phy_add_media(sc); + mii_phy_add_media(sc); printf("\n"); MIIBUS_MEDIAINIT(sc->mii_dev); - return 0; + return (0); } static int @@ -194,25 +186,10 @@ truephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) switch (cmd) { case MII_POLLSTAT: - /* - * If we're not polling our PHY instance, just return. - */ - if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return 0; break; case MII_MEDIACHG: /* - * If the media indicates a different PHY instance, - * isolate ourselves. - */ - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { - bmcr = PHY_READ(sc, MII_BMCR); - PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_ISO); - return 0; - } - - /* * If the interface is not up, don't do anything. */ if ((mii->mii_ifp->if_flags & IFF_UP) == 0) @@ -238,14 +215,8 @@ truephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) break; case MII_TICK: - /* - * If we're not currently selected, just return. - */ - if (IFM_INST(ife->ifm_media) != sc->mii_inst) - return 0; - if (mii_phy_tick(sc) == EJUSTRETURN) - return 0; + return (0); break; } @@ -254,7 +225,7 @@ truephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) /* Callback if something changed. */ mii_phy_update(sc, cmd); - return 0; + return (0); } static void |