Date: Tue, 3 Oct 2006 00:12:45 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 107131 for review Message-ID: <200610030012.k930Cjiq030640@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=107131 Change 107131 by imp@imp_lighthouse on 2006/10/03 00:12:29 Implement mmc acquire and release bus. Affected files ... .. //depot/projects/arm/src/sys/dev/mmc/mmc.c#15 edit Differences ... ==== //depot/projects/arm/src/sys/dev/mmc/mmc.c#15 (text+ko) ==== @@ -45,6 +45,7 @@ device_t dev; struct mtx sc_mtx; struct intr_config_hook config_intrhook; + device_t owner; }; /* @@ -115,14 +116,44 @@ return (EBUSY); /* XXX */ } -static void -mmc_acquire_bus(struct mmc_softc *sc) +static int +mmc_acquire_bus(device_t busdev, device_t dev) { + struct mmc_softc *sc; + int err; + + err = MMCBR_ACQUIRE_HOST(device_get_parent(busdev), dev); + if (err) + return (err); + sc = device_get_softc(busdev); + MMC_LOCK(sc); + if (sc->owner) + panic("How did I get here?"); + sc->owner = dev; + MMC_UNLOCK(sc); + return (0); } -static void -mmc_release_bus(struct mmc_softc *sc) +static int +mmc_release_bus(device_t busdev, device_t dev) { + struct mmc_softc *sc; + int err; + + sc = device_get_softc(busdev); + MMC_LOCK(sc); + if (!sc->owner) + panic("No owner?"); + if (sc->owner != dev) + panic("Wrong owner releasing?"); + MMC_UNLOCK(sc); + err = MMCBR_RELEASE_HOST(device_get_parent(busdev), dev); + if (err) + return (err); + MMC_LOCK(sc); + sc->owner = NULL; + MMC_UNLOCK(sc); + return (0); } static int @@ -565,7 +596,7 @@ device_t dev; dev = sc->dev; - mmc_acquire_bus(sc); + mmc_acquire_bus(dev, dev); if (mmcbr_get_power_mode(dev) == power_on) mmc_rescan_cards(sc); @@ -573,7 +604,7 @@ mmcbr_set_clock(dev, mmc_calculate_clock(sc)); mmcbr_update_ios(dev); - mmc_release_bus(sc); + mmc_release_bus(dev, dev); // XXX probe/attach/detach children? } @@ -635,6 +666,8 @@ /* MMC Bus interface */ DEVMETHOD(mmcbus_wait_for_request, mmc_wait_for_request), + DEVMETHOD(mmcbus_acquire_bus, mmc_acquire_bus), + DEVMETHOD(mmcbus_release_bus, mmc_release_bus), {0, 0}, };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610030012.k930Cjiq030640>