Page MenuHomeFreeBSD

D47970.id148694.diff
No OneTemporary

D47970.id148694.diff

diff --git a/sys/dev/etherswitch/ar40xx/ar40xx_main.c b/sys/dev/etherswitch/ar40xx/ar40xx_main.c
--- a/sys/dev/etherswitch/ar40xx/ar40xx_main.c
+++ b/sys/dev/etherswitch/ar40xx/ar40xx_main.c
@@ -254,22 +254,23 @@
ar40xx_detach(device_t dev)
{
struct ar40xx_softc *sc = device_get_softc(dev);
- int i;
+ int error, i;
device_printf(sc->sc_dev, "%s: called\n", __func__);
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
+
callout_drain(&sc->sc_phy_callout);
/* Free PHYs */
for (i = 0; i < AR40XX_NUM_PHYS; i++) {
- if (sc->sc_phys.miibus[i] != NULL)
- device_delete_child(dev, sc->sc_phys.miibus[i]);
if (sc->sc_phys.ifp[i] != NULL)
if_free(sc->sc_phys.ifp[i]);
free(sc->sc_phys.ifname[i], M_DEVBUF);
}
- bus_generic_detach(dev);
mtx_destroy(&sc->sc_mtx);
return (0);
diff --git a/sys/dev/etherswitch/arswitch/arswitch.c b/sys/dev/etherswitch/arswitch/arswitch.c
--- a/sys/dev/etherswitch/arswitch/arswitch.c
+++ b/sys/dev/etherswitch/arswitch/arswitch.c
@@ -666,13 +666,15 @@
arswitch_detach(device_t dev)
{
struct arswitch_softc *sc = device_get_softc(dev);
- int i;
+ int error, i;
callout_drain(&sc->callout_tick);
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
+
for (i=0; i < sc->numphys; i++) {
- if (sc->miibus[i] != NULL)
- device_delete_child(dev, sc->miibus[i]);
if (sc->ifp[i] != NULL)
if_free(sc->ifp[i]);
free(sc->ifname[i], M_DEVBUF);
@@ -680,7 +682,6 @@
free(sc->atu.entries, M_DEVBUF);
- bus_generic_detach(dev);
mtx_destroy(&sc->sc_mtx);
return (0);
diff --git a/sys/dev/etherswitch/e6000sw/e6060sw.c b/sys/dev/etherswitch/e6000sw/e6060sw.c
--- a/sys/dev/etherswitch/e6000sw/e6060sw.c
+++ b/sys/dev/etherswitch/e6000sw/e6060sw.c
@@ -321,18 +321,20 @@
e6060sw_detach(device_t dev)
{
struct e6060sw_softc *sc;
- int i, port;
+ int error, i, port;
sc = device_get_softc(dev);
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
+
callout_drain(&sc->callout_tick);
for (i = 0; i < MII_NPHY; i++) {
if (((1 << i) & sc->phymask) == 0)
continue;
port = e6060sw_portforphy(sc, i);
- if (sc->miibus[port] != NULL)
- device_delete_child(dev, (*sc->miibus[port]));
if (sc->ifp[port] != NULL)
if_free(sc->ifp[port]);
free(sc->ifname[port], M_E6060SW);
@@ -344,7 +346,6 @@
free(sc->ifname, M_E6060SW);
free(sc->ifp, M_E6060SW);
- bus_generic_detach(dev);
mtx_destroy(&sc->sc_mtx);
return (0);
diff --git a/sys/dev/etherswitch/infineon/adm6996fc.c b/sys/dev/etherswitch/infineon/adm6996fc.c
--- a/sys/dev/etherswitch/infineon/adm6996fc.c
+++ b/sys/dev/etherswitch/infineon/adm6996fc.c
@@ -281,18 +281,20 @@
adm6996fc_detach(device_t dev)
{
struct adm6996fc_softc *sc;
- int i, port;
+ int error, i, port;
sc = device_get_softc(dev);
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
+
callout_drain(&sc->callout_tick);
for (i = 0; i < MII_NPHY; i++) {
if (((1 << i) & sc->phymask) == 0)
continue;
port = adm6996fc_portforphy(sc, i);
- if (sc->miibus[port] != NULL)
- device_delete_child(dev, (*sc->miibus[port]));
if (sc->ifp[port] != NULL)
if_free(sc->ifp[port]);
free(sc->ifname[port], M_ADM6996FC);
@@ -304,7 +306,6 @@
free(sc->ifname, M_ADM6996FC);
free(sc->ifp, M_ADM6996FC);
- bus_generic_detach(dev);
mtx_destroy(&sc->sc_mtx);
return (0);
diff --git a/sys/dev/etherswitch/ip17x/ip17x.c b/sys/dev/etherswitch/ip17x/ip17x.c
--- a/sys/dev/etherswitch/ip17x/ip17x.c
+++ b/sys/dev/etherswitch/ip17x/ip17x.c
@@ -274,7 +274,11 @@
ip17x_detach(device_t dev)
{
struct ip17x_softc *sc;
- int i, port;
+ int error, i, port;
+
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
sc = device_get_softc(dev);
if (sc->miipoll)
@@ -284,8 +288,6 @@
if (((1 << i) & sc->phymask) == 0)
continue;
port = sc->phyport[i];
- if (sc->miibus[port] != NULL)
- device_delete_child(dev, (*sc->miibus[port]));
if (sc->ifp[port] != NULL)
if_free(sc->ifp[port]);
free(sc->miibus[port], M_IP17X);
@@ -299,7 +301,6 @@
/* Reset the switch. */
sc->hal.ip17x_reset(sc);
- bus_generic_detach(dev);
mtx_destroy(&sc->sc_mtx);
return (0);
diff --git a/sys/dev/etherswitch/micrel/ksz8995ma.c b/sys/dev/etherswitch/micrel/ksz8995ma.c
--- a/sys/dev/etherswitch/micrel/ksz8995ma.c
+++ b/sys/dev/etherswitch/micrel/ksz8995ma.c
@@ -339,7 +339,11 @@
ksz8995ma_detach(device_t dev)
{
struct ksz8995ma_softc *sc;
- int i, port;
+ int error, i, port;
+
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
sc = device_get_softc(dev);
@@ -349,8 +353,6 @@
if (((1 << i) & sc->phymask) == 0)
continue;
port = ksz8995ma_portforphy(sc, i);
- if (sc->miibus[port] != NULL)
- device_delete_child(dev, (*sc->miibus[port]));
if (sc->ifp[port] != NULL)
if_free(sc->ifp[port]);
free(sc->ifname[port], M_KSZ8995MA);
@@ -362,7 +364,6 @@
free(sc->ifname, M_KSZ8995MA);
free(sc->ifp, M_KSZ8995MA);
- bus_generic_detach(dev);
mtx_destroy(&sc->sc_mtx);
return (0);
diff --git a/sys/dev/etherswitch/mtkswitch/mtkswitch.c b/sys/dev/etherswitch/mtkswitch/mtkswitch.c
--- a/sys/dev/etherswitch/mtkswitch/mtkswitch.c
+++ b/sys/dev/etherswitch/mtkswitch/mtkswitch.c
@@ -248,19 +248,20 @@
mtkswitch_detach(device_t dev)
{
struct mtkswitch_softc *sc = device_get_softc(dev);
- int phy;
+ int error, phy;
+
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
callout_drain(&sc->callout_tick);
for (phy = 0; phy < MTKSWITCH_MAX_PHYS; phy++) {
- if (sc->miibus[phy] != NULL)
- device_delete_child(dev, sc->miibus[phy]);
if (sc->ifp[phy] != NULL)
if_free(sc->ifp[phy]);
free(sc->ifname[phy], M_DEVBUF);
}
- bus_generic_detach(dev);
mtx_destroy(&sc->sc_mtx);
return (0);
diff --git a/sys/dev/etherswitch/rtl8366/rtl8366rb.c b/sys/dev/etherswitch/rtl8366/rtl8366rb.c
--- a/sys/dev/etherswitch/rtl8366/rtl8366rb.c
+++ b/sys/dev/etherswitch/rtl8366/rtl8366rb.c
@@ -268,18 +268,19 @@
rtl8366rb_detach(device_t dev)
{
struct rtl8366rb_softc *sc;
- int i;
+ int error, i;
+
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
sc = device_get_softc(dev);
for (i=0; i < sc->numphys; i++) {
- if (sc->miibus[i])
- device_delete_child(dev, sc->miibus[i]);
if (sc->ifp[i] != NULL)
if_free(sc->ifp[i]);
free(sc->ifname[i], M_DEVBUF);
}
- bus_generic_detach(dev);
callout_drain(&sc->callout_tick);
mtx_destroy(&sc->callout_mtx);
mtx_destroy(&sc->sc_mtx);
diff --git a/sys/dev/etherswitch/ukswitch/ukswitch.c b/sys/dev/etherswitch/ukswitch/ukswitch.c
--- a/sys/dev/etherswitch/ukswitch/ukswitch.c
+++ b/sys/dev/etherswitch/ukswitch/ukswitch.c
@@ -224,7 +224,11 @@
ukswitch_detach(device_t dev)
{
struct ukswitch_softc *sc = device_get_softc(dev);
- int i, port;
+ int error, i, port;
+
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
callout_drain(&sc->callout_tick);
@@ -232,8 +236,6 @@
if (((1 << i) & sc->phymask) == 0)
continue;
port = ukswitch_portforphy(sc, i);
- if (sc->miibus[port] != NULL)
- device_delete_child(dev, (*sc->miibus[port]));
if (sc->ifp[port] != NULL)
if_free(sc->ifp[port]);
free(sc->ifname[port], M_UKSWITCH);
@@ -245,7 +247,6 @@
free(sc->ifname, M_UKSWITCH);
free(sc->ifp, M_UKSWITCH);
- bus_generic_detach(dev);
mtx_destroy(&sc->sc_mtx);
return (0);

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 20, 7:29 PM (4 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25738465
Default Alt Text
D47970.id148694.diff (7 KB)

Event Timeline