Date: Mon, 2 Oct 2006 21:04:43 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 107123 for review Message-ID: <200610022104.k92L4hTe098333@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=107123 Change 107123 by imp@imp_lighthouse on 2006/10/02 21:04:16 implement ivars and passing requests fix locking on done, I think... Affected files ... .. //depot/projects/arm/src/sys/dev/mmc/mmc.c#13 edit .. //depot/projects/arm/src/sys/dev/mmc/mmcbus_if.m#5 edit Differences ... ==== //depot/projects/arm/src/sys/dev/mmc/mmc.c#13 (text+ko) ==== @@ -37,6 +37,7 @@ #include <dev/mmc/mmcreg.h> #include <dev/mmc/mmcbrvar.h> +#include <dev/mmc/mmcvar.h> #include "mmcbr_if.h" #include "mmcbus_if.h" @@ -102,6 +103,7 @@ /* We'll probe and attach our children later, but before / mount */ sc->config_intrhook.ich_func = mmc_delayed_attach; sc->config_intrhook.ich_arg = sc; + printf("arg is %p\n", sc); if (config_intrhook_establish(&sc->config_intrhook) != 0) device_printf(dev, "config_intrhook_establish failed\n"); return (0); @@ -156,7 +158,14 @@ static void mmc_wakeup(struct mmc_request *req) { + struct mmc_softc *sc; + + printf("Wakeup for req %p done_data %p\n", req, req->done_data); + sc = (struct mmc_softc *)req->done_data; + MMC_LOCK(sc); + req->flags |= MMC_REQ_DONE; wakeup(req); + MMC_UNLOCK(sc); } static int @@ -165,17 +174,30 @@ int err; req->done = mmc_wakeup; + req->done_data = sc; + printf("Submitting request %p sc %p\n", req, sc); MMCBR_REQUEST(device_get_parent(sc->dev), sc->dev, req); MMC_LOCK(sc); do { err = msleep(req, &sc->sc_mtx, PZERO | PCATCH, "mmcreq", hz / 10); - } while (!(req->flags & MMC_REQ_DONE) && err == 0); + printf("err is %d flags %x\n", err, req->flags); + } while (!(req->flags & MMC_REQ_DONE) && err == EAGAIN); + printf("Request %p done with error %d\n", req, err); MMC_UNLOCK(sc); return (err); } static int +mmc_wait_for_request(device_t brdev, device_t reqdev, struct mmc_request *req) +{ + struct mmc_softc *sc = device_get_softc(brdev); + + printf("passing along request %p\n", req); + return mmc_wait_for_req(sc, req); +} + +static int mmc_wait_for_cmd(struct mmc_softc *sc, struct mmc_command *cmd, int retries) { struct mmc_request mreq; @@ -555,6 +577,42 @@ // XXX probe/attach/detach children? } +static int +mmc_read_ivar(device_t bus, device_t child, int which, u_char *result) +{ +// struct at91_mci_softc *sc = device_get_softc(bus); + struct mmc_ivars *ivar = device_get_ivars(child); + + switch (which) { + default: + return (EINVAL); + case MMC_IVAR_MEDIA_SIZE: + *(int *)result = ivar->csd.capacity; + break; + case MMC_IVAR_MODE: + *(int *)result = ivar->mode; + break; + case MMC_IVAR_SECTOR_SIZE: + *(int *)result = 512; + break; + } + return (0); +} + +static int +mmc_write_ivar(device_t bus, device_t child, int which, uintptr_t value) +{ +// struct at91_mci_softc *sc = device_get_softc(bus); +// struct mmc_ivars *ivar = device_get_ivars(child); + + switch (which) { + default: + return (EINVAL); + } + return (0); +} + + static void mmc_delayed_attach(void *xsc) { @@ -566,9 +624,18 @@ } static device_method_t mmc_methods[] = { + /* device_if */ DEVMETHOD(device_probe, mmc_probe), DEVMETHOD(device_attach, mmc_attach), DEVMETHOD(device_detach, mmc_detach), + + /* Bus interface */ + DEVMETHOD(bus_read_ivar, mmc_read_ivar), + DEVMETHOD(bus_write_ivar, mmc_write_ivar), + + /* MMC Bus interface */ + DEVMETHOD(mmcbus_wait_for_request, mmc_wait_for_request), + {0, 0}, }; ==== //depot/projects/arm/src/sys/dev/mmc/mmcbus_if.m#5 (text+ko) ==== @@ -43,7 +43,6 @@ device_t brdev; device_t reqdev; struct mmc_request *req; - int *status; }; #
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610022104.k92L4hTe098333>