From 3c6c3f2824f7c74b348ec07c873835041a25df05 Mon Sep 17 00:00:00 2001 From: Can Erkin Acar Date: Fri, 19 May 2006 09:10:51 +0000 Subject: Use rwlock instead of lockmgr locks. ok marco@ --- sys/dev/acpi/acpibat.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c index 12194d79183..87e3ed2a69b 100644 --- a/sys/dev/acpi/acpibat.c +++ b/sys/dev/acpi/acpibat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibat.c,v 1.21 2006/04/30 05:22:27 marco Exp $ */ +/* $OpenBSD: acpibat.c,v 1.22 2006/05/19 09:10:50 canacar Exp $ */ /* * Copyright (c) 2005 Marco Peereboom * @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -44,7 +44,7 @@ struct acpibat_softc { struct acpi_softc *sc_acpi; struct aml_node *sc_devnode; - struct lock sc_lock; + struct rwlock sc_lock; struct acpibat_bif sc_bif; struct acpibat_bst sc_bst; volatile int sc_bat_present; @@ -92,7 +92,7 @@ acpibat_attach(struct device *parent, struct device *self, void *aux) sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_devnode = aa->aaa_node->child; - lockinit(&sc->sc_lock, PZERO, DEVNAME(sc), 0, 0); + rw_init(&sc->sc_lock, "acpibat"); memset(&res, 0, sizeof(res)); memset(&env, 0, sizeof(env)); @@ -212,7 +212,7 @@ acpibat_refresh(void *arg) acpibat_getbif(sc); acpibat_getbst(sc); - lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL); + rw_enter_write(&sc->sc_lock); /* XXX ugh but make sure */ if (!sc->sc_bif.bif_cap_granu1) @@ -244,7 +244,7 @@ acpibat_refresh(void *arg) sc->sc_bif.bif_cap_granu1 * 1000; sc->sc_sens[7].value = sc->sc_bst.bst_voltage * 1000; - lockmgr(&sc->sc_lock, LK_RELEASE, NULL); + rw_exit_write(&sc->sc_lock); } int @@ -254,7 +254,7 @@ acpibat_getbif(struct acpibat_softc *sc) struct acpi_context *ctx; int rv = 1; - lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL); + rw_enter_write(&sc->sc_lock); memset(&res, 0, sizeof(res)); memset(&env, 0, sizeof(env)); @@ -321,7 +321,7 @@ acpibat_getbif(struct acpibat_softc *sc) sc->sc_bif.bif_oem); out: - lockmgr(&sc->sc_lock, LK_RELEASE, NULL); + rw_exit_write(&sc->sc_lock); return (rv); } @@ -332,7 +332,7 @@ acpibat_getbst(struct acpibat_softc *sc) struct acpi_context *ctx; int rv = 0; - lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL); + rw_enter_write(&sc->sc_lock); memset(&res, 0, sizeof(res)); memset(&env, 0, sizeof(env)); @@ -364,7 +364,7 @@ acpibat_getbst(struct acpibat_softc *sc) sc->sc_bst.bst_capacity, sc->sc_bst.bst_voltage); out: - lockmgr(&sc->sc_lock, LK_RELEASE, NULL); + rw_exit_write(&sc->sc_lock); return (rv); } -- cgit v1.2.3