Use rwlock(9) rather than lockmgr(9).

This commit is contained in:
xtraeme 2007-08-27 15:57:13 +00:00
parent 89310978dc
commit 87186fcca6
7 changed files with 43 additions and 44 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: amdpm_smbus.c,v 1.13 2007/08/27 12:07:39 xtraeme Exp $ */
/* $NetBSD: amdpm_smbus.c,v 1.14 2007/08/27 15:57:13 xtraeme Exp $ */
/*
* Copyright (c) 2005 Anil Gopinath (anil_public@yahoo.com)
@ -32,13 +32,15 @@
* AMD-8111 HyperTransport I/O Hub
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: amdpm_smbus.c,v 1.13 2007/08/27 12:07:39 xtraeme Exp $");
__KERNEL_RCSID(0, "$NetBSD: amdpm_smbus.c,v 1.14 2007/08/27 15:57:13 xtraeme Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/rnd.h>
#include <sys/rwlock.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
@ -96,7 +98,7 @@ amdpm_smbus_attach(struct amdpm_softc *sc)
sc->sc_i2c.ic_write_byte = NULL;
sc->sc_i2c.ic_exec = amdpm_smbus_exec;
lockinit(&sc->sc_lock, PZERO, "amdpm_smbus", 0, 0);
rw_init(&sc->sc_rwlock);
#ifdef XBOX
#define XBOX_SMBA 0x8000
@ -165,10 +167,9 @@ static int
amdpm_smbus_acquire_bus(void *cookie, int flags)
{
struct amdpm_softc *sc = cookie;
int err;
err = lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
return err;
rw_enter(&sc->sc_rwlock, RW_WRITER);
return 0;
}
static void
@ -176,7 +177,7 @@ amdpm_smbus_release_bus(void *cookie, int flags)
{
struct amdpm_softc *sc = cookie;
lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
rw_exit(&sc->sc_rwlock);
}
static int

View File

@ -1,4 +1,4 @@
/* $NetBSD: amdpmvar.h,v 1.4 2007/02/05 23:38:15 jmcneill Exp $ */
/* $NetBSD: amdpmvar.h,v 1.5 2007/08/27 15:57:13 xtraeme Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#ifndef _DEV_PCI_AMDPMVAR_H_
#define _DEV_PCI_AMDPMVAR_H_
#include <sys/lock.h>
#include <sys/rwlock.h>
struct amdpm_softc {
struct device sc_dev;
@ -54,7 +54,7 @@ struct amdpm_softc {
i2c_addr_t sc_smbus_slaveaddr; /* address of smbus slave */
struct i2c_controller sc_i2c; /* i2c controller info */
struct lock sc_lock;
krwlock_t sc_rwlock;
void *sc_ih;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ichsmb.c,v 1.7 2007/08/27 09:09:22 xtraeme Exp $ */
/* $NetBSD: ichsmb.c,v 1.8 2007/08/27 15:57:14 xtraeme Exp $ */
/* $OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $ */
/*
@ -22,13 +22,13 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.7 2007/08/27 09:09:22 xtraeme Exp $");
__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.8 2007/08/27 15:57:14 xtraeme Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/rwlock.h>
#include <sys/proc.h>
#include <machine/bus.h>
@ -59,7 +59,7 @@ struct ichsmb_softc {
int sc_poll;
struct i2c_controller sc_i2c_tag;
struct lock sc_i2c_lock;
krwlock_t sc_i2c_rwlock;
struct {
i2c_op_t op;
void * buf;
@ -164,7 +164,7 @@ ichsmb_attach(struct device *parent, struct device *self, void *aux)
}
/* Attach I2C bus */
lockinit(&sc->sc_i2c_lock, PZERO, "smblk", 0, 0);
rw_init(&sc->sc_i2c_rwlock);
sc->sc_i2c_tag.ic_cookie = sc;
sc->sc_i2c_tag.ic_acquire_bus = ichsmb_i2c_acquire_bus;
sc->sc_i2c_tag.ic_release_bus = ichsmb_i2c_release_bus;
@ -183,9 +183,10 @@ ichsmb_i2c_acquire_bus(void *cookie, int flags)
struct ichsmb_softc *sc = cookie;
if (cold || sc->sc_poll || (flags & I2C_F_POLL))
return (0);
return 0;
return (lockmgr(&sc->sc_i2c_lock, LK_EXCLUSIVE, NULL));
rw_enter(&sc->sc_i2c_rwlock, RW_WRITER);
return 0;
}
static void
@ -196,7 +197,7 @@ ichsmb_i2c_release_bus(void *cookie, int flags)
if (cold || sc->sc_poll || (flags & I2C_F_POLL))
return;
lockmgr(&sc->sc_i2c_lock, LK_RELEASE, NULL);
rw_exit(&sc->sc_i2c_rwlock);
}
static int

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfsmb.c,v 1.4 2007/08/14 14:18:17 kiyohara Exp $ */
/* $NetBSD: nfsmb.c,v 1.5 2007/08/27 15:57:13 xtraeme Exp $ */
/*
* Copyright (c) 2007 KIYOHARA Takashi
* All rights reserved.
@ -26,13 +26,13 @@
*
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfsmb.c,v 1.4 2007/08/14 14:18:17 kiyohara Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfsmb.c,v 1.5 2007/08/27 15:57:13 xtraeme Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/rwlock.h>
#include <sys/proc.h>
#include <machine/bus.h>
@ -73,7 +73,7 @@ struct nfsmb_softc {
bus_space_handle_t sc_ioh;
struct i2c_controller sc_i2c; /* i2c controller info */
struct lock sc_lock;
krwlock_t sc_rwlock;
};
@ -208,7 +208,7 @@ nfsmb_attach(struct device *parent, struct device *self, void *aux)
sc->sc_i2c.ic_write_byte = NULL;
sc->sc_i2c.ic_exec = nfsmb_exec;
lockinit(&sc->sc_lock, PZERO, "nfsmb", 0, 0);
rw_init(&sc->sc_rwlock);
if (bus_space_map(sc->sc_iot, nfsmbcap->nfsmb_addr, NFORCE_SMBSIZE, 0,
&sc->sc_ioh) != 0) {
@ -225,11 +225,9 @@ static int
nfsmb_acquire_bus(void *cookie, int flags)
{
struct nfsmb_softc *sc = cookie;
int err;
err = lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
return err;
rw_enter(&sc->sc_rwlock, RW_WRITER);
return 0;
}
static void
@ -237,9 +235,7 @@ nfsmb_release_bus(void *cookie, int flags)
{
struct nfsmb_softc *sc = cookie;
lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
return;
rw_exit(&sc->sc_rwlock);
}
static int

View File

@ -1,4 +1,4 @@
/* $NetBSD: piixpm.c,v 1.15 2007/08/26 17:17:06 xtraeme Exp $ */
/* $NetBSD: piixpm.c,v 1.16 2007/08/27 15:57:13 xtraeme Exp $ */
/* $OpenBSD: piixpm.c,v 1.20 2006/02/27 08:25:02 grange Exp $ */
/*
@ -25,7 +25,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>
@ -64,7 +64,7 @@ struct piixpm_softc {
pcitag_t sc_pcitag;
struct i2c_controller sc_i2c_tag;
struct lock sc_i2c_lock;
krwlock_t sc_i2c_rwlock;
struct {
i2c_op_t op;
void * buf;
@ -227,7 +227,7 @@ nopowermanagement:
aprint_normal("\n");
/* Attach I2C bus */
lockinit(&sc->sc_i2c_lock, PRIBIO | PCATCH, "iiclk", 0, 0);
rw_init(&sc->sc_i2c_rwlock);
sc->sc_i2c_tag.ic_cookie = sc;
sc->sc_i2c_tag.ic_acquire_bus = piixpm_i2c_acquire_bus;
sc->sc_i2c_tag.ic_release_bus = piixpm_i2c_release_bus;
@ -271,7 +271,8 @@ piixpm_i2c_acquire_bus(void *cookie, int flags)
if (cold || sc->sc_poll || (flags & I2C_F_POLL))
return (0);
return (lockmgr(&sc->sc_i2c_lock, LK_EXCLUSIVE, NULL));
rw_enter(&sc->sc_i2c_rwlock, RW_WRITER);
return 0;
}
void
@ -282,7 +283,7 @@ piixpm_i2c_release_bus(void *cookie, int flags)
if (cold || sc->sc_poll || (flags & I2C_F_POLL))
return;
lockmgr(&sc->sc_i2c_lock, LK_RELEASE, NULL);
rw_exit(&sc->sc_i2c_rwlock);
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_url.c,v 1.26 2007/03/13 13:51:54 drochner Exp $ */
/* $NetBSD: if_url.c,v 1.27 2007/08/27 16:08:41 xtraeme Exp $ */
/*
* Copyright (c) 2001, 2002
* Shingo WATANABE <nabe@nabechan.org>. All rights reserved.
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.26 2007/03/13 13:51:54 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.27 2007/08/27 16:08:41 xtraeme Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@ -51,7 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.26 2007/03/13 13:51:54 drochner Exp $")
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/rwlock.h>
#include <sys/mbuf.h>
#include <sys/kernel.h>
#include <sys/socket.h>
@ -202,7 +202,7 @@ USB_ATTACH(url)
}
usb_init_task(&sc->sc_tick_task, url_tick_task, sc);
lockinit(&sc->sc_mii_lock, PZERO, "urlmii", 0, 0);
rw_init(&sc->sc_mii_rwlock);
usb_init_task(&sc->sc_stop_task, (void (*)(void *)) url_stop_task, sc);
/* get control interface */
@ -1358,7 +1358,7 @@ url_lock_mii(struct url_softc *sc)
__func__));
sc->sc_refcnt++;
lockmgr(&sc->sc_mii_lock, LK_EXCLUSIVE, NULL);
rw_enter(&sc->sc_mii_rwlock, RW_WRITER);
}
Static void
@ -1367,7 +1367,7 @@ url_unlock_mii(struct url_softc *sc)
DPRINTFN(0xff, ("%s: %s: enter\n", USBDEVNAME(sc->sc_dev),
__func__));
lockmgr(&sc->sc_mii_lock, LK_RELEASE, NULL);
rw_exit(&sc->sc_mii_rwlock);
if (--sc->sc_refcnt < 0)
usb_detach_wakeup(USBDEV(sc->sc_dev));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_urlreg.h,v 1.3 2005/12/11 12:24:01 christos Exp $ */
/* $NetBSD: if_urlreg.h,v 1.4 2007/08/27 16:08:42 xtraeme Exp $ */
/*
* Copyright (c) 2001, 2002
* Shingo WATANABE <nabe@nabechan.org>. All rights reserved.
@ -172,7 +172,7 @@ struct url_softc {
/* Ethernet */
struct ethercom sc_ec; /* ethernet common */
struct mii_data sc_mii;
struct lock sc_mii_lock;
krwlock_t sc_mii_rwlock;
int sc_link;
#define sc_media url_mii.mii_media
#if NRND > 0