summaryrefslogtreecommitdiff
path: root/sys/arch/macppc/dev
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2007-05-20 23:38:53 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2007-05-20 23:38:53 +0000
commit025fd76dd94075c770247c7c463859b14eaf0a87 (patch)
treed8ddf4a4eae0f2848686644c7b5cc220630d46e7 /sys/arch/macppc/dev
parent30faceea686215e466faf22cc127a6ed10f9c373 (diff)
lockmgr -> rwlock for piic(4), kiic(4) and smu(4);
smu(4) tested by kettenis@, ok krw@
Diffstat (limited to 'sys/arch/macppc/dev')
-rw-r--r--sys/arch/macppc/dev/kiic.c8
-rw-r--r--sys/arch/macppc/dev/kiicvar.h5
-rw-r--r--sys/arch/macppc/dev/piic.c12
-rw-r--r--sys/arch/macppc/dev/smu.c26
4 files changed, 26 insertions, 25 deletions
diff --git a/sys/arch/macppc/dev/kiic.c b/sys/arch/macppc/dev/kiic.c
index 85ea7cfcd86..7e831374a4b 100644
--- a/sys/arch/macppc/dev/kiic.c
+++ b/sys/arch/macppc/dev/kiic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kiic.c,v 1.1 2007/04/23 16:27:20 deraadt Exp $ */
+/* $OpenBSD: kiic.c,v 1.2 2007/05/20 23:38:52 thib Exp $ */
/* $NetBSD: kiic.c,v 1.1 2003/12/27 02:19:34 grant Exp $ */
/*-
@@ -116,7 +116,7 @@ kiic_attach(struct device *parent, struct device *self, void *aux)
kiic_setmode(sc, I2C_STDSUBMODE, 0);
kiic_setspeed(sc, I2C_100kHz); /* XXX rate */
- lockinit(&sc->sc_buslock, PZERO, sc->sc_dev.dv_xname, 0, 0);
+ rw_init(&sc->sc_buslock, sc->sc_dev.dv_xname);
kiic_writereg(sc, IER,I2C_INT_DATA|I2C_INT_ADDR|I2C_INT_STOP);
for (node = OF_child(ca->ca_node); node; node = OF_peer(node)) {
@@ -354,7 +354,7 @@ kiic_i2c_acquire_bus(void *cookie, int flags)
{
struct kiic_bus *bus = cookie;
- return (lockmgr(&bus->sc->sc_buslock, LK_EXCLUSIVE, NULL));
+ return (rw_enter(&bus->sc->sc_buslock, RW_WRITE));
}
void
@@ -362,7 +362,7 @@ kiic_i2c_release_bus(void *cookie, int flags)
{
struct kiic_bus *bus = cookie;
- (void) lockmgr(&bus->sc->sc_buslock, LK_RELEASE, NULL);
+ (void) rw_exit(&bus->sc->sc_buslock);
}
int
diff --git a/sys/arch/macppc/dev/kiicvar.h b/sys/arch/macppc/dev/kiicvar.h
index 3a22738a19c..837c7301de3 100644
--- a/sys/arch/macppc/dev/kiicvar.h
+++ b/sys/arch/macppc/dev/kiicvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: kiicvar.h,v 1.1 2007/04/23 16:27:20 deraadt Exp $ */
+/* $OpenBSD: kiicvar.h,v 1.2 2007/05/20 23:38:52 thib Exp $ */
/*-
* Copyright (c) 2001 Tsubai Masanari. All rights reserved.
@@ -32,6 +32,7 @@
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
+#include <sys/rwlock.h>
#include <dev/i2c/i2cvar.h>
@@ -90,7 +91,7 @@ struct kiic_softc {
u_char *sc_reg;
int sc_regstep;
- struct lock sc_buslock;
+ struct rwlock sc_buslock;
struct kiic_bus {
struct kiic_softc *sc;
struct i2c_controller i2c_tag;
diff --git a/sys/arch/macppc/dev/piic.c b/sys/arch/macppc/dev/piic.c
index 7cf8f2a1c14..bc4c67dabc3 100644
--- a/sys/arch/macppc/dev/piic.c
+++ b/sys/arch/macppc/dev/piic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: piic.c,v 1.1 2007/04/23 16:27:20 deraadt Exp $ */
+/* $OpenBSD: piic.c,v 1.2 2007/05/20 23:38:52 thib Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -19,7 +19,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
-#include <sys/lock.h>
+#include <sys/rwlock.h>
#include <sys/proc.h>
#include <machine/autoconf.h>
@@ -32,7 +32,7 @@
struct piic_softc {
struct device sc_dev;
- struct lock sc_buslock;
+ struct rwlock sc_buslock;
struct i2c_controller sc_i2c_tag;
};
@@ -67,7 +67,7 @@ piic_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
- lockinit(&sc->sc_buslock, PZERO, sc->sc_dev.dv_xname, 0, 0);
+ rw_init(&sc->sc_buslock, sc->sc_dev.dv_xname);
sc->sc_i2c_tag.ic_cookie = sc;
sc->sc_i2c_tag.ic_acquire_bus = piic_i2c_acquire_bus;
@@ -87,7 +87,7 @@ piic_i2c_acquire_bus(void *cookie, int flags)
{
struct piic_softc *sc = cookie;
- return (lockmgr(&sc->sc_buslock, LK_EXCLUSIVE, NULL));
+ return (rw_enter(&sc->sc_buslock, RW_WRITE));
}
void
@@ -95,7 +95,7 @@ piic_i2c_release_bus(void *cookie, int flags)
{
struct piic_softc *sc = cookie;
- lockmgr(&sc->sc_buslock, LK_RELEASE, NULL);
+ rw_exit(&sc->sc_buslock);
}
int
diff --git a/sys/arch/macppc/dev/smu.c b/sys/arch/macppc/dev/smu.c
index dfec142a89d..bbc900cf49e 100644
--- a/sys/arch/macppc/dev/smu.c
+++ b/sys/arch/macppc/dev/smu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smu.c,v 1.18 2007/04/22 22:31:14 deraadt Exp $ */
+/* $OpenBSD: smu.c,v 1.19 2007/05/20 23:38:52 thib Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -20,7 +20,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 <sys/sensors.h>
@@ -61,7 +61,7 @@ struct smu_softc {
bus_dmamap_t sc_cmdmap;
bus_dma_segment_t sc_cmdseg[1];
caddr_t sc_cmd;
- struct lock sc_lock;
+ struct rwlock sc_lock;
/* Doorbell and mailbox. */
struct ppc_bus_space sc_mem_bus_space;
@@ -242,7 +242,7 @@ smu_attach(struct device *parent, struct device *self, void *aux)
return;
}
- lockinit(&sc->sc_lock, PZERO, sc->sc_dev.dv_xname, 0, 0);
+ rw_init(&sc->sc_lock, sc->sc_dev.dv_xname);
/* Establish smu-doorbell interrupt. */
mac_intr_establish(parent, intr, IST_EDGE, IPL_BIO,
@@ -420,14 +420,14 @@ smu_time_read(time_t *secs)
struct clock_ymdhms dt;
int error;
- lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&sc->sc_lock);
cmd->cmd = SMU_RTC;
cmd->len = 1;
cmd->data[0] = SMU_RTC_GET_DATETIME;
error = smu_do_cmd(sc, 800);
if (error) {
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit_write(&sc->sc_lock);
*secs = 0;
return (error);
@@ -440,7 +440,7 @@ smu_time_read(time_t *secs)
dt.dt_min = FROMBCD(cmd->data[1]);
dt.dt_sec = FROMBCD(cmd->data[0]);
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit_write(&sc->sc_lock);
*secs = clock_ymdhms_to_secs(&dt);
return (0);
@@ -456,7 +456,7 @@ smu_time_write(time_t secs)
clock_secs_to_ymdhms(secs, &dt);
- lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&sc->sc_lock);
cmd->cmd = SMU_RTC;
cmd->len = 8;
@@ -470,7 +470,7 @@ smu_time_write(time_t secs)
cmd->data[7] = TOBCD(dt.dt_year - 2000);
error = smu_do_cmd(sc, 800);
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit_write(&sc->sc_lock);
return (error);
}
@@ -616,12 +616,12 @@ smu_refresh_sensors(void *arg)
struct smu_softc *sc = arg;
int i;
- lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&sc->sc_lock);
for (i = 0; i < sc->sc_num_sensors; i++)
smu_sensor_refresh(sc, &sc->sc_sensors[i]);
for (i = 0; i < sc->sc_num_fans; i++)
smu_fan_refresh(sc, &sc->sc_fans[i]);
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit_write(&sc->sc_lock);
}
int
@@ -632,7 +632,7 @@ smu_i2c_acquire_bus(void *cookie, int flags)
if (flags & I2C_F_POLL)
return (0);
- return (lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL));
+ return (rw_enter(&sc->sc_lock, RW_WRITE));
}
void
@@ -643,7 +643,7 @@ smu_i2c_release_bus(void *cookie, int flags)
if (flags & I2C_F_POLL)
return;
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit(&sc->sc_lock);
}
int