svn commit: r227814 - head/sys/dev/ppbus

Attilio Rao attilio at FreeBSD.org
Tue Nov 22 11:35:25 UTC 2011


Author: attilio
Date: Tue Nov 22 11:35:24 2011
New Revision: 227814
URL: http://svn.freebsd.org/changeset/base/227814

Log:
  - Use ppb_assert_locked() rather than using explicit mtx_assert call
  - Make ppbus code agnostic in regard of INVARIANTS option
  
  MFC after:	2 weeks

Modified:
  head/sys/dev/ppbus/lpt.c
  head/sys/dev/ppbus/ppb_base.c
  head/sys/dev/ppbus/ppb_msq.c
  head/sys/dev/ppbus/vpo.c

Modified: head/sys/dev/ppbus/lpt.c
==============================================================================
--- head/sys/dev/ppbus/lpt.c	Tue Nov 22 06:56:45 2011	(r227813)
+++ head/sys/dev/ppbus/lpt.c	Tue Nov 22 11:35:24 2011	(r227814)
@@ -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) {

Modified: head/sys/dev/ppbus/ppb_base.c
==============================================================================
--- head/sys/dev/ppbus/ppb_base.c	Tue Nov 22 06:56:45 2011	(r227813)
+++ head/sys/dev/ppbus/ppb_base.c	Tue Nov 22 11:35:24 2011	(r227814)
@@ -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 l
 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);
 

Modified: head/sys/dev/ppbus/ppb_msq.c
==============================================================================
--- head/sys/dev/ppbus/ppb_msq.c	Tue Nov 22 06:56:45 2011	(r227813)
+++ head/sys/dev/ppbus/ppb_msq.c	Tue Nov 22 11:35:24 2011	(r227814)
@@ -117,13 +117,10 @@ mode2xfer(device_t bus, struct ppb_devic
 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);

Modified: head/sys/dev/ppbus/vpo.c
==============================================================================
--- head/sys/dev/ppbus/vpo.c	Tue Nov 22 06:56:45 2011	(r227813)
+++ head/sys/dev/ppbus/vpo.c	Tue Nov 22 11:35:24 2011	(r227814)
@@ -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:
 	{


More information about the svn-src-head mailing list