summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/cardbus/if_rl_cardbus.c31
-rw-r--r--sys/dev/ic/rtl81x9.c28
-rw-r--r--sys/dev/ic/rtl81x9reg.h3
-rw-r--r--sys/dev/pci/if_rl_pci.c44
4 files changed, 66 insertions, 40 deletions
diff --git a/sys/dev/cardbus/if_rl_cardbus.c b/sys/dev/cardbus/if_rl_cardbus.c
index 505106fee15..7fa6adb6b00 100644
--- a/sys/dev/cardbus/if_rl_cardbus.c
+++ b/sys/dev/cardbus/if_rl_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rl_cardbus.c,v 1.16 2007/05/08 18:49:32 deraadt Exp $ */
+/* $OpenBSD: if_rl_cardbus.c,v 1.17 2009/06/02 17:27:39 jsg Exp $ */
/* $NetBSD: if_rl_cardbus.c,v 1.3.8.3 2001/11/14 19:14:02 nathanw Exp $ */
/*
@@ -212,35 +212,6 @@ rl_cardbus_attach(parent, self, aux)
rl_attach(sc);
}
-extern int rl_detach(struct rl_softc *);
-
-int
-rl_detach(sc)
- struct rl_softc *sc;
-{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
-
- /* Unhook our tick handler. */
- timeout_del(&sc->sc_tick_tmo);
-
- /* Detach any PHYs we might have. */
- if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL)
- mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
-
- /* Delete any remaining media. */
- ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
-
- ether_ifdetach(ifp);
- if_detach(ifp);
-
- if (sc->sc_sdhook != NULL)
- shutdownhook_disestablish(sc->sc_sdhook);
- if (sc->sc_pwrhook != NULL)
- powerhook_disestablish(sc->sc_pwrhook);
-
- return (0);
-}
-
int
rl_cardbus_detach(self, flags)
struct device *self;
diff --git a/sys/dev/ic/rtl81x9.c b/sys/dev/ic/rtl81x9.c
index aab49cea07c..7ef1c14f2b7 100644
--- a/sys/dev/ic/rtl81x9.c
+++ b/sys/dev/ic/rtl81x9.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtl81x9.c,v 1.63 2009/02/04 19:54:44 claudio Exp $ */
+/* $OpenBSD: rtl81x9.c,v 1.64 2009/06/02 17:27:39 jsg Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -1445,6 +1445,32 @@ rl_tick(v)
timeout_add_sec(&sc->sc_tick_tmo, 1);
}
+int
+rl_detach(struct rl_softc *sc)
+{
+ struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+
+ /* Unhook our tick handler. */
+ timeout_del(&sc->sc_tick_tmo);
+
+ /* Detach any PHYs we might have. */
+ if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL)
+ mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
+
+ /* Delete any remaining media. */
+ ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
+
+ ether_ifdetach(ifp);
+ if_detach(ifp);
+
+ if (sc->sc_sdhook != NULL)
+ shutdownhook_disestablish(sc->sc_sdhook);
+ if (sc->sc_pwrhook != NULL)
+ powerhook_disestablish(sc->sc_pwrhook);
+
+ return (0);
+}
+
struct cfdriver rl_cd = {
0, "rl", DV_IFNET
};
diff --git a/sys/dev/ic/rtl81x9reg.h b/sys/dev/ic/rtl81x9reg.h
index 1f300d728e2..776c2aa5225 100644
--- a/sys/dev/ic/rtl81x9reg.h
+++ b/sys/dev/ic/rtl81x9reg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtl81x9reg.h,v 1.60 2009/02/12 11:55:29 martynas Exp $ */
+/* $OpenBSD: rtl81x9reg.h,v 1.61 2009/06/02 17:27:39 jsg Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -996,3 +996,4 @@ struct rl_softc {
extern int rl_attach(struct rl_softc *);
extern int rl_intr(void *);
extern void rl_setmulti(struct rl_softc *);
+int rl_detach(struct rl_softc *);
diff --git a/sys/dev/pci/if_rl_pci.c b/sys/dev/pci/if_rl_pci.c
index c78cd121767..69aa2d6a2c9 100644
--- a/sys/dev/pci/if_rl_pci.c
+++ b/sys/dev/pci/if_rl_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rl_pci.c,v 1.16 2009/06/02 04:03:39 jsg Exp $ */
+/* $OpenBSD: if_rl_pci.c,v 1.17 2009/06/02 17:27:39 jsg Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -84,9 +84,16 @@
int rl_pci_match(struct device *, void *, void *);
void rl_pci_attach(struct device *, struct device *, void *);
+int rl_pci_detach(struct device *, int);
+
+struct rl_pci_softc {
+ struct rl_softc psc_softc;
+ pci_chipset_tag_t psc_pc;
+ bus_size_t psc_mapsize;
+};
struct cfattach rl_pci_ca = {
- sizeof(struct rl_softc), rl_pci_match, rl_pci_attach,
+ sizeof(struct rl_pci_softc), rl_pci_match, rl_pci_attach, rl_pci_detach
};
const struct pci_matchid rl_pci_devices[] = {
@@ -128,12 +135,12 @@ rl_pci_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
- struct rl_softc *sc = (struct rl_softc *)self;
+ struct rl_pci_softc *psc = (void *)self;
+ struct rl_softc *sc = &psc->psc_softc;
struct pci_attach_args *pa = aux;
pci_chipset_tag_t pc = pa->pa_pc;
pci_intr_handle_t ih;
const char *intrstr = NULL;
- bus_size_t size;
/*
* Map control/status registers.
@@ -141,13 +148,13 @@ rl_pci_attach(parent, self, aux)
#ifdef RL_USEIOSPACE
if (pci_mapreg_map(pa, RL_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0,
- &sc->rl_btag, &sc->rl_bhandle, NULL, &size, 0)) {
+ &sc->rl_btag, &sc->rl_bhandle, NULL, &psc->psc_mapsize, 0)) {
printf(": can't map i/o space\n");
return;
}
#else
if (pci_mapreg_map(pa, RL_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0,
- &sc->rl_btag, &sc->rl_bhandle, NULL, &size, 0)){
+ &sc->rl_btag, &sc->rl_bhandle, NULL, &psc->psc_mapsize, 0)){
printf(": can't map mem space\n");
return;
}
@@ -158,10 +165,11 @@ rl_pci_attach(parent, self, aux)
*/
if (pci_intr_map(pa, &ih)) {
printf(": couldn't map interrupt\n");
- bus_space_unmap(sc->rl_btag, sc->rl_bhandle, size);
+ bus_space_unmap(sc->rl_btag, sc->rl_bhandle, psc->psc_mapsize);
return;
}
+ psc->psc_pc = pa->pa_pc;
intrstr = pci_intr_string(pc, ih);
sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, rl_intr, sc,
self->dv_xname);
@@ -170,7 +178,7 @@ rl_pci_attach(parent, self, aux)
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
- bus_space_unmap(sc->rl_btag, sc->rl_bhandle, size);
+ bus_space_unmap(sc->rl_btag, sc->rl_bhandle, psc->psc_mapsize);
return;
}
printf(": %s", intrstr);
@@ -179,3 +187,23 @@ rl_pci_attach(parent, self, aux)
rl_attach(sc);
}
+
+int
+rl_pci_detach(struct device *self, int flags)
+{
+ struct rl_pci_softc *psc = (void *)self;
+ struct rl_softc *sc = &psc->psc_softc;
+ int rv;
+
+ rv = rl_detach(sc);
+ if (rv)
+ return (rv);
+
+ if (sc->sc_ih != NULL)
+ pci_intr_disestablish(psc->psc_pc, sc->sc_ih);
+
+ bus_space_unmap(sc->rl_btag, sc->rl_bhandle, psc->psc_mapsize);
+
+ return (0);
+}
+