svn commit: r214262 - head/sys/dev/mii

Marius Strobl marius at FreeBSD.org
Sun Oct 24 11:37:01 UTC 2010


Author: marius
Date: Sun Oct 24 11:37:01 2010
New Revision: 214262
URL: http://svn.freebsd.org/changeset/base/214262

Log:
  - Take advantage of mii_phy_dev_probe().
  - Use mii_phy_add_media() instead of mii_add_media(). I'm not sure how
    this driver actually managed to work before as mii_add_media() is
    intended to be used to gether with mii_anar() while mii_phy_add_media()
    is intended to be used with mii_phy_setmedia(), however this driver
    mii_add_media() along with mii_phy_setmedia().

Modified:
  head/sys/dev/mii/smcphy.c

Modified: head/sys/dev/mii/smcphy.c
==============================================================================
--- head/sys/dev/mii/smcphy.c	Sun Oct 24 09:14:21 2010	(r214261)
+++ head/sys/dev/mii/smcphy.c	Sun Oct 24 11:37:01 2010	(r214262)
@@ -76,20 +76,16 @@ static driver_t smcphy_driver = {
 
 DRIVER_MODULE(smcphy, miibus, smcphy_driver, smcphy_devclass, 0, 0);
 
+static const struct mii_phydesc smcphys[] = {
+	MII_PHY_DESC(SMSC, LAN83C183),
+	MII_PHY_END
+};
+
 static int
 smcphy_probe(device_t dev)
 {
-	struct	mii_attach_args *ma;
-
-	ma = device_get_ivars(dev);
 
-	if (MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_SMSC ||
-	    MII_MODEL(ma->mii_id2) != MII_MODEL_SMSC_LAN83C183)
-		return (ENXIO);
-
-	device_set_desc(dev, MII_STR_SMSC_LAN83C183);
-
-	return (0);
+	return (mii_phy_dev_probe(dev, smcphys, BUS_PROBE_DEFAULT));
 }
 
 static int
@@ -111,7 +107,7 @@ smcphy_attach(device_t dev)
 	sc->mii_service = smcphy_service;
 	sc->mii_pdata = mii;
 
-	sc->mii_flags |= MIIF_NOISOLATE;
+	sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
 
 	if (smcphy_reset(sc) != 0) {
 		device_printf(dev, "reset failed\n");
@@ -122,7 +118,7 @@ smcphy_attach(device_t dev)
 
 	sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
 	device_printf(dev, " ");
-	mii_add_media(sc);
+	mii_phy_add_media(sc);
 	printf("\n");
 
 	MIIBUS_MEDIAINIT(sc->mii_dev);


More information about the svn-src-all mailing list