lockmgr -> mutex

This commit is contained in:
ad 2007-12-05 07:15:53 +00:00
parent 598ab03ad0
commit 5a24480bf8
9 changed files with 55 additions and 48 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ehci.c,v 1.125 2007/10/19 12:01:21 ad Exp $ */
/* $NetBSD: ehci.c,v 1.126 2007/12/05 07:15:53 ad Exp $ */
/*
* Copyright (c) 2004,2005 The NetBSD Foundation, Inc.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.125 2007/10/19 12:01:21 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.126 2007/12/05 07:15:53 ad Exp $");
#include "ohci.h"
#include "uhci.h"
@ -74,8 +74,9 @@ __KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.125 2007/10/19 12:01:21 ad Exp $");
#include <sys/select.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/mutex.h>
#include <sys/bus.h>
#include <machine/endian.h>
#include <dev/usb/usb.h>
@ -494,7 +495,7 @@ ehci_init(ehci_softc_t *sc)
usb_callout_init(sc->sc_tmo_intrlist);
lockinit(&sc->sc_doorbell_lock, PZERO, "ehcidb", 0, 0);
mutex_init(&sc->sc_doorbell_lock, MUTEX_DEFAULT, IPL_NONE);
/* Turn on controller */
EOWRITE4(sc, EHCI_USBCMD,
@ -932,6 +933,7 @@ ehci_detach(struct ehci_softc *sc, int flags)
usb_delay_ms(&sc->sc_bus, 300); /* XXX let stray task complete */
/* XXX free other data structures XXX */
mutex_destroy(&sc->sc_doorbell_lock);
return (rv);
}
@ -1525,7 +1527,7 @@ ehci_sync_hc(ehci_softc_t *sc)
return;
}
DPRINTFN(2,("ehci_sync_hc: enter\n"));
usb_lockmgr(&sc->sc_doorbell_lock, LK_EXCLUSIVE, NULL); /* get doorbell */
mutex_enter(&sc->sc_doorbell_lock); /* get doorbell */
s = splhardusb();
/* ask for doorbell */
EOWRITE4(sc, EHCI_USBCMD, EOREAD4(sc, EHCI_USBCMD) | EHCI_CMD_IAAD);
@ -1535,7 +1537,7 @@ ehci_sync_hc(ehci_softc_t *sc)
DPRINTFN(1,("ehci_sync_hc: cmd=0x%08x sts=0x%08x\n",
EOREAD4(sc, EHCI_USBCMD), EOREAD4(sc, EHCI_USBSTS)));
splx(s);
usb_lockmgr(&sc->sc_doorbell_lock, LK_RELEASE, NULL); /* release doorbell */
mutex_exit(&sc->sc_doorbell_lock); /* release doorbell */
#ifdef DIAGNOSTIC
if (error)
printf("ehci_sync_hc: tsleep() = %d\n", error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ehcivar.h,v 1.24 2007/01/07 16:44:44 drochner Exp $ */
/* $NetBSD: ehcivar.h,v 1.25 2007/12/05 07:15:54 ad Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -131,7 +131,7 @@ typedef struct ehci_softc {
SIMPLEQ_HEAD(, usbd_xfer) sc_free_xfers; /* free xfers */
struct lock sc_doorbell_lock;
kmutex_t sc_doorbell_lock;
usb_callout_t sc_tmo_intrlist;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_aue.c,v 1.105 2007/11/20 10:43:01 sborrill Exp $ */
/* $NetBSD: if_aue.c,v 1.106 2007/12/05 07:15:54 ad Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.105 2007/11/20 10:43:01 sborrill Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.106 2007/12/05 07:15:54 ad Exp $");
#if defined(__NetBSD__)
#include "opt_inet.h"
@ -90,12 +90,11 @@ __KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.105 2007/11/20 10:43:01 sborrill Exp $"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sockio.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/mbuf.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/device.h>
#if NRND > 0
#include <sys/rnd.h>
@ -439,13 +438,13 @@ Static void
aue_lock_mii(struct aue_softc *sc)
{
sc->aue_refcnt++;
lockmgr(&sc->aue_mii_lock, LK_EXCLUSIVE, NULL);
mutex_enter(&sc->aue_mii_lock);
}
Static void
aue_unlock_mii(struct aue_softc *sc)
{
lockmgr(&sc->aue_mii_lock, LK_RELEASE, NULL);
mutex_exit(&sc->aue_mii_lock);
if (--sc->aue_refcnt < 0)
usb_detach_wakeup(USBDEV(sc->aue_dev));
}
@ -772,7 +771,7 @@ USB_ATTACH(aue)
usb_init_task(&sc->aue_tick_task, aue_tick_task, sc);
usb_init_task(&sc->aue_stop_task, (void (*)(void *))aue_stop, sc);
lockinit(&sc->aue_mii_lock, PZERO, "auemii", 0, 0);
mutex_init(&sc->aue_mii_lock, MUTEX_DEFAULT, IPL_NONE);
err = usbd_device2interface_handle(dev, AUE_IFACE_IDX, &iface);
if (err) {
@ -947,6 +946,8 @@ USB_DETACH(aue)
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->aue_udev,
USBDEV(sc->aue_dev));
mutex_destroy(&sc->aue_mii_lock);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_auereg.h,v 1.17 2006/09/15 10:47:34 is Exp $ */
/* $NetBSD: if_auereg.h,v 1.18 2007/12/05 07:15:54 ad Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
@ -275,7 +275,7 @@ struct aue_softc {
struct usb_task aue_tick_task;
struct usb_task aue_stop_task;
struct lock aue_mii_lock;
kmutex_t aue_mii_lock;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_udav.c,v 1.18 2007/07/12 21:24:02 xtraeme Exp $ */
/* $NetBSD: if_udav.c,v 1.19 2007/12/05 07:15:54 ad Exp $ */
/* $nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $ */
/*
* Copyright (c) 2003
@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.18 2007/07/12 21:24:02 xtraeme Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.19 2007/12/05 07:15:54 ad Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@ -52,11 +52,10 @@ __KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.18 2007/07/12 21:24:02 xtraeme Exp $")
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/mbuf.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/device.h>
#if NRND > 0
#include <sys/rnd.h>
@ -200,7 +199,7 @@ USB_ATTACH(udav)
}
usb_init_task(&sc->sc_tick_task, udav_tick_task, sc);
lockinit(&sc->sc_mii_lock, PZERO, "udavmii", 0, 0);
mutex_init(&sc->sc_mii_lock, MUTEX_DEFAULT, IPL_NONE);
usb_init_task(&sc->sc_stop_task, (void (*)(void *)) udav_stop_task, sc);
/* get control interface */
@ -366,6 +365,8 @@ USB_DETACH(udav)
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
USBDEV(sc->sc_dev));
mutex_destroy(&sc->sc_mii_lock);
return (0);
}
@ -1476,7 +1477,7 @@ udav_lock_mii(struct udav_softc *sc)
__func__));
sc->sc_refcnt++;
lockmgr(&sc->sc_mii_lock, LK_EXCLUSIVE, NULL);
mutex_enter(&sc->sc_mii_lock);
}
Static void
@ -1485,7 +1486,7 @@ udav_unlock_mii(struct udav_softc *sc)
DPRINTFN(0xff, ("%s: %s: enter\n", USBDEVNAME(sc->sc_dev),
__func__));
lockmgr(&sc->sc_mii_lock, LK_RELEASE, NULL);
mutex_exit(&sc->sc_mii_lock);
if (--sc->sc_refcnt < 0)
usb_detach_wakeup(USBDEV(sc->sc_dev));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_udavreg.h,v 1.3 2005/12/11 12:24:01 christos Exp $ */
/* $NetBSD: if_udavreg.h,v 1.4 2007/12/05 07:15:54 ad Exp $ */
/* $nabe: if_udavreg.h,v 1.2 2003/08/21 16:26:40 nabe Exp $ */
/*
* Copyright (c) 2003
@ -186,7 +186,7 @@ struct udav_softc {
/* Ethernet */
struct ethercom sc_ec; /* ethernet common */
struct mii_data sc_mii;
struct lock sc_mii_lock;
kmutex_t sc_mii_lock;
int sc_link;
#define sc_media udav_mii.mii_media
#if NRND > 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: stuirda.c,v 1.2 2007/05/11 13:12:14 is Exp $ */
/* $NetBSD: stuirda.c,v 1.3 2007/12/05 07:15:54 ad Exp $ */
/*
* Copyright (c) 2001,2007 The NetBSD Foundation, Inc.
@ -298,7 +298,7 @@ stuirda_write(void *h, struct uio *uio, int flag)
return (EINVAL);
sc->sc_refcnt++;
lockmgr(&sc->sc_wr_buf_lk, LK_EXCLUSIVE, NULL);
mutex_enter(&sc->sc_wr_buf_lk);
sc->sc_wr_buf[0] = UIRDA_EB_NO_CHANGE | UIRDA_NO_SPEED;
@ -328,7 +328,7 @@ stuirda_write(void *h, struct uio *uio, int flag)
}
}
lockmgr(&sc->sc_wr_buf_lk, LK_RELEASE, NULL);
mutex_exit(&sc->sc_wr_buf_lk);
if (--sc->sc_refcnt < 0)
usb_detach_wakeup(USBDEV(sc->sc_dev));

View File

@ -1,4 +1,4 @@
/* $NetBSD: uirda.c,v 1.25 2007/05/11 13:12:14 is Exp $ */
/* $NetBSD: uirda.c,v 1.26 2007/12/05 07:15:54 ad Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,13 +37,13 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uirda.c,v 1.25 2007/05/11 13:12:14 is Exp $");
__KERNEL_RCSID(0, "$NetBSD: uirda.c,v 1.26 2007/12/05 07:15:54 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/ioctl.h>
#include <sys/conf.h>
#include <sys/file.h>
@ -271,8 +271,8 @@ USB_ATTACH(uirda)
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
USBDEV(sc->sc_dev));
lockinit(&sc->sc_wr_buf_lk, PZERO, "iirwrl", 0, 0);
lockinit(&sc->sc_rd_buf_lk, PZERO, "uirrdl", 0, 0);
mutex_init(&sc->sc_wr_buf_lk, MUTEX_DEFAULT, IPL_NONE);
mutex_init(&sc->sc_rd_buf_lk, MUTEX_DEFAULT, IPL_NONE);
ia.ia_type = IR_TYPE_IRFRAME;
ia.ia_methods = sc->sc_irm ? sc->sc_irm : &uirda_methods;
@ -320,6 +320,9 @@ USB_DETACH(uirda)
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
USBDEV(sc->sc_dev));
mutex_destroy(&sc->sc_wr_buf_lk);
mutex_destroy(&sc->sc_rd_buf_lk);
return (rv);
}
@ -483,7 +486,7 @@ uirda_read(void *h, struct uio *uio, int flag)
}
splx(s);
lockmgr(&sc->sc_rd_buf_lk, LK_EXCLUSIVE, NULL);
mutex_enter(&sc->sc_rd_buf_lk);
n = sc->sc_rd_count - sc->sc_hdszi;
DPRINTFN(1,("%s: sc=%p n=%u, hdr=0x%02x\n", __func__,
sc, n, sc->sc_rd_buf[0]));
@ -492,7 +495,7 @@ uirda_read(void *h, struct uio *uio, int flag)
else
error = uiomove(sc->sc_rd_buf + sc->sc_hdszi, n, uio);
sc->sc_rd_count = 0;
lockmgr(&sc->sc_rd_buf_lk, LK_RELEASE, NULL);
mutex_exit(&sc->sc_rd_buf_lk);
err = uirda_start_read(sc);
/* XXX check err */
@ -530,7 +533,7 @@ uirda_write(void *h, struct uio *uio, int flag)
return (EINVAL);
sc->sc_refcnt++;
lockmgr(&sc->sc_wr_buf_lk, LK_EXCLUSIVE, NULL);
mutex_enter(&sc->sc_wr_buf_lk);
sc->sc_wr_buf[0] = UIRDA_EB_NO_CHANGE | UIRDA_NO_SPEED;
error = uiomove(sc->sc_wr_buf + UIRDA_OUTPUT_HEADER_SIZE, n, uio);
@ -553,7 +556,7 @@ uirda_write(void *h, struct uio *uio, int flag)
}
}
lockmgr(&sc->sc_wr_buf_lk, LK_RELEASE, NULL);
mutex_exit(&sc->sc_wr_buf_lk);
if (--sc->sc_refcnt < 0)
usb_detach_wakeup(USBDEV(sc->sc_dev));
@ -725,28 +728,28 @@ uirda_set_params(void *h, struct irda_params *p)
return (EINVAL);
/* Change the write buffer */
lockmgr(&sc->sc_wr_buf_lk, LK_EXCLUSIVE, NULL);
mutex_enter(&sc->sc_wr_buf_lk);
if (sc->sc_wr_buf != NULL)
usbd_free_buffer(sc->sc_wr_xfer);
sc->sc_wr_buf = usbd_alloc_buffer(sc->sc_wr_xfer, p->maxsize+1);
lockmgr(&sc->sc_wr_buf_lk, LK_RELEASE, NULL);
mutex_exit(&sc->sc_wr_buf_lk);
if (sc->sc_wr_buf == NULL)
return (ENOMEM);
/* Change the read buffer */
lockmgr(&sc->sc_rd_buf_lk, LK_EXCLUSIVE, NULL);
mutex_enter(&sc->sc_rd_buf_lk);
usbd_abort_pipe(sc->sc_rd_pipe);
if (sc->sc_rd_buf != NULL)
usbd_free_buffer(sc->sc_rd_xfer);
sc->sc_rd_buf = usbd_alloc_buffer(sc->sc_rd_xfer, p->maxsize+1);
sc->sc_rd_count = 0;
if (sc->sc_rd_buf == NULL) {
lockmgr(&sc->sc_rd_buf_lk, LK_RELEASE, NULL);
mutex_exit(&sc->sc_rd_buf_lk);
return (ENOMEM);
}
sc->sc_params.maxsize = p->maxsize;
err = uirda_start_read(sc); /* XXX check */
lockmgr(&sc->sc_rd_buf_lk, LK_RELEASE, NULL);
mutex_exit(&sc->sc_rd_buf_lk);
#endif
}
if (hdr != 0 && hdr != sc->sc_wr_hdr) {
@ -758,7 +761,7 @@ uirda_set_params(void *h, struct irda_params *p)
DPRINTF(("%s: sc=%p setting header 0x%02x\n",
__func__, sc, hdr));
sc->sc_wr_hdr = hdr;
lockmgr(&sc->sc_wr_buf_lk, LK_EXCLUSIVE, NULL);
mutex_enter(&sc->sc_wr_buf_lk);
sc->sc_wr_buf[0] = hdr;
n = UIRDA_OUTPUT_HEADER_SIZE;
err = usbd_bulk_transfer(sc->sc_wr_xfer, sc->sc_wr_pipe,
@ -769,7 +772,7 @@ uirda_set_params(void *h, struct irda_params *p)
USBDEVNAME(sc->sc_dev), err);
usbd_clear_endpoint_stall(sc->sc_wr_pipe);
}
lockmgr(&sc->sc_wr_buf_lk, LK_RELEASE, NULL);
mutex_exit(&sc->sc_wr_buf_lk);
}
sc->sc_params = *p;

View File

@ -1,4 +1,4 @@
/* $NetBSD: uirdavar.h,v 1.1 2007/04/27 14:42:49 is Exp $ */
/* $NetBSD: uirdavar.h,v 1.2 2007/12/05 07:15:54 ad Exp $ */
/*
* Copyright (c) 2001,2007 The NetBSD Foundation, Inc.
@ -128,7 +128,7 @@ struct uirda_softc {
usbd_device_handle sc_udev;
usbd_interface_handle sc_iface;
struct lock sc_rd_buf_lk;
kmutex_t sc_rd_buf_lk;
u_int8_t *sc_rd_buf;
int sc_rd_addr;
usbd_pipe_handle sc_rd_pipe;
@ -137,7 +137,7 @@ struct uirda_softc {
u_int sc_rd_count;
u_char sc_rd_err;
struct lock sc_wr_buf_lk;
kmutex_t sc_wr_buf_lk;
u_int8_t *sc_wr_buf;
int sc_wr_addr;
usbd_xfer_handle sc_wr_xfer;