From: mpi Date: Sun, 10 Aug 2014 11:00:35 +0000 (+0000) Subject: Set and check for XFER_BUSY in the common methods instead of doing it X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=79234da18a06ebd26b4a298d9308dba6b4cdfd8d;p=openbsd Set and check for XFER_BUSY in the common methods instead of doing it in every HC driver. --- diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c index 7f051acd48e..e6efccd425c 100644 --- a/sys/dev/usb/ehci.c +++ b/sys/dev/usb/ehci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ehci.c,v 1.164 2014/08/05 20:26:15 mpi Exp $ */ +/* $OpenBSD: ehci.c,v 1.165 2014/08/10 11:00:35 mpi Exp $ */ /* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */ /* @@ -1172,10 +1172,8 @@ ehci_allocx(struct usbd_bus *bus) ex = pool_get(ehcixfer, PR_NOWAIT | PR_ZERO); #ifdef DIAGNOSTIC - if (ex != NULL) { + if (ex != NULL) ex->isdone = 1; - ex->xfer.busy_free = XFER_BUSY; - } #endif return ((struct usbd_xfer *)ex); } @@ -1186,11 +1184,6 @@ ehci_freex(struct usbd_bus *bus, struct usbd_xfer *xfer) struct ehci_xfer *ex = (struct ehci_xfer*)xfer; #ifdef DIAGNOSTIC - if (xfer->busy_free != XFER_BUSY) { - printf("%s: xfer=%p not busy, 0x%08x\n", __func__, xfer, - xfer->busy_free); - return; - } if (!ex->isdone) { printf("%s: !isdone\n", __func__); return; diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index f0cc91b23b8..18637bc1f04 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ohci.c,v 1.137 2014/08/05 20:26:15 mpi Exp $ */ +/* $OpenBSD: ohci.c,v 1.138 2014/08/10 11:00:36 mpi Exp $ */ /* $NetBSD: ohci.c,v 1.139 2003/02/22 05:24:16 tsutsui Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */ @@ -938,30 +938,13 @@ ohci_init(struct ohci_softc *sc) struct usbd_xfer * ohci_allocx(struct usbd_bus *bus) { - struct ohci_xfer *ox; - - ox = pool_get(ohcixfer, PR_NOWAIT | PR_ZERO); -#ifdef DIAGNOSTIC - if (ox != NULL) { - ox->xfer.busy_free = XFER_BUSY; - } -#endif - return ((struct usbd_xfer *)ox); + return (pool_get(ohcixfer, PR_NOWAIT | PR_ZERO)); } void ohci_freex(struct usbd_bus *bus, struct usbd_xfer *xfer) { - struct ohci_xfer *ox = (struct ohci_xfer*)xfer; - -#ifdef DIAGNOSTIC - if (xfer->busy_free != XFER_BUSY) { - printf("%s: xfer=%p not busy, 0x%08x\n", __func__, xfer, - xfer->busy_free); - return; - } -#endif - pool_put(ohcixfer, ox); + pool_put(ohcixfer, xfer); } #ifdef OHCI_DEBUG diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index 4836ecec6c5..f52c07d7707 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhci.c,v 1.129 2014/08/05 20:26:15 mpi Exp $ */ +/* $OpenBSD: uhci.c,v 1.130 2014/08/10 11:00:36 mpi Exp $ */ /* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -586,10 +586,8 @@ uhci_allocx(struct usbd_bus *bus) ux = pool_get(uhcixfer, PR_NOWAIT | PR_ZERO); #ifdef DIAGNOSTIC - if (ux != NULL) { + if (ux != NULL) ux->isdone = 1; - ux->xfer.busy_free = XFER_BUSY; - } #endif return ((struct usbd_xfer *)ux); } @@ -600,11 +598,6 @@ uhci_freex(struct usbd_bus *bus, struct usbd_xfer *xfer) struct uhci_xfer *ux = (struct uhci_xfer*)xfer; #ifdef DIAGNOSTIC - if (xfer->busy_free != XFER_BUSY) { - printf("%s: xfer=%p not busy, 0x%08x\n", __func__, xfer, - xfer->busy_free); - return; - } if (!ux->isdone) { printf("%s: !isdone\n", __func__); return; diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index c83218b2db4..7478c5983a3 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi.c,v 1.71 2014/07/12 18:48:53 tedu Exp $ */ +/* $OpenBSD: usbdi.c,v 1.72 2014/08/10 11:00:36 mpi Exp $ */ /* $NetBSD: usbdi.c,v 1.103 2002/09/27 15:37:38 provos Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */ @@ -395,6 +395,9 @@ usbd_alloc_xfer(struct usbd_device *dev) xfer = dev->bus->methods->allocx(dev->bus); if (xfer == NULL) return (NULL); +#ifdef DIAGNOSTIC + xfer->busy_free = XFER_BUSY; +#endif xfer->device = dev; timeout_set(&xfer->timeout_handle, NULL, NULL); DPRINTFN(5,("usbd_alloc_xfer() = %p\n", xfer)); @@ -407,8 +410,14 @@ usbd_free_xfer(struct usbd_xfer *xfer) DPRINTFN(5,("usbd_free_xfer: %p\n", xfer)); if (xfer->rqflags & (URQ_DEV_DMABUF | URQ_AUTO_DMABUF)) usbd_free_buffer(xfer); +#ifdef DIAGNOSTIC + if (xfer->busy_free != XFER_BUSY) { + printf("%s: xfer=%p not busy, 0x%08x\n", __func__, xfer, + xfer->busy_free); + return; + } +#endif xfer->device->bus->methods->freex(xfer->device->bus, xfer); - return; } void diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c index 1af29e5ac04..a799818a8ea 100644 --- a/sys/dev/usb/xhci.c +++ b/sys/dev/usb/xhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xhci.c,v 1.21 2014/08/09 10:32:36 mpi Exp $ */ +/* $OpenBSD: xhci.c,v 1.22 2014/08/10 11:00:36 mpi Exp $ */ /* * Copyright (c) 2014 Martin Pieuchot @@ -1168,29 +1168,13 @@ xhci_pipe_close(struct usbd_pipe *pipe) struct usbd_xfer * xhci_allocx(struct usbd_bus *bus) { - struct xhci_xfer *xx; - - xx = pool_get(xhcixfer, PR_NOWAIT | PR_ZERO); -#ifdef DIAGNOSTIC - if (xx != NULL) - xx->xfer.busy_free = XFER_BUSY; -#endif - return ((struct usbd_xfer *)xx); + return (pool_get(xhcixfer, PR_NOWAIT | PR_ZERO)); } void xhci_freex(struct usbd_bus *bus, struct usbd_xfer *xfer) { - struct xhci_xfer *xx = (struct xhci_xfer*)xfer; - -#ifdef DIAGNOSTIC - if (xfer->busy_free != XFER_BUSY) { - printf("%s: xfer=%p not busy, 0x%08x\n", __func__, xfer, - xfer->busy_free); - return; - } -#endif - pool_put(xhcixfer, xx); + pool_put(xhcixfer, xfer); } int