Module Name: src Committed By: rmind Date: Wed Jun 8 23:05:48 UTC 2011
Modified Files: src/sys/arch/mips/alchemy/dev: auspi.c src/sys/arch/mips/atheros/dev: arspi.c src/sys/dev/spi: spi.c spivar.h Log Message: - Use IPL_BIO (instead of IPL_SERIAL) for SPI. - Convert simple_lock/ltsleep to mutex/condvar. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/alchemy/dev/auspi.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/mips/atheros/dev/arspi.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/spi/spi.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/spi/spivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/mips/alchemy/dev/auspi.c diff -u src/sys/arch/mips/alchemy/dev/auspi.c:1.3 src/sys/arch/mips/alchemy/dev/auspi.c:1.4 --- src/sys/arch/mips/alchemy/dev/auspi.c:1.3 Wed Feb 28 04:21:53 2007 +++ src/sys/arch/mips/alchemy/dev/auspi.c Wed Jun 8 23:05:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: auspi.c,v 1.3 2007/02/28 04:21:53 thorpej Exp $ */ +/* $NetBSD: auspi.c,v 1.4 2011/06/08 23:05:48 rmind Exp $ */ /*- * Copyright (c) 2006 Urbana-Champaign Independent Media Center. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: auspi.c,v 1.3 2007/02/28 04:21:53 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: auspi.c,v 1.4 2011/06/08 23:05:48 rmind Exp $"); #include "locators.h" @@ -158,7 +158,7 @@ PUTREG(sc, AUPSC_SPIMSK, SPIMSK_ALL); /* enable device interrupts */ - sc->sc_ih = au_intr_establish(aa->aupsc_irq, 0, IPL_SERIAL, IST_LEVEL, + sc->sc_ih = au_intr_establish(aa->aupsc_irq, 0, IPL_BIO, IST_LEVEL, auspi_intr, sc); (void) config_found_ia(&sc->sc_dev, "spibus", &sba, spibus_print); @@ -428,7 +428,7 @@ int s; /* make sure we select the right chip */ - s = splserial(); + s = splbio(); spi_transq_enqueue(&sc->sc_q, st); if (sc->sc_running == 0) { auspi_sched(sc); Index: src/sys/arch/mips/atheros/dev/arspi.c diff -u src/sys/arch/mips/atheros/dev/arspi.c:1.5 src/sys/arch/mips/atheros/dev/arspi.c:1.6 --- src/sys/arch/mips/atheros/dev/arspi.c:1.5 Wed Feb 28 04:21:53 2007 +++ src/sys/arch/mips/atheros/dev/arspi.c Wed Jun 8 23:05:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: arspi.c,v 1.5 2007/02/28 04:21:53 thorpej Exp $ */ +/* $NetBSD: arspi.c,v 1.6 2011/06/08 23:05:48 rmind Exp $ */ /*- * Copyright (c) 2006 Urbana-Champaign Independent Media Center. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: arspi.c,v 1.5 2007/02/28 04:21:53 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arspi.c,v 1.6 2011/06/08 23:05:48 rmind Exp $"); #include "locators.h" @@ -211,7 +211,7 @@ struct arspi_softc *sc = device_private(self); int s; - s = splserial(); + s = splbio(); sc->sc_interrupts = true; splx(s); #endif @@ -270,7 +270,7 @@ return rv; } - s = splserial(); + s = splbio(); spi_transq_enqueue(&sc->sc_transq, st); if (sc->sc_transfer == NULL) { arspi_sched(sc); Index: src/sys/dev/spi/spi.c diff -u src/sys/dev/spi/spi.c:1.4 src/sys/dev/spi/spi.c:1.5 --- src/sys/dev/spi/spi.c:1.4 Sat Aug 14 20:49:21 2010 +++ src/sys/dev/spi/spi.c Wed Jun 8 23:05:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: spi.c,v 1.4 2010/08/14 20:49:21 jym Exp $ */ +/* $NetBSD: spi.c,v 1.5 2011/06/08 23:05:48 rmind Exp $ */ /*- * Copyright (c) 2006 Urbana-Champaign Independent Media Center. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.4 2010/08/14 20:49:21 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.5 2011/06/08 23:05:48 rmind Exp $"); #include "locators.h" @@ -50,7 +50,8 @@ #include <sys/systm.h> #include <sys/device.h> #include <sys/malloc.h> -#include <sys/proc.h> +#include <sys/mutex.h> +#include <sys/condvar.h> #include <sys/errno.h> #include <dev/spi/spivar.h> @@ -90,7 +91,7 @@ static int spi_match(device_t parent, cfdata_t cf, void *aux) { - + return 1; } @@ -188,7 +189,7 @@ if ((sc->sc_mode >= 0) && (sc->sc_mode != mode)) return EINVAL; - s = splserial(); + s = splbio(); /* pick lowest configured speed */ if (speed == 0) speed = sc->sc_speed; @@ -210,7 +211,9 @@ spi_transfer_init(struct spi_transfer *st) { - simple_lock_init(&st->st_lock); + mutex_init(&st->st_lock, MUTEX_DEFAULT, IPL_BIO); + cv_init(&st->st_cv, "spicv"); + st->st_flags = 0; st->st_errno = 0; st->st_done = NULL; @@ -267,24 +270,19 @@ void spi_wait(struct spi_transfer *st) { - int s; - s = splserial(); - simple_lock(&st->st_lock); + mutex_enter(&st->st_lock); while (!(st->st_flags & SPI_F_DONE)) { - ltsleep(st, PWAIT, "spi_wait", 0, &st->st_lock); + cv_wait(&st->st_cv, &st->st_lock); } - simple_unlock(&st->st_lock); - splx(s); + mutex_exit(&st->st_lock); } void spi_done(struct spi_transfer *st, int err) { - int s; - s = splserial(); - + mutex_enter(&st->st_lock); if ((st->st_errno = err) != 0) { st->st_flags |= SPI_F_ERROR; } @@ -292,12 +290,9 @@ if (st->st_done != NULL) { (*st->st_done)(st); } else { - - simple_lock(&st->st_lock); - wakeup(st); - simple_unlock(&st->st_lock); + cv_broadcast(&st->st_cv); } - splx(s); + mutex_exit(&st->st_lock); } /* Index: src/sys/dev/spi/spivar.h diff -u src/sys/dev/spi/spivar.h:1.3 src/sys/dev/spi/spivar.h:1.4 --- src/sys/dev/spi/spivar.h:1.3 Tue Jan 8 13:28:22 2008 +++ src/sys/dev/spi/spivar.h Wed Jun 8 23:05:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: spivar.h,v 1.3 2008/01/08 13:28:22 dogcow Exp $ */ +/* $NetBSD: spivar.h,v 1.4 2011/06/08 23:05:48 rmind Exp $ */ /*- * Copyright (c) 2006 Urbana-Champaign Independent Media Center. @@ -109,7 +109,8 @@ int st_slave; void *st_private; void (*st_done)(struct spi_transfer *); - struct simplelock st_lock; + kmutex_t st_lock; + kcondvar_t st_cv; void *st_busprivate; };