Avoid the 16-bit read in sdhc_host_found for 32-bit-only devices. This makes sdhc_host_found allocate hp up front before showing the identification, in order to avoid having to open-code a copy of HREAD2 before hp is available. Index: sys/dev/sdmmc/sdhc.c =================================================================== RCS file: /cvsroot/src/sys/dev/sdmmc/sdhc.c,v retrieving revision 1.32 diff -p -u -r1.32 sdhc.c --- sys/dev/sdmmc/sdhc.c 29 Oct 2012 13:30:25 -0000 1.32 +++ sys/dev/sdmmc/sdhc.c 12 Dec 2012 05:10:14 -0000 @@ -244,8 +244,28 @@ sdhc_host_found(struct sdhc_softc *sc, b uint32_t caps; uint16_t sdhcver; - sdhcver = bus_space_read_2(iot, ioh, SDHC_HOST_CTL_VERSION); + /* Allocate one more host structure. */ + hp = malloc(sizeof(struct sdhc_host), M_DEVBUF, M_WAITOK|M_ZERO); + if (hp == NULL) { + aprint_error_dev(sc->sc_dev, + "couldn't alloc memory (sdhc host)\n"); + goto err1; + } + sc->sc_host[sc->sc_nhosts++] = hp; + + /* Fill in the new host structure. */ + hp->sc = sc; + hp->iot = iot; + hp->ioh = ioh; + hp->dmat = sc->sc_dmat; + + mutex_init(&hp->host_mtx, MUTEX_DEFAULT, IPL_SDMMC); + mutex_init(&hp->intr_mtx, MUTEX_DEFAULT, IPL_SDMMC); + cv_init(&hp->intr_cv, "sdhcintr"); + + sdhcver = HREAD2(hp, SDHC_HOST_CTL_VERSION); aprint_normal_dev(sc->sc_dev, "SD Host Specification "); + hp->specver = SDHC_SPEC_VERSION(sdhcver); switch (SDHC_SPEC_VERSION(sdhcver)) { case SDHC_SPEC_VERS_100: aprint_normal("1.0"); @@ -266,26 +286,6 @@ sdhc_host_found(struct sdhc_softc *sc, b } aprint_normal(", rev.%u\n", SDHC_VENDOR_VERSION(sdhcver)); - /* Allocate one more host structure. */ - hp = malloc(sizeof(struct sdhc_host), M_DEVBUF, M_WAITOK|M_ZERO); - if (hp == NULL) { - aprint_error_dev(sc->sc_dev, - "couldn't alloc memory (sdhc host)\n"); - goto err1; - } - sc->sc_host[sc->sc_nhosts++] = hp; - - /* Fill in the new host structure. */ - hp->sc = sc; - hp->iot = iot; - hp->ioh = ioh; - hp->dmat = sc->sc_dmat; - hp->specver = SDHC_SPEC_VERSION(sdhcver); - - mutex_init(&hp->host_mtx, MUTEX_DEFAULT, IPL_SDMMC); - mutex_init(&hp->intr_mtx, MUTEX_DEFAULT, IPL_SDMMC); - cv_init(&hp->intr_cv, "sdhcintr"); - /* * Reset the host controller and enable interrupts. */