diff options
-rw-r--r-- | sys/dev/cardbus/puc_cardbus.c | 35 | ||||
-rw-r--r-- | sys/dev/pci/puc.c | 37 | ||||
-rw-r--r-- | sys/dev/pci/pucvar.h | 6 | ||||
-rw-r--r-- | sys/dev/puc/com_puc.c | 12 |
4 files changed, 61 insertions, 29 deletions
diff --git a/sys/dev/cardbus/puc_cardbus.c b/sys/dev/cardbus/puc_cardbus.c index a8ea3f65335..f6f95d76b1d 100644 --- a/sys/dev/cardbus/puc_cardbus.c +++ b/sys/dev/cardbus/puc_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: puc_cardbus.c,v 1.2 2006/10/12 16:35:52 grange Exp $ */ +/* $OpenBSD: puc_cardbus.c,v 1.3 2007/12/04 21:49:35 kettenis Exp $ */ /* * Copyright (c) 2006 Michael Shalayeff @@ -158,30 +158,39 @@ puc_cardbus_intr_establish(struct puc_attach_args *paa, int type, int (*func)(void *), void *arg, char *name) { struct puc_cardbus_softc *sc = paa->puc; + struct puc_softc *psc = &sc->sc_psc; struct cardbus_devfunc *ct = sc->ct; - return (cardbus_intr_establish(ct->ct_cc, ct->ct_cf, sc->intrline, - type, func, arg, name)); + psc->sc_ports[paa->port].intrhand = + cardbus_intr_establish(ct->ct_cc, ct->ct_cf, sc->intrline, + type, func, arg, name); + + return (psc->sc_ports[paa->port].intrhand); } int puc_cardbus_detach(struct device *self, int flags) { - struct puc_cardbus_softc *csc = (struct puc_cardbus_softc *)self; - struct puc_softc *sc = &csc->sc_psc; - struct cardbus_devfunc *ct = csc->ct; + struct puc_cardbus_softc *sc = (struct puc_cardbus_softc *)self; + struct puc_softc *psc = &sc->sc_psc; + struct cardbus_devfunc *ct = sc->ct; int i, rv; - for (i = PUC_MAX_PORTS; i--; ) - if (sc->sc_ports[i].dev) - if ((rv = config_detach(sc->sc_ports[i].dev, flags))) + for (i = PUC_MAX_PORTS; i--; ) { + if (psc->sc_ports[i].intrhand) + cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, + psc->sc_ports[i].intrhand); + if (psc->sc_ports[i].dev) + if ((rv = config_detach(psc->sc_ports[i].dev, flags))) return (rv); + } for (i = PUC_NBARS; i--; ) - if (sc->sc_bar_mappings[i].mapped) - Cardbus_mapreg_unmap(ct, sc->sc_bar_mappings[i].type, - sc->sc_bar_mappings[i].t, sc->sc_bar_mappings[i].h, - sc->sc_bar_mappings[i].s); + if (psc->sc_bar_mappings[i].mapped) + Cardbus_mapreg_unmap(ct, psc->sc_bar_mappings[i].type, + psc->sc_bar_mappings[i].t, + psc->sc_bar_mappings[i].h, + psc->sc_bar_mappings[i].s); return (0); } diff --git a/sys/dev/pci/puc.c b/sys/dev/pci/puc.c index 4f213c7b05d..35e736c1d9d 100644 --- a/sys/dev/pci/puc.c +++ b/sys/dev/pci/puc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: puc.c,v 1.12 2007/04/26 01:31:05 gwk Exp $ */ +/* $OpenBSD: puc.c,v 1.13 2007/12/04 21:49:35 kettenis Exp $ */ /* $NetBSD: puc.c,v 1.3 1999/02/06 06:29:54 cgd Exp $ */ /* @@ -72,12 +72,14 @@ struct puc_pci_softc { int puc_pci_match(struct device *, void *, void *); void puc_pci_attach(struct device *, struct device *, void *); +int puc_pci_detach(struct device *, int); const char *puc_pci_intr_string(struct puc_attach_args *); void *puc_pci_intr_establish(struct puc_attach_args *, int, int (*)(void *), void *, char *); struct cfattach puc_pci_ca = { - sizeof(struct puc_pci_softc), puc_pci_match, puc_pci_attach + sizeof(struct puc_pci_softc), puc_pci_match, + puc_pci_attach, puc_pci_detach }; struct cfdriver puc_cd = { @@ -128,8 +130,12 @@ puc_pci_intr_establish(struct puc_attach_args *paa, int type, int (*func)(void *), void *arg, char *name) { struct puc_pci_softc *sc = paa->puc; + struct puc_softc *psc = &sc->sc_psc; + + psc->sc_ports[paa->port].intrhand = + pci_intr_establish(sc->pc, sc->ih, type, func, arg, name); - return (pci_intr_establish(sc->pc, sc->ih, type, func, arg, name)); + return (psc->sc_ports[paa->port].intrhand); } void @@ -292,6 +298,31 @@ puc_common_attach(struct puc_softc *sc, struct puc_attach_args *paa) } int +puc_pci_detach(struct device *self, int flags) +{ + struct puc_pci_softc *sc = (struct puc_pci_softc *)self; + struct puc_softc *psc = &sc->sc_psc; + int i, rv; + + for (i = PUC_MAX_PORTS; i--; ) { + if (psc->sc_ports[i].intrhand) + pci_intr_disestablish(sc->pc, + psc->sc_ports[i].intrhand); + if (psc->sc_ports[i].dev) + if ((rv = config_detach(psc->sc_ports[i].dev, flags))) + return (rv); + } + + for (i = PUC_NBARS; i--; ) + if (psc->sc_bar_mappings[i].mapped) + bus_space_unmap(psc->sc_bar_mappings[i].t, + psc->sc_bar_mappings[i].h, + psc->sc_bar_mappings[i].s); + + return (0); +} + +int puc_print(void *aux, const char *pnp) { struct puc_attach_args *paa = aux; diff --git a/sys/dev/pci/pucvar.h b/sys/dev/pci/pucvar.h index 12fc9f11f85..6b6fc292467 100644 --- a/sys/dev/pci/pucvar.h +++ b/sys/dev/pci/pucvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pucvar.h,v 1.5 2006/07/31 11:06:33 mickey Exp $ */ +/* $OpenBSD: pucvar.h,v 1.6 2007/12/04 21:49:35 kettenis Exp $ */ /* $NetBSD: pucvar.h,v 1.2 1999/02/06 06:29:54 cgd Exp $ */ /* @@ -82,6 +82,7 @@ struct puc_attach_args { const char *(*intr_string)(struct puc_attach_args *); void *(*intr_establish)(struct puc_attach_args *, int, int (*)(void *), void *, char *); + void (*intr_disestablish)(struct puc_attach_args *, void *); }; extern const struct puc_device_description puc_devices[]; @@ -107,8 +108,7 @@ struct puc_softc { struct { struct device *dev; /* filled in by port attachments */ - int (*ihand)(void *); - void *ihandarg; + void *intrhand; } sc_ports[PUC_MAX_PORTS]; }; diff --git a/sys/dev/puc/com_puc.c b/sys/dev/puc/com_puc.c index 93e66249a10..6c1db9e3b5e 100644 --- a/sys/dev/puc/com_puc.c +++ b/sys/dev/puc/com_puc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com_puc.c,v 1.14 2006/11/05 17:18:14 martin Exp $ */ +/* $OpenBSD: com_puc.c,v 1.15 2007/12/04 21:49:35 kettenis Exp $ */ /* * Copyright (c) 1997 - 1999, Jason Downs. All rights reserved. @@ -133,13 +133,5 @@ com_puc_attach(parent, self, aux) int com_puc_detach(struct device *self, int flags) { - /* struct com_softc *sc = (void *)self; */ - int error; - - if ((error = com_detach(self, flags)) != 0) - return (error); - - /* cardbus_intr_disestablish(psc->sc_cc, psc->sc_cf, csc->cc_ih); */ - - return (0); + return com_detach(self, flags); } |