summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorbmilekic <bmilekic@FreeBSD.org>2001-02-09 06:11:45 +0000
committerbmilekic <bmilekic@FreeBSD.org>2001-02-09 06:11:45 +0000
commitf364d4ac3621ae2689a3cc1b82c73eb491475a24 (patch)
tree84444d0341ce519800ed7913d826f5f38c622d6d /sys/dev
parent363bdddf694863339f6629340cfb324771b8ffe7 (diff)
downloadFreeBSD-src-f364d4ac3621ae2689a3cc1b82c73eb491475a24.zip
FreeBSD-src-f364d4ac3621ae2689a3cc1b82c73eb491475a24.tar.gz
Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order)
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpica/Osd/OsdSynch.c8
-rw-r--r--sys/dev/an/if_anreg.h4
-rw-r--r--sys/dev/dc/if_dcreg.h4
-rw-r--r--sys/dev/fxp/if_fxpvar.h4
-rw-r--r--sys/dev/ichsmb/ichsmb.c44
-rw-r--r--sys/dev/isp/isp_freebsd.c4
-rw-r--r--sys/dev/isp/isp_freebsd.h4
-rw-r--r--sys/dev/pccbb/pccbb.c26
-rw-r--r--sys/dev/random/harvest.c2
-rw-r--r--sys/dev/random/yarrow.c72
-rw-r--r--sys/dev/sf/if_sfreg.h4
-rw-r--r--sys/dev/sio/sio.c86
-rw-r--r--sys/dev/sk/if_skreg.h8
-rw-r--r--sys/dev/ti/if_tireg.h4
-rw-r--r--sys/dev/usb/if_auereg.h4
-rw-r--r--sys/dev/usb/if_cuereg.h4
-rw-r--r--sys/dev/usb/if_kuereg.h4
-rw-r--r--sys/dev/vinum/vinumdaemon.c4
-rw-r--r--sys/dev/vinum/vinumlock.c4
-rw-r--r--sys/dev/vr/if_vrreg.h4
-rw-r--r--sys/dev/wi/if_wireg.h4
21 files changed, 151 insertions, 151 deletions
diff --git a/sys/dev/acpica/Osd/OsdSynch.c b/sys/dev/acpica/Osd/OsdSynch.c
index 79ae4f5..dacfc5c 100644
--- a/sys/dev/acpica/Osd/OsdSynch.c
+++ b/sys/dev/acpica/Osd/OsdSynch.c
@@ -139,7 +139,7 @@ AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT32 Timeout)
tmo = 1;
}
- mtx_enter(&as->as_mtx, MTX_DEF);
+ mtx_lock(&as->as_mtx);
DEBUG_PRINT(TRACE_MUTEX, ("get %d units from semaphore %p (has %d), timeout %d\n",
Units, as, as->as_units, Timeout));
for (;;) {
@@ -163,7 +163,7 @@ AcpiOsWaitSemaphore(ACPI_HANDLE Handle, UINT32 Units, UINT32 Timeout)
break;
}
}
- mtx_exit(&as->as_mtx, MTX_DEF);
+ mtx_unlock(&as->as_mtx);
return_ACPI_STATUS(result);
#else
@@ -182,14 +182,14 @@ AcpiOsSignalSemaphore(ACPI_HANDLE Handle, UINT32 Units)
if (as == NULL)
return_ACPI_STATUS(AE_BAD_PARAMETER);
- mtx_enter(&as->as_mtx, MTX_DEF);
+ mtx_lock(&as->as_mtx);
DEBUG_PRINT(TRACE_MUTEX, ("return %d units to semaphore %p (has %d)\n",
Units, as, as->as_units));
as->as_units += Units;
if (as->as_units > as->as_maxunits)
as->as_units = as->as_maxunits;
wakeup(as);
- mtx_exit(&as->as_mtx, MTX_DEF);
+ mtx_unlock(&as->as_mtx);
return_ACPI_STATUS(AE_OK);
#else
return(AE_OK);
diff --git a/sys/dev/an/if_anreg.h b/sys/dev/an/if_anreg.h
index 9d67a3a..241cd65 100644
--- a/sys/dev/an/if_anreg.h
+++ b/sys/dev/an/if_anreg.h
@@ -844,8 +844,8 @@ struct an_softc {
device_t an_dev;
};
-#define AN_LOCK(_sc) mtx_enter(&(_sc)->an_mtx, MTX_DEF)
-#define AN_UNLOCK(_sc) mtx_exit(&(_sc)->an_mtx, MTX_DEF)
+#define AN_LOCK(_sc) mtx_lock(&(_sc)->an_mtx)
+#define AN_UNLOCK(_sc) mtx_unlock(&(_sc)->an_mtx)
void an_release_resources __P((device_t));
int an_alloc_port __P((device_t, int, int));
diff --git a/sys/dev/dc/if_dcreg.h b/sys/dev/dc/if_dcreg.h
index 2327fa6..56f441f 100644
--- a/sys/dev/dc/if_dcreg.h
+++ b/sys/dev/dc/if_dcreg.h
@@ -702,8 +702,8 @@ struct dc_softc {
};
-#define DC_LOCK(_sc) mtx_enter(&(_sc)->dc_mtx, MTX_DEF)
-#define DC_UNLOCK(_sc) mtx_exit(&(_sc)->dc_mtx, MTX_DEF)
+#define DC_LOCK(_sc) mtx_lock(&(_sc)->dc_mtx)
+#define DC_UNLOCK(_sc) mtx_unlock(&(_sc)->dc_mtx)
#define DC_TX_POLL 0x00000001
#define DC_TX_COALESCE 0x00000002
diff --git a/sys/dev/fxp/if_fxpvar.h b/sys/dev/fxp/if_fxpvar.h
index aee009c..7a9eb8d 100644
--- a/sys/dev/fxp/if_fxpvar.h
+++ b/sys/dev/fxp/if_fxpvar.h
@@ -86,5 +86,5 @@ struct fxp_softc {
#define sc_if arpcom.ac_if
#define FXP_UNIT(_sc) (_sc)->arpcom.ac_if.if_unit
-#define FXP_LOCK(_sc) mtx_enter(&(_sc)->sc_mtx, MTX_DEF)
-#define FXP_UNLOCK(_sc) mtx_exit(&(_sc)->sc_mtx, MTX_DEF)
+#define FXP_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
+#define FXP_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
diff --git a/sys/dev/ichsmb/ichsmb.c b/sys/dev/ichsmb/ichsmb.c
index 9bbc7db..71b9b7a 100644
--- a/sys/dev/ichsmb/ichsmb.c
+++ b/sys/dev/ichsmb/ichsmb.c
@@ -167,7 +167,7 @@ ichsmb_quick(device_t dev, u_char slave, int how)
switch (how) {
case SMB_QREAD:
case SMB_QWRITE:
- mtx_enter(&sc->mutex, MTX_DEF);
+ mtx_lock(&sc->mutex);
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_QUICK;
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
(slave << 1) | (how == SMB_QREAD ?
@@ -175,7 +175,7 @@ ichsmb_quick(device_t dev, u_char slave, int how)
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_CNT,
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
smb_error = ichsmb_wait(sc);
- mtx_exit(&sc->mutex, MTX_DEF);
+ mtx_unlock(&sc->mutex);
break;
default:
smb_error = SMB_ENOTSUPP;
@@ -193,7 +193,7 @@ ichsmb_sendb(device_t dev, u_char slave, char byte)
DBG("slave=0x%02x byte=0x%02x\n", slave, (u_char)byte);
KASSERT(sc->ich_cmd == -1,
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
- mtx_enter(&sc->mutex, MTX_DEF);
+ mtx_lock(&sc->mutex);
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE;
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
(slave << 1) | ICH_XMIT_SLVA_WRITE);
@@ -201,7 +201,7 @@ ichsmb_sendb(device_t dev, u_char slave, char byte)
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_CNT,
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
smb_error = ichsmb_wait(sc);
- mtx_exit(&sc->mutex, MTX_DEF);
+ mtx_unlock(&sc->mutex);
DBG("smb_error=%d\n", smb_error);
return (smb_error);
}
@@ -215,7 +215,7 @@ ichsmb_recvb(device_t dev, u_char slave, char *byte)
DBG("slave=0x%02x\n", slave);
KASSERT(sc->ich_cmd == -1,
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
- mtx_enter(&sc->mutex, MTX_DEF);
+ mtx_lock(&sc->mutex);
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE;
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
(slave << 1) | ICH_XMIT_SLVA_READ);
@@ -223,7 +223,7 @@ ichsmb_recvb(device_t dev, u_char slave, char *byte)
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR)
*byte = bus_space_read_1(sc->io_bst, sc->io_bsh, ICH_D0);
- mtx_exit(&sc->mutex, MTX_DEF);
+ mtx_unlock(&sc->mutex);
DBG("smb_error=%d byte=0x%02x\n", smb_error, (u_char)*byte);
return (smb_error);
}
@@ -238,7 +238,7 @@ ichsmb_writeb(device_t dev, u_char slave, char cmd, char byte)
slave, (u_char)cmd, (u_char)byte);
KASSERT(sc->ich_cmd == -1,
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
- mtx_enter(&sc->mutex, MTX_DEF);
+ mtx_lock(&sc->mutex);
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE_DATA;
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
(slave << 1) | ICH_XMIT_SLVA_WRITE);
@@ -247,7 +247,7 @@ ichsmb_writeb(device_t dev, u_char slave, char cmd, char byte)
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_CNT,
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
smb_error = ichsmb_wait(sc);
- mtx_exit(&sc->mutex, MTX_DEF);
+ mtx_unlock(&sc->mutex);
DBG("smb_error=%d\n", smb_error);
return (smb_error);
}
@@ -262,7 +262,7 @@ ichsmb_writew(device_t dev, u_char slave, char cmd, short word)
slave, (u_char)cmd, (u_int16_t)word);
KASSERT(sc->ich_cmd == -1,
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
- mtx_enter(&sc->mutex, MTX_DEF);
+ mtx_lock(&sc->mutex);
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_WORD_DATA;
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
(slave << 1) | ICH_XMIT_SLVA_WRITE);
@@ -272,7 +272,7 @@ ichsmb_writew(device_t dev, u_char slave, char cmd, short word)
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_CNT,
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
smb_error = ichsmb_wait(sc);
- mtx_exit(&sc->mutex, MTX_DEF);
+ mtx_unlock(&sc->mutex);
DBG("smb_error=%d\n", smb_error);
return (smb_error);
}
@@ -286,7 +286,7 @@ ichsmb_readb(device_t dev, u_char slave, char cmd, char *byte)
DBG("slave=0x%02x cmd=0x%02x\n", slave, (u_char)cmd);
KASSERT(sc->ich_cmd == -1,
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
- mtx_enter(&sc->mutex, MTX_DEF);
+ mtx_lock(&sc->mutex);
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE_DATA;
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
(slave << 1) | ICH_XMIT_SLVA_READ);
@@ -295,7 +295,7 @@ ichsmb_readb(device_t dev, u_char slave, char cmd, char *byte)
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR)
*byte = bus_space_read_1(sc->io_bst, sc->io_bsh, ICH_D0);
- mtx_exit(&sc->mutex, MTX_DEF);
+ mtx_unlock(&sc->mutex);
DBG("smb_error=%d byte=0x%02x\n", smb_error, (u_char)*byte);
return (smb_error);
}
@@ -309,7 +309,7 @@ ichsmb_readw(device_t dev, u_char slave, char cmd, short *word)
DBG("slave=0x%02x cmd=0x%02x\n", slave, (u_char)cmd);
KASSERT(sc->ich_cmd == -1,
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
- mtx_enter(&sc->mutex, MTX_DEF);
+ mtx_lock(&sc->mutex);
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_WORD_DATA;
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
(slave << 1) | ICH_XMIT_SLVA_READ);
@@ -322,7 +322,7 @@ ichsmb_readw(device_t dev, u_char slave, char cmd, short *word)
| (bus_space_read_1(sc->io_bst,
sc->io_bsh, ICH_D1) << 8);
}
- mtx_exit(&sc->mutex, MTX_DEF);
+ mtx_unlock(&sc->mutex);
DBG("smb_error=%d word=0x%04x\n", smb_error, (u_int16_t)*word);
return (smb_error);
}
@@ -337,7 +337,7 @@ ichsmb_pcall(device_t dev, u_char slave, char cmd, short sdata, short *rdata)
slave, (u_char)cmd, (u_int16_t)sdata);
KASSERT(sc->ich_cmd == -1,
("%s: ich_cmd=%d\n", __FUNCTION__ , sc->ich_cmd));
- mtx_enter(&sc->mutex, MTX_DEF);
+ mtx_lock(&sc->mutex);
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_PROC_CALL;
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
(slave << 1) | ICH_XMIT_SLVA_WRITE);
@@ -352,7 +352,7 @@ ichsmb_pcall(device_t dev, u_char slave, char cmd, short sdata, short *rdata)
| (bus_space_read_1(sc->io_bst,
sc->io_bsh, ICH_D1) << 8);
}
- mtx_exit(&sc->mutex, MTX_DEF);
+ mtx_unlock(&sc->mutex);
DBG("smb_error=%d rdata=0x%04x\n", smb_error, (u_int16_t)*rdata);
return (smb_error);
}
@@ -388,7 +388,7 @@ ichsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf)
sc->block_index = 1;
sc->block_write = 1;
- mtx_enter(&sc->mutex, MTX_DEF);
+ mtx_lock(&sc->mutex);
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BLOCK;
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
(slave << 1) | ICH_XMIT_SLVA_WRITE);
@@ -398,7 +398,7 @@ ichsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf)
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_CNT,
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
smb_error = ichsmb_wait(sc);
- mtx_exit(&sc->mutex, MTX_DEF);
+ mtx_unlock(&sc->mutex);
DBG("smb_error=%d\n", smb_error);
return (smb_error);
}
@@ -419,7 +419,7 @@ ichsmb_bread(device_t dev, u_char slave, char cmd, u_char count, char *buf)
sc->block_index = 0;
sc->block_write = 0;
- mtx_enter(&sc->mutex, MTX_DEF);
+ mtx_lock(&sc->mutex);
sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BLOCK;
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_XMIT_SLVA,
(slave << 1) | ICH_XMIT_SLVA_READ);
@@ -429,7 +429,7 @@ ichsmb_bread(device_t dev, u_char slave, char cmd, u_char count, char *buf)
ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd);
if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR)
bcopy(sc->block_data, buf, sc->block_count);
- mtx_exit(&sc->mutex, MTX_DEF);
+ mtx_unlock(&sc->mutex);
DBG("smb_error=%d\n", smb_error);
#if ICHSMB_DEBUG
#define DISP(ch) (((ch) < 0x20 || (ch) >= 0x7e) ? '.' : (ch))
@@ -491,7 +491,7 @@ ichsmb_device_intr(void *cookie)
int cmd_index;
int count;
- mtx_enter(&sc->mutex, MTX_DEF);
+ mtx_lock(&sc->mutex);
for (count = 0; count < maxloops; count++) {
/* Get and reset status bits */
@@ -603,7 +603,7 @@ finished:
/* Clear status bits and try again */
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_STA, status);
}
- mtx_exit(&sc->mutex, MTX_DEF);
+ mtx_unlock(&sc->mutex);
/* Too many loops? */
if (count == maxloops) {
diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c
index ecf9e71..72fb71b 100644
--- a/sys/dev/isp/isp_freebsd.c
+++ b/sys/dev/isp/isp_freebsd.c
@@ -1992,9 +1992,9 @@ isp_done(struct ccb_scsiio *sccb)
XS_CMD_S_CLEAR(sccb);
ISP_UNLOCK(isp);
#ifdef ISP_SMPLOCK
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
xpt_done((union ccb *) sccb);
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#else
xpt_done((union ccb *) sccb);
#endif
diff --git a/sys/dev/isp/isp_freebsd.h b/sys/dev/isp/isp_freebsd.h
index 3bdfb1d..d184b7b 100644
--- a/sys/dev/isp/isp_freebsd.h
+++ b/sys/dev/isp/isp_freebsd.h
@@ -124,8 +124,8 @@ struct isposinfo {
*/
#ifdef ISP_SMPLOCK
-#define ISP_LOCK(x) mtx_enter(&(x)->isp_osinfo.lock, MTX_DEF)
-#define ISP_UNLOCK(x) mtx_exit(&(x)->isp_osinfo.lock, MTX_DEF)
+#define ISP_LOCK(x) mtx_lock(&(x)->isp_osinfo.lock)
+#define ISP_UNLOCK(x) mtx_unlock(&(x)->isp_osinfo.lock)
#else
#define ISP_LOCK isp_lock
#define ISP_UNLOCK isp_unlock
diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c
index b45b7ce..02cc697 100644
--- a/sys/dev/pccbb/pccbb.c
+++ b/sys/dev/pccbb/pccbb.c
@@ -530,13 +530,13 @@ pccbb_detach(device_t dev)
if (error > 0)
return ENXIO;
- mtx_enter(&sc->sc_mtx, MTX_DEF);
+ mtx_lock(&sc->sc_mtx);
bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intrhand);
sc->sc_flags |= PCCBB_KTHREAD_DONE;
if (sc->sc_flags & PCCBB_KTHREAD_RUNNING) {
wakeup(sc);
- mtx_exit(&sc->sc_mtx, MTX_DEF);
+ mtx_unlock(&sc->sc_mtx);
DEVPRINTF((dev, "waiting for kthread exit..."));
error = tsleep(sc, PWAIT, "pccbb-detach-wait", 60 * hz);
if (error)
@@ -544,7 +544,7 @@ pccbb_detach(device_t dev)
else
DPRINTF(("done\n"));
} else
- mtx_exit(&sc->sc_mtx, MTX_DEF);
+ mtx_unlock(&sc->sc_mtx);
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res);
bus_release_resource(dev, SYS_RES_MEMORY, PCCBBR_SOCKBASE,
@@ -572,17 +572,17 @@ pccbb_driver_added(device_t dev, driver_t *driver)
sc->sc_cbdev = devlist[tmp];
if ((sc->sc_socketreg->socket_state
& PCCBB_SOCKET_STAT_CD) == 0) {
- mtx_enter(&sc->sc_mtx, MTX_DEF);
+ mtx_lock(&sc->sc_mtx);
wakeup(sc);
- mtx_exit(&sc->sc_mtx, MTX_DEF);
+ mtx_unlock(&sc->sc_mtx);
}
} else if (strcmp(driver->name, "pccard") == 0) {
sc->sc_pccarddev = devlist[tmp];
if ((sc->sc_socketreg->socket_state
& PCCBB_SOCKET_STAT_CD) == 0) {
- mtx_enter(&sc->sc_mtx, MTX_DEF);
+ mtx_lock(&sc->sc_mtx);
wakeup(sc);
- mtx_exit(&sc->sc_mtx, MTX_DEF);
+ mtx_unlock(&sc->sc_mtx);
}
} else
device_printf(dev,
@@ -616,7 +616,7 @@ pccbb_event_thread (void *arg)
struct pccbb_softc *sc = arg;
u_int32_t status;
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
for(;;) {
if (!(sc->sc_flags & PCCBB_KTHREAD_RUNNING))
sc->sc_flags |= PCCBB_KTHREAD_RUNNING;
@@ -629,7 +629,7 @@ pccbb_event_thread (void *arg)
*/
tsleep (&sc->sc_flags, PWAIT, "pccbbev", 1*hz);
}
- mtx_enter(&sc->sc_mtx, MTX_DEF);
+ mtx_lock(&sc->sc_mtx);
if (sc->sc_flags & PCCBB_KTHREAD_DONE)
break;
@@ -639,9 +639,9 @@ pccbb_event_thread (void *arg)
} else {
pccbb_removal(sc);
}
- mtx_exit(&sc->sc_mtx, MTX_DEF);
+ mtx_unlock(&sc->sc_mtx);
}
- mtx_exit(&sc->sc_mtx, MTX_DEF);
+ mtx_unlock(&sc->sc_mtx);
sc->sc_flags &= ~PCCBB_KTHREAD_RUNNING;
wakeup(sc);
kthread_exit(0);
@@ -744,9 +744,9 @@ pccbb_intr(void* arg)
sc->sc_socketreg->socket_event = sockevent | 0x01;
if (sockevent & PCCBB_SOCKET_EVENT_CD) {
- mtx_enter(&sc->sc_mtx, MTX_DEF);
+ mtx_lock(&sc->sc_mtx);
wakeup(sc);
- mtx_exit(&sc->sc_mtx, MTX_DEF);
+ mtx_unlock(&sc->sc_mtx);
} else {
if (sockevent & PCCBB_SOCKET_EVENT_CSTS) {
DPRINTF((" cstsevent occures, 0x%08x\n",
diff --git a/sys/dev/random/harvest.c b/sys/dev/random/harvest.c
index 60067dc..93ce35b 100644
--- a/sys/dev/random/harvest.c
+++ b/sys/dev/random/harvest.c
@@ -123,7 +123,7 @@ void
random_set_wakeup_exit(void *control)
{
wakeup(control);
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
kthread_exit(0);
/* NOTREACHED */
}
diff --git a/sys/dev/random/yarrow.c b/sys/dev/random/yarrow.c
index 816ab23..f1325e5 100644
--- a/sys/dev/random/yarrow.c
+++ b/sys/dev/random/yarrow.c
@@ -96,10 +96,10 @@ random_kthread(void *arg /* NOTUSED */)
struct source *source;
#ifdef DEBUG
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("OWNERSHIP Giant == %d sched_lock == %d\n",
mtx_owned(&Giant), mtx_owned(&sched_lock));
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
for (pl = 0; pl < 2; pl++)
@@ -114,11 +114,11 @@ random_kthread(void *arg /* NOTUSED */)
else {
#ifdef DEBUG1
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("HARVEST src=%d bits=%d/%d pool=%d count=%lld\n",
event->source, event->bits, event->frac,
event->pool, event->somecounter);
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
/* Suck the harvested entropy out of the queue and hash
@@ -160,9 +160,9 @@ random_kthread(void *arg /* NOTUSED */)
/* Is the thread scheduled for a shutdown? */
if (random_kthread_control != 0) {
#ifdef DEBUG
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("Random kthread setting terminate\n");
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
random_set_wakeup_exit(&random_kthread_control);
/* NOTREACHED */
@@ -179,9 +179,9 @@ random_init(void)
int error;
#ifdef DEBUG
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("Random initialise\n");
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
/* This can be turned off by the very paranoid
@@ -213,9 +213,9 @@ random_init(void)
random_init_harvester(random_harvest_internal, read_random_real);
#ifdef DEBUG
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("Random initialise finish\n");
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
return 0;
@@ -225,31 +225,31 @@ void
random_deinit(void)
{
#ifdef DEBUG
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("Random deinitialise\n");
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
/* Deregister the randomness harvesting routine */
random_deinit_harvester();
#ifdef DEBUG
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("Random deinitialise waiting for thread to terminate\n");
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
/* Command the hash/reseed thread to end and wait for it to finish */
- mtx_enter(&harvestring.lockout_mtx, MTX_DEF);
+ mtx_lock(&harvestring.lockout_mtx);
random_kthread_control = -1;
msleep((void *)&random_kthread_control, &harvestring.lockout_mtx, PUSER,
"rndend", 0);
- mtx_exit(&harvestring.lockout_mtx, MTX_DEF);
+ mtx_unlock(&harvestring.lockout_mtx);
#ifdef DEBUG
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("Random deinitialise removing mutexes\n");
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
/* Remove the mutexes */
@@ -257,9 +257,9 @@ random_deinit(void)
mtx_destroy(&harvestring.lockout_mtx);
#ifdef DEBUG
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("Random deinitialise finish\n");
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
}
@@ -276,13 +276,13 @@ reseed(int fastslow)
int i, j;
#ifdef DEBUG
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("Reseed type %d\n", fastslow);
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
/* The reseed task must not be jumped on */
- mtx_enter(&random_reseed_mtx, MTX_DEF);
+ mtx_lock(&random_reseed_mtx);
/* 1. Hash the accumulated entropy into v[0] */
@@ -353,12 +353,12 @@ reseed(int fastslow)
/* XXX Not done here yet */
/* Release the reseed mutex */
- mtx_exit(&random_reseed_mtx, MTX_DEF);
+ mtx_unlock(&random_reseed_mtx);
#ifdef DEBUG
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("Reseed finish\n");
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
if (!random_state.seeded) {
@@ -379,7 +379,7 @@ read_random_real(void *buf, u_int count)
u_int retval;
/* The reseed task must not be jumped on */
- mtx_enter(&random_reseed_mtx, MTX_DEF);
+ mtx_lock(&random_reseed_mtx);
if (gate) {
generator_gate();
@@ -423,7 +423,7 @@ read_random_real(void *buf, u_int count)
cur -= retval;
}
}
- mtx_exit(&random_reseed_mtx, MTX_DEF);
+ mtx_unlock(&random_reseed_mtx);
return retval;
}
@@ -462,9 +462,9 @@ generator_gate(void)
u_char temp[KEYSIZE];
#ifdef DEBUG
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("Generator gate\n");
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
for (i = 0; i < KEYSIZE; i += sizeof(random_state.counter)) {
@@ -477,9 +477,9 @@ generator_gate(void)
memset((void *)temp, 0, KEYSIZE);
#ifdef DEBUG
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("Generator gate finish\n");
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
}
@@ -495,16 +495,16 @@ random_harvest_internal(u_int64_t somecounter, void *entropy, u_int count,
int newhead, tail;
#ifdef DEBUG1
- mtx_enter(&Giant, MTX_DEF);
+ mtx_lock(&Giant);
printf("Random harvest\n");
- mtx_exit(&Giant, MTX_DEF);
+ mtx_unlock(&Giant);
#endif
if (origin < ENTROPYSOURCE) {
/* Add the harvested data to the ring buffer, but
* do not block.
*/
- if (mtx_try_enter(&harvestring.lockout_mtx, MTX_DEF)) {
+ if (mtx_trylock(&harvestring.lockout_mtx)) {
tail = atomic_load_acq_int(&harvestring.tail);
newhead = (harvestring.head + 1) % HARVEST_RING_SIZE;
@@ -533,7 +533,7 @@ random_harvest_internal(u_int64_t somecounter, void *entropy, u_int count,
wakeup(&harvestring.head);
}
- mtx_exit(&harvestring.lockout_mtx, MTX_DEF);
+ mtx_unlock(&harvestring.lockout_mtx);
}
diff --git a/sys/dev/sf/if_sfreg.h b/sys/dev/sf/if_sfreg.h
index c2dc20e..fd2107f 100644
--- a/sys/dev/sf/if_sfreg.h
+++ b/sys/dev/sf/if_sfreg.h
@@ -1048,8 +1048,8 @@ struct sf_softc {
};
-#define SF_LOCK(_sc) mtx_enter(&(_sc)->sf_mtx, MTX_DEF)
-#define SF_UNLOCK(_sc) mtx_exit(&(_sc)->sf_mtx, MTX_DEF)
+#define SF_LOCK(_sc) mtx_lock(&(_sc)->sf_mtx)
+#define SF_UNLOCK(_sc) mtx_unlock(&(_sc)->sf_mtx)
#define SF_TIMEOUT 1000
diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c
index 332ce49..be5f642 100644
--- a/sys/dev/sio/sio.c
+++ b/sys/dev/sio/sio.c
@@ -856,7 +856,7 @@ sioprobe(dev, xrid)
* but mask them in the processor as well in case there are some
* (misconfigured) shared interrupts.
*/
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
/* EXTRA DELAY? */
/*
@@ -953,7 +953,7 @@ sioprobe(dev, xrid)
CLR_FLAG(dev, COM_C_IIR_TXRDYBUG);
}
sio_setreg(com, com_cfcr, CFCR_8BITS);
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
return (iobase == siocniobase ? 0 : result);
}
@@ -993,7 +993,7 @@ sioprobe(dev, xrid)
irqmap[3] = isa_irq_pending();
failures[9] = (sio_getreg(com, com_iir) & IIR_IMASK) - IIR_NOPEND;
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
irqs = irqmap[1] & ~irqmap[0];
if (bus_get_resource(idev, SYS_RES_IRQ, 0, &xirq, NULL) == 0 &&
@@ -1181,7 +1181,7 @@ sioattach(dev, xrid)
} else
com->it_in.c_ispeed = com->it_in.c_ospeed = TTYDEF_SPEED;
if (siosetwater(com, com->it_in.c_ispeed) != 0) {
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
/*
* Leave i/o resources allocated if this is a `cn'-level
* console, so that other devices can't snarf them.
@@ -1190,7 +1190,7 @@ sioattach(dev, xrid)
bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
return (ENOMEM);
}
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
termioschars(&com->it_in);
com->it_out = com->it_in;
@@ -1485,7 +1485,7 @@ open_top:
}
}
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
(void) inb(com->line_status_port);
(void) inb(com->data_port);
com->prev_modem_status = com->last_modem_status
@@ -1497,7 +1497,7 @@ open_top:
outb(com->intr_ctl_port, IER_ERXRDY | IER_ETXRDY
| IER_ERLS | IER_EMSC);
}
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
/*
* Handle initial DCD. Callout devices get a fake initial
* DCD (trapdoor DCD). If we are callout, then any sleeping
@@ -1753,7 +1753,7 @@ sioinput(com)
* semantics instead of the save-and-disable semantics
* that are used everywhere else.
*/
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
incc = com->iptr - buf;
if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
&& (com->state & CS_RTS_IFLOW
@@ -1774,7 +1774,7 @@ sioinput(com)
tp->t_lflag &= ~FLUSHO;
comstart(tp);
}
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
} while (buf < com->iptr);
} else {
do {
@@ -1783,7 +1783,7 @@ sioinput(com)
* semantics instead of the save-and-disable semantics
* that are used everywhere else.
*/
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
line_status = buf[com->ierroff];
recv_data = *buf++;
if (line_status
@@ -1798,7 +1798,7 @@ sioinput(com)
recv_data |= TTY_PE;
}
(*linesw[tp->t_line].l_rint)(recv_data, tp);
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
} while (buf < com->iptr);
}
com_events -= (com->iptr - com->ibuf);
@@ -1823,9 +1823,9 @@ siointr(arg)
#ifndef COM_MULTIPORT
com = (struct com_s *)arg;
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
siointr1(com);
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
#else /* COM_MULTIPORT */
bool_t possibly_more_intrs;
int unit;
@@ -1837,7 +1837,7 @@ siointr(arg)
* devices, then the edge from one may be lost because another is
* on.
*/
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
do {
possibly_more_intrs = FALSE;
for (unit = 0; unit < sio_numunits; ++unit) {
@@ -1856,7 +1856,7 @@ siointr(arg)
/* XXX COM_UNLOCK(); */
}
} while (possibly_more_intrs);
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
#endif /* COM_MULTIPORT */
}
@@ -2264,7 +2264,7 @@ repeat:
* Discard any events related to never-opened or
* going-away devices.
*/
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
incc = com->iptr - com->ibuf;
com->iptr = com->ibuf;
if (com->state & CS_CHECKMSR) {
@@ -2272,33 +2272,33 @@ repeat:
com->state &= ~CS_CHECKMSR;
}
com_events -= incc;
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
continue;
}
if (com->iptr != com->ibuf) {
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
sioinput(com);
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
}
if (com->state & CS_CHECKMSR) {
u_char delta_modem_status;
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
delta_modem_status = com->last_modem_status
^ com->prev_modem_status;
com->prev_modem_status = com->last_modem_status;
com_events -= LOTS_OF_EVENTS;
com->state &= ~CS_CHECKMSR;
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
if (delta_modem_status & MSR_DCD)
(*linesw[tp->t_line].l_modem)
(tp, com->prev_modem_status & MSR_DCD);
}
if (com->state & CS_ODONE) {
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
com_events -= LOTS_OF_EVENTS;
com->state &= ~CS_ODONE;
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
if (!(com->state & CS_BUSY)
&& !(com->extra_state & CSE_BUSYCHECK)) {
timeout(siobusycheck, com, hz / 100);
@@ -2484,7 +2484,7 @@ comparam(tp, t)
if (com->state >= (CS_BUSY | CS_TTGO))
siointr1(com);
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
splx(s);
comstart(tp);
if (com->ibufold != NULL) {
@@ -2518,7 +2518,7 @@ siosetwater(com, speed)
for (ibufsize = 128; ibufsize < cp4ticks;)
ibufsize <<= 1;
if (ibufsize == com->ibufsize) {
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
return (0);
}
@@ -2528,7 +2528,7 @@ siosetwater(com, speed)
*/
ibuf = malloc(2 * ibufsize, M_DEVBUF, M_NOWAIT);
if (ibuf == NULL) {
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
return (ENOMEM);
}
@@ -2546,7 +2546,7 @@ siosetwater(com, speed)
* Read current input buffer, if any. Continue with interrupts
* disabled.
*/
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
if (com->iptr != com->ibuf)
sioinput(com);
@@ -2581,7 +2581,7 @@ comstart(tp)
if (com == NULL)
return;
s = spltty();
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
if (tp->t_state & TS_TTSTOP)
com->state &= ~CS_TTGO;
else
@@ -2594,7 +2594,7 @@ comstart(tp)
&& com->state & CS_RTS_IFLOW)
outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
}
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
ttwwakeup(tp);
splx(s);
@@ -2610,7 +2610,7 @@ comstart(tp)
sizeof com->obuf1);
com->obufs[0].l_next = NULL;
com->obufs[0].l_queued = TRUE;
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
if (com->state & CS_BUSY) {
qp = com->obufq.l_next;
while ((next = qp->l_next) != NULL)
@@ -2622,7 +2622,7 @@ comstart(tp)
com->obufq.l_next = &com->obufs[0];
com->state |= CS_BUSY;
}
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
}
if (tp->t_outq.c_cc != 0 && !com->obufs[1].l_queued) {
com->obufs[1].l_tail
@@ -2630,7 +2630,7 @@ comstart(tp)
sizeof com->obuf2);
com->obufs[1].l_next = NULL;
com->obufs[1].l_queued = TRUE;
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
if (com->state & CS_BUSY) {
qp = com->obufq.l_next;
while ((next = qp->l_next) != NULL)
@@ -2642,14 +2642,14 @@ comstart(tp)
com->obufq.l_next = &com->obufs[1];
com->state |= CS_BUSY;
}
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
}
tp->t_state |= TS_BUSY;
}
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
if (com->state >= (CS_BUSY | CS_TTGO))
siointr1(com); /* fake interrupt to start output */
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
ttwwakeup(tp);
splx(s);
}
@@ -2664,7 +2664,7 @@ comstop(tp, rw)
com = com_addr(DEV_TO_UNIT(tp->t_dev));
if (com == NULL || com->gone)
return;
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
if (rw & FWRITE) {
if (com->hasfifo)
#ifdef COM_ESP
@@ -2691,7 +2691,7 @@ comstop(tp, rw)
com_events -= (com->iptr - com->ibuf);
com->iptr = com->ibuf;
}
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
comstart(tp);
}
@@ -2734,7 +2734,7 @@ commctl(com, bits, how)
mcr |= MCR_RTS;
if (com->gone)
return(0);
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
switch (how) {
case DMSET:
outb(com->modem_ctl_port,
@@ -2747,7 +2747,7 @@ commctl(com, bits, how)
outb(com->modem_ctl_port, com->mcr_image &= ~mcr);
break;
}
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
return (0);
}
@@ -2806,9 +2806,9 @@ comwakeup(chan)
com = com_addr(unit);
if (com != NULL && !com->gone
&& (com->state >= (CS_BUSY | CS_TTGO) || com->poll)) {
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
siointr1(com);
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
}
}
@@ -2830,10 +2830,10 @@ comwakeup(chan)
u_int delta;
u_long total;
- mtx_enter(&sio_lock, MTX_SPIN);
+ mtx_lock_spin(&sio_lock);
delta = com->delta_error_counts[errnum];
com->delta_error_counts[errnum] = 0;
- mtx_exit(&sio_lock, MTX_SPIN);
+ mtx_unlock_spin(&sio_lock);
if (delta == 0)
continue;
total = com->error_counts[errnum] += delta;
diff --git a/sys/dev/sk/if_skreg.h b/sys/dev/sk/if_skreg.h
index 6f31d1d..061707c 100644
--- a/sys/dev/sk/if_skreg.h
+++ b/sys/dev/sk/if_skreg.h
@@ -1182,10 +1182,10 @@ struct sk_softc {
struct mtx sk_mtx;
};
-#define SK_LOCK(_sc) mtx_enter(&(_sc)->sk_mtx, MTX_DEF)
-#define SK_UNLOCK(_sc) mtx_exit(&(_sc)->sk_mtx, MTX_DEF)
-#define SK_IF_LOCK(_sc) mtx_enter(&(_sc)->sk_softc->sk_mtx, MTX_DEF)
-#define SK_IF_UNLOCK(_sc) mtx_exit(&(_sc)->sk_softc->sk_mtx, MTX_DEF)
+#define SK_LOCK(_sc) mtx_lock(&(_sc)->sk_mtx)
+#define SK_UNLOCK(_sc) mtx_unlock(&(_sc)->sk_mtx)
+#define SK_IF_LOCK(_sc) mtx_lock(&(_sc)->sk_softc->sk_mtx)
+#define SK_IF_UNLOCK(_sc) mtx_unlock(&(_sc)->sk_softc->sk_mtx)
/* Softc for each logical interface */
struct sk_if_softc {
diff --git a/sys/dev/ti/if_tireg.h b/sys/dev/ti/if_tireg.h
index 0eaff14..df399be 100644
--- a/sys/dev/ti/if_tireg.h
+++ b/sys/dev/ti/if_tireg.h
@@ -1147,8 +1147,8 @@ struct ti_softc {
struct mtx ti_mtx;
};
-#define TI_LOCK(_sc) mtx_enter(&(_sc)->ti_mtx, MTX_DEF)
-#define TI_UNLOCK(_sc) mtx_exit(&(_sc)->ti_mtx, MTX_DEF)
+#define TI_LOCK(_sc) mtx_lock(&(_sc)->ti_mtx)
+#define TI_UNLOCK(_sc) mtx_unlock(&(_sc)->ti_mtx)
/*
* Microchip Technology 24Cxx EEPROM control bytes
diff --git a/sys/dev/usb/if_auereg.h b/sys/dev/usb/if_auereg.h
index 5558b50..5544091 100644
--- a/sys/dev/usb/if_auereg.h
+++ b/sys/dev/usb/if_auereg.h
@@ -249,8 +249,8 @@ struct aue_softc {
struct mtx aue_mtx;
};
-#define AUE_LOCK(_sc) mtx_enter(&(_sc)->aue_mtx, MTX_DEF)
-#define AUE_UNLOCK(_sc) mtx_exit(&(_sc)->aue_mtx, MTX_DEF)
+#define AUE_LOCK(_sc) mtx_lock(&(_sc)->aue_mtx)
+#define AUE_UNLOCK(_sc) mtx_unlock(&(_sc)->aue_mtx)
#define AUE_TIMEOUT 1000
#define ETHER_ALIGN 2
diff --git a/sys/dev/usb/if_cuereg.h b/sys/dev/usb/if_cuereg.h
index 5d043e4..dc7b8c8 100644
--- a/sys/dev/usb/if_cuereg.h
+++ b/sys/dev/usb/if_cuereg.h
@@ -182,5 +182,5 @@ struct cue_softc {
struct mtx cue_mtx;
};
-#define CUE_LOCK(_sc) mtx_enter(&(_sc)->cue_mtx, MTX_DEF)
-#define CUE_UNLOCK(_sc) mtx_exit(&(_sc)->cue_mtx, MTX_DEF)
+#define CUE_LOCK(_sc) mtx_lock(&(_sc)->cue_mtx)
+#define CUE_UNLOCK(_sc) mtx_unlock(&(_sc)->cue_mtx)
diff --git a/sys/dev/usb/if_kuereg.h b/sys/dev/usb/if_kuereg.h
index 49cd235..b5ffb32 100644
--- a/sys/dev/usb/if_kuereg.h
+++ b/sys/dev/usb/if_kuereg.h
@@ -173,5 +173,5 @@ struct kue_softc {
struct mtx kue_mtx;
};
-#define KUE_LOCK(_sc) mtx_enter(&(_sc)->kue_mtx, MTX_DEF)
-#define KUE_UNLOCK(_sc) mtx_exit(&(_sc)->kue_mtx, MTX_DEF)
+#define KUE_LOCK(_sc) mtx_lock(&(_sc)->kue_mtx)
+#define KUE_UNLOCK(_sc) mtx_unlock(&(_sc)->kue_mtx)
diff --git a/sys/dev/vinum/vinumdaemon.c b/sys/dev/vinum/vinumdaemon.c
index 99c1751..f03d36b 100644
--- a/sys/dev/vinum/vinumdaemon.c
+++ b/sys/dev/vinum/vinumdaemon.c
@@ -72,9 +72,9 @@ vinum_daemon(void)
PROC_LOCK(curproc);
curproc->p_flag |= P_SYSTEM; /* we're a system process */
PROC_UNLOCK(curproc);
- mtx_enter(&sched_lock, MTX_SPIN);
+ mtx_lock_spin(&sched_lock);
curproc->p_sflag |= PS_INMEM;
- mtx_exit(&sched_lock, MTX_SPIN);
+ mtx_unlock_spin(&sched_lock);
daemon_save_config(); /* start by saving the configuration */
daemonpid = curproc->p_pid; /* mark our territory */
while (1) {
diff --git a/sys/dev/vinum/vinumlock.c b/sys/dev/vinum/vinumlock.c
index c85fbae..801f13f 100644
--- a/sys/dev/vinum/vinumlock.c
+++ b/sys/dev/vinum/vinumlock.c
@@ -132,7 +132,7 @@ lockrange(daddr_t stripe, struct buf *bp, struct plex *plex)
* increment all addresses by 1.
*/
stripe++;
- mtx_enter(&plex->lockmtx, MTX_DEF);
+ mtx_lock(&plex->lockmtx);
/* Wait here if the table is full */
while (plex->usedlocks == PLEX_LOCKS) /* all in use */
@@ -187,7 +187,7 @@ lockrange(daddr_t stripe, struct buf *bp, struct plex *plex)
pos->stripe = stripe;
pos->bp = bp;
plex->usedlocks++; /* one more lock */
- mtx_exit(&plex->lockmtx, MTX_DEF);
+ mtx_unlock(&plex->lockmtx);
#ifdef VINUMDEBUG
if (debug & DEBUG_LASTREQS)
logrq(loginfo_lock, (union rqinfou) pos, bp);
diff --git a/sys/dev/vr/if_vrreg.h b/sys/dev/vr/if_vrreg.h
index 8217a8c..235962d 100644
--- a/sys/dev/vr/if_vrreg.h
+++ b/sys/dev/vr/if_vrreg.h
@@ -414,8 +414,8 @@ struct vr_softc {
struct mtx vr_mtx;
};
-#define VR_LOCK(_sc) mtx_enter(&(_sc)->vr_mtx, MTX_DEF)
-#define VR_UNLOCK(_sc) mtx_exit(&(_sc)->vr_mtx, MTX_DEF)
+#define VR_LOCK(_sc) mtx_lock(&(_sc)->vr_mtx)
+#define VR_UNLOCK(_sc) mtx_unlock(&(_sc)->vr_mtx)
/*
* register space access macros
diff --git a/sys/dev/wi/if_wireg.h b/sys/dev/wi/if_wireg.h
index eb4ab7c..9751029 100644
--- a/sys/dev/wi/if_wireg.h
+++ b/sys/dev/wi/if_wireg.h
@@ -128,8 +128,8 @@ struct wi_softc {
int wi_prism2; /* set to 1 if it uses a Prism II chip */
};
-#define WI_LOCK(_sc) mtx_enter(&(_sc)->wi_mtx, MTX_DEF)
-#define WI_UNLOCK(_sc) mtx_exit(&(_sc)->wi_mtx, MTX_DEF)
+#define WI_LOCK(_sc) mtx_lock(&(_sc)->wi_mtx)
+#define WI_UNLOCK(_sc) mtx_unlock(&(_sc)->wi_mtx)
#define WI_TIMEOUT 65536
OpenPOWER on IntegriCloud