Module Name: src
Committed By: riastradh
Date: Wed Dec 12 06:24:02 UTC 2012
Modified Files:
src/sys/dev/sdmmc: sdhc.c
Log Message:
Avoid the 16-bit read in sdhc_host_found for 32-bit-only devices.
This change 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.
To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/sdmmc/sdhc.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/sdmmc/sdhc.c
diff -u src/sys/dev/sdmmc/sdhc.c:1.32 src/sys/dev/sdmmc/sdhc.c:1.33
--- src/sys/dev/sdmmc/sdhc.c:1.32 Mon Oct 29 13:30:25 2012
+++ src/sys/dev/sdmmc/sdhc.c Wed Dec 12 06:24:01 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: sdhc.c,v 1.32 2012/10/29 13:30:25 kiyohara Exp $ */
+/* $NetBSD: sdhc.c,v 1.33 2012/12/12 06:24:01 riastradh Exp $ */
/* $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $ */
/*
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.32 2012/10/29 13:30:25 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.33 2012/12/12 06:24:01 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_sdmmc.h"
@@ -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.
*/