summaryrefslogtreecommitdiffstats
path: root/sys/dev/mii/tdkphy.c
diff options
context:
space:
mode:
authorjlemon <jlemon@FreeBSD.org>2001-09-29 19:18:52 +0000
committerjlemon <jlemon@FreeBSD.org>2001-09-29 19:18:52 +0000
commit6689cad44720247770c3439271c41126ceb5476e (patch)
treee747bfa7e8d363f3c895759cfbfa10fc7ec0841e /sys/dev/mii/tdkphy.c
parent8bad7ad549c81c7741eb484b254cbe6200cba4c3 (diff)
downloadFreeBSD-src-6689cad44720247770c3439271c41126ceb5476e.zip
FreeBSD-src-6689cad44720247770c3439271c41126ceb5476e.tar.gz
Cleanup pass for mii drivers.
. Make internal service routines static. . Use a consistent ordering of checks in MII_TICK. Do the work in the mii_phy_tick() subroutine if appropriate. . Call mii_phy_update() to trigger the callbacks.
Diffstat (limited to 'sys/dev/mii/tdkphy.c')
-rw-r--r--sys/dev/mii/tdkphy.c43
1 files changed, 5 insertions, 38 deletions
diff --git a/sys/dev/mii/tdkphy.c b/sys/dev/mii/tdkphy.c
index 4c3d6f8..759f0e7 100644
--- a/sys/dev/mii/tdkphy.c
+++ b/sys/dev/mii/tdkphy.c
@@ -175,7 +175,7 @@ static int tdkphy_detach(device_t dev)
return(0);
}
-int
+static int
tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
{
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
@@ -237,38 +237,7 @@ tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
*/
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
return (0);
-
- /*
- * Only used for autonegotiation.
- */
- if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
- return (0);
-
- /*
- * Is the interface even up?
- */
- if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
- return (0);
-
- /*
- * Check to see if we have link. If we do, we don't
- * need to restart the autonegotiation process. Read
- * the BMSR twice in case it's latched.
- */
- reg = PHY_READ(sc, MII_BMSR) |
- PHY_READ(sc, MII_BMSR);
- if (reg & BMSR_LINK)
- return (0);
-
- /*
- * Only retry autonegotiation every 5 seconds.
- */
- if (++sc->mii_ticks != 5)
- return (0);
-
- sc->mii_ticks = 0;
- mii_phy_reset(sc);
- if (mii_phy_auto(sc, 0) == EJUSTRETURN)
+ if (mii_phy_tick(sc) == EJUSTRETURN)
return (0);
break;
}
@@ -279,15 +248,13 @@ tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
PHY_WRITE(sc, MII_BMCR, PHY_READ(sc, MII_BMCR) | BMCR_FDX);
else
PHY_WRITE(sc, MII_BMCR, PHY_READ(sc, MII_BMCR) & ~BMCR_FDX);
+
/* Callback if something changed. */
- if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
- MIIBUS_STATCHG(sc->mii_dev);
- sc->mii_active = mii->mii_media_active;
- }
+ mii_phy_update(sc, cmd);
return (0);
}
-void
+static void
tdkphy_status(struct mii_softc *phy)
{
struct mii_data *mii = phy->mii_pdata;
OpenPOWER on IntegriCloud