summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsg <jsg@openbsd.org>2009-06-02 15:13:58 +0000
committerjsg <jsg@openbsd.org>2009-06-02 15:13:58 +0000
commit6040bf374ac690033479429a38bbc82e996cdcdc (patch)
tree6386f2d7414bf9e91adb7b622f29af6754553e46
parentWhen authnone_create fails, do not leave behind a NULL cl_auth attribute, (diff)
downloadwireguard-openbsd-6040bf374ac690033479429a38bbc82e996cdcdc.tar.xz
wireguard-openbsd-6040bf374ac690033479429a38bbc82e996cdcdc.zip
let atw at pci be detachable; untested.
-rw-r--r--sys/dev/ic/atwvar.h3
-rw-r--r--sys/dev/pci/if_atw_pci.c31
2 files changed, 29 insertions, 5 deletions
diff --git a/sys/dev/ic/atwvar.h b/sys/dev/ic/atwvar.h
index b784dab5403..8ec2e43a3ba 100644
--- a/sys/dev/ic/atwvar.h
+++ b/sys/dev/ic/atwvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: atwvar.h,v 1.15 2008/07/21 18:43:19 damien Exp $ */
+/* $OpenBSD: atwvar.h,v 1.16 2009/06/02 15:13:58 jsg Exp $ */
/* $NetBSD: atwvar.h,v 1.13 2004/07/23 07:07:55 dyoung Exp $ */
/*
@@ -209,6 +209,7 @@ struct atw_softc {
bus_space_tag_t sc_st; /* bus space tag */
bus_space_handle_t sc_sh; /* bus space handle */
+ bus_size_t sc_mapsize; /* mapping size */
bus_dma_tag_t sc_dmat; /* bus dma tag */
void *sc_sdhook; /* shutdown hook */
void *sc_powerhook; /* power management hook */
diff --git a/sys/dev/pci/if_atw_pci.c b/sys/dev/pci/if_atw_pci.c
index 453c6c4e4b4..1a3f1e4279f 100644
--- a/sys/dev/pci/if_atw_pci.c
+++ b/sys/dev/pci/if_atw_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_atw_pci.c,v 1.11 2009/06/02 04:03:39 jsg Exp $ */
+/* $OpenBSD: if_atw_pci.c,v 1.12 2009/06/02 15:13:58 jsg Exp $ */
/* $NetBSD: if_atw_pci.c,v 1.7 2004/07/23 07:07:55 dyoung Exp $ */
/*-
@@ -90,9 +90,10 @@ struct atw_pci_softc {
int atw_pci_match(struct device *, void *, void *);
void atw_pci_attach(struct device *, struct device *, void *);
+int atw_pci_detach(struct device *, int);
struct cfattach atw_pci_ca = {
- sizeof (struct atw_softc), atw_pci_match, atw_pci_attach
+ sizeof (struct atw_softc), atw_pci_match, atw_pci_attach, atw_pci_detach
};
const struct pci_matchid atw_pci_devices[] = {
@@ -144,6 +145,7 @@ atw_pci_attach(struct device *parent, struct device *self, void *aux)
const char *intrstr = NULL;
bus_space_tag_t iot, memt;
bus_space_handle_t ioh, memh;
+ bus_size_t iosize, memsize;
int ioh_valid, memh_valid;
int state;
@@ -187,17 +189,19 @@ atw_pci_attach(struct device *parent, struct device *self, void *aux)
*/
ioh_valid = (pci_mapreg_map(pa, ATW_PCI_IOBA,
PCI_MAPREG_TYPE_IO, 0,
- &iot, &ioh, NULL, NULL, 0) == 0);
+ &iot, &ioh, NULL, &iosize, 0) == 0);
memh_valid = (pci_mapreg_map(pa, ATW_PCI_MMBA,
PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT, 0,
- &memt, &memh, NULL, NULL, 0) == 0);
+ &memt, &memh, NULL, &memsize, 0) == 0);
if (memh_valid) {
sc->sc_st = memt;
sc->sc_sh = memh;
+ sc->sc_mapsize = memsize;
} else if (ioh_valid) {
sc->sc_st = iot;
sc->sc_sh = ioh;
+ sc->sc_mapsize = iosize;
} else {
printf(": unable to map device registers\n");
return;
@@ -249,3 +253,22 @@ atw_pci_attach(struct device *parent, struct device *self, void *aux)
*/
atw_attach(sc);
}
+
+int
+atw_pci_detach(struct device *self, int flags)
+{
+ struct atw_pci_softc *psc = (void *)self;
+ struct atw_softc *sc = &psc->psc_atw;
+ int rv;
+
+ rv = atw_detach(sc);
+ if (rv)
+ return (rv);
+
+ if (psc->psc_intrcookie != NULL)
+ pci_intr_disestablish(psc->psc_pc, psc->psc_intrcookie);
+
+ bus_space_unmap(sc->sc_st, sc->sc_sh, sc->sc_mapsize);
+
+ return (0);
+}