From 1ff33426c8353fab4b2fdae23f9e0766e55f1f0c Mon Sep 17 00:00:00 2001 From: Bill Paul Date: Wed, 1 Sep 1999 17:07:27 +0000 Subject: [PATCH] Re-arrange things in the attach routines of the 3Com and RealTek PHY drivers so that we don't clobber things or leave them uninitialized if we abort due a failure. Submitted by: Luoqi Chen --- sys/dev/mii/exphy.c | 14 +++++++------- sys/dev/mii/rlphy.c | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sys/dev/mii/exphy.c b/sys/dev/mii/exphy.c index ddf7d820661e..30b6b6310d50 100644 --- a/sys/dev/mii/exphy.c +++ b/sys/dev/mii/exphy.c @@ -89,7 +89,7 @@ #if !defined(lint) static const char rcsid[] = - "$Id: exphy.c,v 1.1 1999/08/21 17:40:41 wpaul Exp $"; + "$FreeBSD$"; #endif static int exphy_probe __P((device_t)); @@ -161,12 +161,6 @@ static int exphy_attach(dev) ma = device_get_ivars(dev); sc->mii_dev = device_get_parent(dev); mii = device_get_softc(sc->mii_dev); - LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); - - sc->mii_inst = mii->mii_instance; - sc->mii_phy = ma->mii_phyno; - sc->mii_service = exphy_service; - sc->mii_pdata = mii; /* * The 3Com PHY can never be isolated, so never allow non-zero @@ -177,6 +171,12 @@ static int exphy_attach(dev) return(ENXIO); } + LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); + + sc->mii_inst = mii->mii_instance; + sc->mii_phy = ma->mii_phyno; + sc->mii_service = exphy_service; + sc->mii_pdata = mii; mii->mii_instance++; sc->mii_flags |= MIIF_NOISOLATE; diff --git a/sys/dev/mii/rlphy.c b/sys/dev/mii/rlphy.c index 423159eaa575..956160d23516 100644 --- a/sys/dev/mii/rlphy.c +++ b/sys/dev/mii/rlphy.c @@ -121,12 +121,6 @@ static int rlphy_attach(dev) ma = device_get_ivars(dev); sc->mii_dev = device_get_parent(dev); mii = device_get_softc(sc->mii_dev); - LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); - - sc->mii_inst = mii->mii_instance; - sc->mii_phy = ma->mii_phyno; - sc->mii_service = rlphy_service; - sc->mii_pdata = mii; /* * The RealTek PHY can never be isolated, so never allow non-zero @@ -137,6 +131,12 @@ static int rlphy_attach(dev) return(ENXIO); } + LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); + + sc->mii_inst = mii->mii_instance; + sc->mii_phy = ma->mii_phyno; + sc->mii_service = rlphy_service; + sc->mii_pdata = mii; mii->mii_instance++; sc->mii_flags |= MIIF_NOISOLATE;