- Use ppb_assert_locked() rather than using explicit mtx_assert call

- Make ppbus code agnostic in regard of INVARIANTS option

MFC after:	2 weeks
This commit is contained in:
Attilio Rao 2011-11-22 11:35:24 +00:00
parent 623b87d8f4
commit b373cc4263
4 changed files with 12 additions and 34 deletions

View File

@ -447,10 +447,9 @@ lptout(void *arg)
{
struct lpt_data *sc = arg;
device_t dev = sc->sc_dev;
#if defined(INVARIANTS) || defined(LPT_DEBUG)
device_t ppbus = device_get_parent(dev);
#endif
device_t ppbus;
ppbus = device_get_parent(dev);
ppb_assert_locked(ppbus);
lprintf(("T %x ", ppb_rstr(ppbus)));
if (sc->sc_state & OPEN) {

View File

@ -60,7 +60,7 @@ ppb_poll_bus(device_t bus, int max,
int i, j, error;
char r;
mtx_assert(ppb->ppc_lock, MA_OWNED);
ppb_assert_locked(bus);
/* try at least up to 10ms */
for (j = 0; j < ((how & PPB_POLL) ? max : 1); j++) {
@ -96,12 +96,9 @@ ppb_poll_bus(device_t bus, int max,
int
ppb_get_epp_protocol(device_t bus)
{
#ifdef INVARIANTS
struct ppb_data *ppb = DEVTOSOFTC(bus);
#endif
uintptr_t protocol;
mtx_assert(ppb->ppc_lock, MA_OWNED);
ppb_assert_locked(bus);
BUS_READ_IVAR(device_get_parent(bus), bus, PPC_IVAR_EPP_PROTO, &protocol);
return (protocol);
@ -117,7 +114,7 @@ ppb_get_mode(device_t bus)
struct ppb_data *ppb = DEVTOSOFTC(bus);
/* XXX yet device mode = ppbus mode = chipset mode */
mtx_assert(ppb->ppc_lock, MA_OWNED);
ppb_assert_locked(bus);
return (ppb->mode);
}
@ -132,7 +129,7 @@ ppb_set_mode(device_t bus, int mode)
struct ppb_data *ppb = DEVTOSOFTC(bus);
int old_mode = ppb_get_mode(bus);
mtx_assert(ppb->ppc_lock, MA_OWNED);
ppb_assert_locked(bus);
if (PPBUS_SETMODE(device_get_parent(bus), mode))
return (-1);
@ -150,11 +147,8 @@ ppb_set_mode(device_t bus, int mode)
int
ppb_write(device_t bus, char *buf, int len, int how)
{
#ifdef INVARIANTS
struct ppb_data *ppb = DEVTOSOFTC(bus);
#endif
mtx_assert(ppb->ppc_lock, MA_OWNED);
ppb_assert_locked(bus);
return (PPBUS_WRITE(device_get_parent(bus), buf, len, how));
}
@ -166,11 +160,8 @@ ppb_write(device_t bus, char *buf, int len, int how)
int
ppb_reset_epp_timeout(device_t bus)
{
#ifdef INVARIANTS
struct ppb_data *ppb = DEVTOSOFTC(bus);
#endif
mtx_assert(ppb->ppc_lock, MA_OWNED);
ppb_assert_locked(bus);
return(PPBUS_RESET_EPP(device_get_parent(bus)));
}
@ -182,11 +173,8 @@ ppb_reset_epp_timeout(device_t bus)
int
ppb_ecp_sync(device_t bus)
{
#ifdef INVARIANTS
struct ppb_data *ppb = DEVTOSOFTC(bus);
#endif
mtx_assert(ppb->ppc_lock, MA_OWNED);
ppb_assert_locked(bus);
return (PPBUS_ECP_SYNC(device_get_parent(bus)));
}
@ -198,12 +186,9 @@ ppb_ecp_sync(device_t bus)
int
ppb_get_status(device_t bus, struct ppb_status *status)
{
#ifdef INVARIANTS
struct ppb_data *ppb = DEVTOSOFTC(bus);
#endif
register char r;
mtx_assert(ppb->ppc_lock, MA_OWNED);
ppb_assert_locked(bus);
r = status->status = ppb_rstr(bus);

View File

@ -117,13 +117,10 @@ mode2xfer(device_t bus, struct ppb_device *ppbdev, int opcode)
int
ppb_MS_init(device_t bus, device_t dev, struct ppb_microseq *loop, int opcode)
{
#ifdef INVARIANTS
struct ppb_data *ppb = device_get_softc(bus);
#endif
struct ppb_device *ppbdev = (struct ppb_device *)device_get_ivars(dev);
struct ppb_xfer *xfer = mode2xfer(bus, ppbdev, opcode);
mtx_assert(ppb->ppc_lock, MA_OWNED);
ppb_assert_locked(bus);
xfer->loop = loop;
return (0);

View File

@ -298,11 +298,8 @@ static void
vpo_action(struct cam_sim *sim, union ccb *ccb)
{
struct vpo_data *vpo = (struct vpo_data *)sim->softc;
#ifdef INVARIANTS
device_t ppbus = device_get_parent(vpo->vpo_dev);
ppb_assert_locked(ppbus);
#endif
ppb_assert_locked(device_get_parent(vpo->vpo_dev));
switch (ccb->ccb_h.func_code) {
case XPT_SCSI_IO:
{