summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2007-06-05 08:37:21 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2007-06-05 08:37:21 +0000
commit3033997e9c562ce3ee8b9bb55e4ecc77e6b90a56 (patch)
treedc182b2601e4aac378167183e9be6d802cb45b70 /sys/dev
parent8f79d391bb54f8c64e2d0cd49200d426e55218d9 (diff)
Switch to rwlock(9)
ok grange@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/gpio/gpioiic.c11
-rw-r--r--sys/dev/isa/gscsio.c16
2 files changed, 13 insertions, 14 deletions
diff --git a/sys/dev/gpio/gpioiic.c b/sys/dev/gpio/gpioiic.c
index 2d3a5580f33..559717f8f7c 100644
--- a/sys/dev/gpio/gpioiic.c
+++ b/sys/dev/gpio/gpioiic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gpioiic.c,v 1.6 2006/01/20 21:39:09 grange Exp $ */
+/* $OpenBSD: gpioiic.c,v 1.7 2007/06/05 08:37:20 jsg Exp $ */
/*
* Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org>
@@ -24,6 +24,7 @@
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/gpio.h>
+#include <sys/rwlock.h>
#include <dev/gpio/gpiovar.h>
@@ -45,7 +46,7 @@ struct gpioiic_softc {
int __map[GPIOIIC_NPINS];
struct i2c_controller sc_i2c_tag;
- struct lock sc_i2c_lock;
+ struct rwlock sc_i2c_lock;
int sc_sda;
int sc_scl;
@@ -165,7 +166,7 @@ gpioiic_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
/* Attach I2C bus */
- lockinit(&sc->sc_i2c_lock, PRIBIO | PCATCH, "iiclk", 0, 0);
+ rw_init(&sc->sc_i2c_lock, "iiclk");
sc->sc_i2c_tag.ic_cookie = sc;
sc->sc_i2c_tag.ic_acquire_bus = gpioiic_i2c_acquire_bus;
sc->sc_i2c_tag.ic_release_bus = gpioiic_i2c_release_bus;
@@ -200,7 +201,7 @@ gpioiic_i2c_acquire_bus(void *cookie, int flags)
if (cold || (flags & I2C_F_POLL))
return (0);
- return (lockmgr(&sc->sc_i2c_lock, LK_EXCLUSIVE, NULL));
+ return (rw_enter(&sc->sc_i2c_lock, RW_WRITE | RW_INTR));
}
void
@@ -211,7 +212,7 @@ gpioiic_i2c_release_bus(void *cookie, int flags)
if (cold || (flags & I2C_F_POLL))
return;
- lockmgr(&sc->sc_i2c_lock, LK_RELEASE, NULL);
+ rw_exit(&sc->sc_i2c_lock);
}
int
diff --git a/sys/dev/isa/gscsio.c b/sys/dev/isa/gscsio.c
index 469af381223..8d400dc7f44 100644
--- a/sys/dev/isa/gscsio.c
+++ b/sys/dev/isa/gscsio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gscsio.c,v 1.8 2006/01/05 10:43:15 grange Exp $ */
+/* $OpenBSD: gscsio.c,v 1.9 2007/06/05 08:37:20 jsg Exp $ */
/*
* Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
*
@@ -24,7 +24,7 @@
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/kernel.h>
-#include <sys/lock.h>
+#include <sys/rwlock.h>
#include <sys/proc.h>
#include <machine/bus.h>
@@ -50,7 +50,7 @@ struct gscsio_softc {
struct gscsio_acb {
void *sc;
bus_space_handle_t ioh;
- struct lock buslock;
+ struct rwlock buslock;
} sc_acb[2];
struct i2c_controller sc_acb1_tag;
struct i2c_controller sc_acb2_tag;
@@ -207,8 +207,7 @@ gscsio_attach(struct device *parent, struct device *self, void *aux)
if (sc->sc_ld_en[GSCSIO_LDN_ACB1]) {
sc->sc_acb[0].sc = sc;
sc->sc_acb[0].ioh = sc->sc_ld_ioh0[GSCSIO_LDN_ACB1];
- lockinit(&sc->sc_acb[0].buslock, PRIBIO | PCATCH,
- "iiclk", 0, 0);
+ rw_init(&sc->sc_acb[0].buslock, "iiclk");
gscsio_acb_init(&sc->sc_acb[0], &sc->sc_acb1_tag);
}
@@ -216,8 +215,7 @@ gscsio_attach(struct device *parent, struct device *self, void *aux)
if (sc->sc_ld_en[GSCSIO_LDN_ACB2]) {
sc->sc_acb[1].sc = sc;
sc->sc_acb[1].ioh = sc->sc_ld_ioh0[GSCSIO_LDN_ACB2];
- lockinit(&sc->sc_acb[1].buslock, PRIBIO | PCATCH,
- "iiclk", 0, 0);
+ rw_init(&sc->sc_acb[1].buslock, "iiclk");
gscsio_acb_init(&sc->sc_acb[1], &sc->sc_acb2_tag);
}
}
@@ -323,7 +321,7 @@ gscsio_acb_acquire_bus(void *cookie, int flags)
if (cold || flags & I2C_F_POLL)
return (0);
- return (lockmgr(&acb->buslock, LK_EXCLUSIVE, NULL));
+ return (rw_enter(&acb->buslock, RW_WRITE | RW_INTR));
}
void
@@ -334,7 +332,7 @@ gscsio_acb_release_bus(void *cookie, int flags)
if (cold || flags & I2C_F_POLL)
return;
- lockmgr(&acb->buslock, LK_RELEASE, NULL);
+ rw_exit(&acb->buslock);
}
int