Date: Thu, 7 Jun 2007 11:18:03 GMT From: Rui Paulo <rpaulo@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 121149 for review Message-ID: <200706071118.l57BI3dw022039@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=121149 Change 121149 by rpaulo@rpaulo_epsilon on 2007/06/07 11:17:05 Adapt interrupts to INTR_FILTER compile time variable. sc_mtx is now a spin lock mutex again. While there, make asmc_sms_intr() return a proper value. Discussed with: Attilio Rao Affected files ... .. //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#12 edit Differences ... ==== //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#12 (text+ko) ==== @@ -23,7 +23,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#11 $ + * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#12 $ * */ @@ -77,7 +77,12 @@ static int asmc_temp_getvalue(device_t, const char *); static int asmc_sms_read(device_t, const char *, int16_t *); static void asmc_sms_calibrate(device_t); +#ifdef INTR_FILTER static int asmc_sms_intr(void *); +#else +static void asmc_sms_fastintr(void *); +#endif +static void asmc_sms_printintr(device_t, uint8_t); /* * Model functions. @@ -238,7 +243,7 @@ model = asmc_match(dev); - mtx_init(&sc->sc_mtx, "asmc", NULL, MTX_DEF); + mtx_init(&sc->sc_mtx, "asmc", NULL, MTX_SPIN); asmc_init(dev); @@ -373,9 +378,15 @@ goto out; } +#ifdef INTR_FILTER error = bus_setup_intr(dev, sc->sc_res, - INTR_TYPE_MISC|INTR_MPSAFE|INTR_EXCL, + INTR_TYPE_MISC|INTR_MPSAFE, asmc_sms_intr, NULL, dev, &sc->sc_cookie); +#else + error = bus_setup_intr(dev, sc->sc_res, + INTR_TYPE_MISC|INTR_MPSAFE|INTR_FAST, + NULL, asmc_sms_fastintr, dev, &sc->sc_cookie); +#endif if (error) { device_printf(dev, "unable to setup SMS IRQ\n"); bus_release_resource(dev, SYS_RES_IRQ, sc->sc_rid, @@ -515,7 +526,7 @@ int i, error = 1; struct asmc_softc *sc = device_get_softc(dev); - mtx_lock(&sc->sc_mtx); + mtx_lock_spin(&sc->sc_mtx); outb(ASMC_CMDPORT, ASMC_CMDREAD); if (asmc_wait(dev, 0x0c)) @@ -537,7 +548,7 @@ error = 0; out: - mtx_unlock(&sc->sc_mtx); + mtx_unlock_spin(&sc->sc_mtx); return error; } @@ -548,7 +559,7 @@ int i, error = -1; struct asmc_softc *sc = device_get_softc(dev); - mtx_lock(&sc->sc_mtx); + mtx_lock_spin(&sc->sc_mtx); outb(ASMC_CMDPORT, ASMC_CMDWRITE); if (asmc_wait(dev, 0x0c)) @@ -570,7 +581,7 @@ error = 0; out: - mtx_unlock(&sc->sc_mtx); + mtx_unlock_spin(&sc->sc_mtx); return error; @@ -749,6 +760,7 @@ asmc_sms_read(dev, ASMC_KEY_SMS_Z, &sc->sms_rest_z); } +#ifdef INTR_FILTER static int asmc_sms_intr(void *arg) { @@ -756,9 +768,33 @@ device_t dev = (device_t) arg; struct asmc_softc *sc = device_get_softc(dev); - mtx_lock(&sc->sc_mtx); + mtx_lock_spin(&sc->sc_mtx); + type = inb(ASMC_INTPORT); + mtx_unlock_spin(&sc->sc_mtx); + + asmc_sms_printintr(dev, type); + + return FILTER_HANDLED; +} +#else +static void +asmc_sms_fastintr(void *arg) +{ + uint8_t type; + device_t dev = (device_t) arg; + struct asmc_softc *sc = device_get_softc(dev); + + mtx_lock_spin(&sc->sc_mtx); type = inb(ASMC_INTPORT); - mtx_unlock(&sc->sc_mtx); + mtx_unlock_spin(&sc->sc_mtx); + + asmc_sms_printintr(dev, type); +} +#endif /* INTR_FILTER */ + +static void +asmc_sms_printintr(device_t dev, uint8_t type) +{ switch (type) { case ASMC_SMS_INTFF: @@ -773,8 +809,6 @@ default: device_printf(dev, "%s unknown interrupt\n", __func__); } - - return 0; } static int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706071118.l57BI3dw022039>