Simplify the ipgphy(4) attach routine a bit by making use of
mii_phy_add_media() to set the media types and adjust the
anegticks as appropriate.

>From FreeBSD

Tested by jasper@


Index: ipgphy.c
===================================================================
RCS file: /cvs/src/sys/dev/mii/ipgphy.c,v
retrieving revision 1.10
diff -u -p -r1.10 ipgphy.c
--- ipgphy.c    10 Jun 2008 21:18:41 -0000      1.10
+++ ipgphy.c    2 Jul 2009 02:44:35 -0000
@@ -111,30 +111,14 @@ ipgphy_attach(struct device *parent, str
        sc->mii_phy = ma->mii_phyno;
        sc->mii_funcs = &ipgphy_funcs;
        sc->mii_pdata = mii;
-       sc->mii_anegticks = MII_ANEGTICKS_GIGE;
 
        sc->mii_flags |= MIIF_NOISOLATE;
 
-#define ADD(m, c)      ifmedia_add(&mii->mii_media, (m), (c), NULL)
-
-       ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
-           BMCR_ISO);
-
-       ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst),
-           IPGPHY_BMCR_10);
-       ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_FDX, sc->mii_inst),
-           IPGPHY_BMCR_10 | IPGPHY_BMCR_FDX);
-       ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, 0, sc->mii_inst),
-           IPGPHY_BMCR_100);
-       ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_FDX, sc->mii_inst),
-           IPGPHY_BMCR_100 | IPGPHY_BMCR_FDX);
-       /* 1000baseT half-duplex, really supported? */
-       ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, 0, sc->mii_inst),
-           IPGPHY_BMCR_1000);
-       ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, IFM_FDX, sc->mii_inst),
-           IPGPHY_BMCR_1000 | IPGPHY_BMCR_FDX);
-       ADD(IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, sc->mii_inst), 0);
-#undef ADD
+       sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
+       if (sc->mii_capabilities & BMSR_EXTSTAT)
+               sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
+ 
+       mii_phy_add_media(sc);
 
        PHY_RESET(sc);
 }

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Reply via email to