diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2007-06-05 08:37:21 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2007-06-05 08:37:21 +0000 |
commit | 3033997e9c562ce3ee8b9bb55e4ecc77e6b90a56 (patch) | |
tree | dc182b2601e4aac378167183e9be6d802cb45b70 /sys/dev/gpio/gpioiic.c | |
parent | 8f79d391bb54f8c64e2d0cd49200d426e55218d9 (diff) |
Switch to rwlock(9)
ok grange@
Diffstat (limited to 'sys/dev/gpio/gpioiic.c')
-rw-r--r-- | sys/dev/gpio/gpioiic.c | 11 |
1 files changed, 6 insertions, 5 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 |