Module Name: src Committed By: jakllsch Date: Thu Dec 20 14:41:35 UTC 2012
Modified Files: src/sys/dev/pci: sdhc_pci.c Log Message: Add detachment support for sdhc_pci. Tested on an ExpressCard JMicron JMB38[89] with as-of-yet-uncommitted changes. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/sdhc_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/sdhc_pci.c diff -u src/sys/dev/pci/sdhc_pci.c:1.9 src/sys/dev/pci/sdhc_pci.c:1.10 --- src/sys/dev/pci/sdhc_pci.c:1.9 Sun Jul 29 23:14:13 2012 +++ src/sys/dev/pci/sdhc_pci.c Thu Dec 20 14:41:35 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: sdhc_pci.c,v 1.9 2012/07/29 23:14:13 matt Exp $ */ +/* $NetBSD: sdhc_pci.c,v 1.10 2012/12/20 14:41:35 jakllsch Exp $ */ /* $OpenBSD: sdhc_pci.c,v 1.7 2007/10/30 18:13:45 chl Exp $ */ /* @@ -18,7 +18,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sdhc_pci.c,v 1.9 2012/07/29 23:14:13 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdhc_pci.c,v 1.10 2012/12/20 14:41:35 jakllsch Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -56,14 +56,16 @@ __KERNEL_RCSID(0, "$NetBSD: sdhc_pci.c,v struct sdhc_pci_softc { struct sdhc_softc sc; + pci_chipset_tag_t sc_pc; void *sc_ih; }; static int sdhc_pci_match(device_t, cfdata_t, void *); static void sdhc_pci_attach(device_t, device_t, void *); +static int sdhc_pci_detach(device_t, int); CFATTACH_DECL_NEW(sdhc_pci, sizeof(struct sdhc_pci_softc), - sdhc_pci_match, sdhc_pci_attach, NULL, NULL); + sdhc_pci_match, sdhc_pci_attach, sdhc_pci_detach, NULL); #ifdef SDHC_DEBUG #define DPRINTF(s) printf s @@ -224,6 +226,8 @@ sdhc_pci_attach(device_t parent, device_ sc->sc.sc_dmat = pa->pa_dmat; sc->sc.sc_host = NULL; + sc->sc_pc = pc; + pci_aprint_devinfo(pa, NULL); /* Some controllers needs special treatment. */ @@ -305,8 +309,33 @@ sdhc_pci_attach(device_t parent, device_ return; err: - if (sc->sc.sc_host != NULL) + if (sc->sc.sc_host != NULL) { free(sc->sc.sc_host, M_DEVBUF); + sc->sc.sc_host = NULL; + } +} + +static int +sdhc_pci_detach(device_t self, int flags) +{ + struct sdhc_pci_softc * const sc = device_private(self); + int rv; + + rv = sdhc_detach(&sc->sc, flags); + if (rv) + return rv; + + if (sc->sc_ih != NULL) { + pci_intr_disestablish(sc->sc_pc, sc->sc_ih); + sc->sc_ih = NULL; + } + + if (sc->sc.sc_host != NULL) { + free(sc->sc.sc_host, M_DEVBUF); + sc->sc.sc_host = NULL; + } + + return rv; } static void