- Use IPL_BIO (instead of IPL_SERIAL) for SPI.
- Convert simple_lock/ltsleep to mutex/condvar.
This commit is contained in:
parent
c652f42cfd
commit
b1d9d10d78
@ -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 @@ auspi_attach(struct device *parent, struct device *self, void *aux)
|
||||
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 @@ auspi_transfer(void *arg, struct spi_transfer *st)
|
||||
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);
|
||||
|
@ -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 @@ arspi_interrupts(struct device *self)
|
||||
struct arspi_softc *sc = device_private(self);
|
||||
int s;
|
||||
|
||||
s = splserial();
|
||||
s = splbio();
|
||||
sc->sc_interrupts = true;
|
||||
splx(s);
|
||||
#endif
|
||||
@ -270,7 +270,7 @@ arspi_transfer(void *cookie, struct spi_transfer *st)
|
||||
return rv;
|
||||
}
|
||||
|
||||
s = splserial();
|
||||
s = splbio();
|
||||
spi_transq_enqueue(&sc->sc_transq, st);
|
||||
if (sc->sc_transfer == NULL) {
|
||||
arspi_sched(sc);
|
||||
|
@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.4 2010/08/14 20:49:21 jym Exp $");
|
||||
#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 @@ spibus_print(void *aux, const char *pnp)
|
||||
static int
|
||||
spi_match(device_t parent, cfdata_t cf, void *aux)
|
||||
{
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -188,7 +189,7 @@ spi_configure(struct spi_handle *sh, int mode, int speed)
|
||||
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 @@ void
|
||||
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 @@ spi_transfer(struct spi_handle *sh, struct spi_transfer *st)
|
||||
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 @@ spi_done(struct spi_transfer *st, int err)
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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 @@ struct spi_transfer {
|
||||
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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user