summaryrefslogtreecommitdiff
path: root/sys/dev/ips/ips.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2014-11-13 22:06:57 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2014-11-13 22:06:57 +0000
commit352176c8cbca91a5361a1d7e59e317861775a322 (patch)
treeefd964ac078cb3a00b84c7927aa5c1cd1713980e /sys/dev/ips/ips.c
parent7ff829cb0e176bed820eca23d6d183c364639068 (diff)
Notes
Diffstat (limited to 'sys/dev/ips/ips.c')
-rw-r--r--sys/dev/ips/ips.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/dev/ips/ips.c b/sys/dev/ips/ips.c
index 4de98ce7475e..7ef3ba7beb43 100644
--- a/sys/dev/ips/ips.c
+++ b/sys/dev/ips/ips.c
@@ -41,7 +41,6 @@ MALLOC_DEFINE(M_IPSBUF, "ipsbuf","IPS driver buffer");
static struct cdevsw ips_cdevsw = {
.d_version = D_VERSION,
- .d_flags = D_NEEDGIANT,
.d_open = ips_open,
.d_close = ips_close,
.d_ioctl = ips_ioctl,
@@ -74,14 +73,19 @@ static const char* ips_adapter_name[] = {
static int ips_open(struct cdev *dev, int flags, int fmt, struct thread *td)
{
ips_softc_t *sc = dev->si_drv1;
+ mtx_lock(&sc->queue_mtx);
sc->state |= IPS_DEV_OPEN;
+ mtx_unlock(&sc->queue_mtx);
return 0;
}
static int ips_close(struct cdev *dev, int flags, int fmt, struct thread *td)
{
ips_softc_t *sc = dev->si_drv1;
+
+ mtx_lock(&sc->queue_mtx);
sc->state &= ~IPS_DEV_OPEN;
+ mtx_unlock(&sc->queue_mtx);
return 0;
}
@@ -299,7 +303,7 @@ static void ips_timeout(void *arg)
int i, state = 0;
ips_command_t *command;
- mtx_lock(&sc->queue_mtx);
+ mtx_assert(&sc->queue_mtx, MA_OWNED);
command = &sc->commandarray[0];
for(i = 0; i < sc->max_cmds; i++){
if(!command[i].timeout){
@@ -329,8 +333,7 @@ static void ips_timeout(void *arg)
sc->state &= ~IPS_TIMEOUT;
}
if (sc->state != IPS_OFFLINE)
- sc->timer = timeout(ips_timeout, sc, 10*hz);
- mtx_unlock(&sc->queue_mtx);
+ callout_reset(&sc->timer, 10 * hz, ips_timeout, sc);
}
/* check card and initialize it */
@@ -379,7 +382,6 @@ int ips_adapter_init(ips_softc_t *sc)
can handle */
sc->max_cmds = 1;
ips_cmdqueue_init(sc);
- callout_handle_init(&sc->timer);
if(sc->ips_adapter_reinit(sc, 0))
goto error;
@@ -417,7 +419,7 @@ int ips_adapter_init(ips_softc_t *sc)
S_IRUSR | S_IWUSR, "ips%d", device_get_unit(sc->dev));
sc->device_file->si_drv1 = sc;
ips_diskdev_init(sc);
- sc->timer = timeout(ips_timeout, sc, 10*hz);
+ callout_reset(&sc->timer, 10 * hz, ips_timeout, sc);
return 0;
error:
@@ -492,7 +494,7 @@ int ips_adapter_free(ips_softc_t *sc)
return EBUSY;
}
DEVICE_PRINTF(1, sc->dev, "free\n");
- untimeout(ips_timeout, sc, sc->timer);
+ callout_drain(&sc->timer);
if(sc->sg_dmatag)
bus_dma_tag_destroy(sc->sg_dmatag);