From 4565300d5658c6fb6e38ed0f7d849cb782984e3c Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Sun, 5 Apr 2009 18:21:21 +0000 Subject: [PATCH] MFp4 //depot/projects/usb@159946 Some cancelable flags are always true. Substitute these away. These cancelable flags were mostly useful with the root HUB which is now handled differently. Submitted by: Hans Petter Selasky --- sys/dev/usb/controller/at91dci.c | 8 ---- sys/dev/usb/controller/atmegadci.c | 4 -- sys/dev/usb/controller/ehci.c | 10 ----- sys/dev/usb/controller/musb_otg.c | 8 ---- sys/dev/usb/controller/ohci.c | 8 ---- sys/dev/usb/controller/uhci.c | 8 ---- sys/dev/usb/controller/uss820dci.c | 8 ---- sys/dev/usb/usb_controller.h | 13 ++---- sys/dev/usb/usb_transfer.c | 66 +++++++++++++----------------- 9 files changed, 32 insertions(+), 101 deletions(-) diff --git a/sys/dev/usb/controller/at91dci.c b/sys/dev/usb/controller/at91dci.c index b855a5b6265f..af3eb5a903b8 100644 --- a/sys/dev/usb/controller/at91dci.c +++ b/sys/dev/usb/controller/at91dci.c @@ -1499,8 +1499,6 @@ struct usb2_pipe_methods at91dci_device_bulk_methods = .close = at91dci_device_bulk_close, .enter = at91dci_device_bulk_enter, .start = at91dci_device_bulk_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -1538,8 +1536,6 @@ struct usb2_pipe_methods at91dci_device_ctrl_methods = .close = at91dci_device_ctrl_close, .enter = at91dci_device_ctrl_enter, .start = at91dci_device_ctrl_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -1577,8 +1573,6 @@ struct usb2_pipe_methods at91dci_device_intr_methods = .close = at91dci_device_intr_close, .enter = at91dci_device_intr_enter, .start = at91dci_device_intr_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -1661,8 +1655,6 @@ struct usb2_pipe_methods at91dci_device_isoc_fs_methods = .close = at91dci_device_isoc_fs_close, .enter = at91dci_device_isoc_fs_enter, .start = at91dci_device_isoc_fs_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* diff --git a/sys/dev/usb/controller/atmegadci.c b/sys/dev/usb/controller/atmegadci.c index ddb72d94f668..dcb66be656fd 100644 --- a/sys/dev/usb/controller/atmegadci.c +++ b/sys/dev/usb/controller/atmegadci.c @@ -1376,8 +1376,6 @@ struct usb2_pipe_methods atmegadci_device_non_isoc_methods = .close = atmegadci_device_non_isoc_close, .enter = atmegadci_device_non_isoc_enter, .start = atmegadci_device_non_isoc_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -1464,8 +1462,6 @@ struct usb2_pipe_methods atmegadci_device_isoc_fs_methods = .close = atmegadci_device_isoc_fs_close, .enter = atmegadci_device_isoc_fs_enter, .start = atmegadci_device_isoc_fs_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* diff --git a/sys/dev/usb/controller/ehci.c b/sys/dev/usb/controller/ehci.c index 09793bbc7e46..fe7bf702cc66 100644 --- a/sys/dev/usb/controller/ehci.c +++ b/sys/dev/usb/controller/ehci.c @@ -2210,8 +2210,6 @@ struct usb2_pipe_methods ehci_device_bulk_methods = .close = ehci_device_bulk_close, .enter = ehci_device_bulk_enter, .start = ehci_device_bulk_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -2253,8 +2251,6 @@ struct usb2_pipe_methods ehci_device_ctrl_methods = .close = ehci_device_ctrl_close, .enter = ehci_device_ctrl_enter, .start = ehci_device_ctrl_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -2351,8 +2347,6 @@ struct usb2_pipe_methods ehci_device_intr_methods = .close = ehci_device_intr_close, .enter = ehci_device_intr_enter, .start = ehci_device_intr_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -2636,8 +2630,6 @@ struct usb2_pipe_methods ehci_device_isoc_fs_methods = .close = ehci_device_isoc_fs_close, .enter = ehci_device_isoc_fs_enter, .start = ehci_device_isoc_fs_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -2904,8 +2896,6 @@ struct usb2_pipe_methods ehci_device_isoc_hs_methods = .close = ehci_device_isoc_hs_close, .enter = ehci_device_isoc_hs_enter, .start = ehci_device_isoc_hs_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* diff --git a/sys/dev/usb/controller/musb_otg.c b/sys/dev/usb/controller/musb_otg.c index f16d47e5785b..ca87eaf4165c 100644 --- a/sys/dev/usb/controller/musb_otg.c +++ b/sys/dev/usb/controller/musb_otg.c @@ -1899,8 +1899,6 @@ struct usb2_pipe_methods musbotg_device_bulk_methods = .close = musbotg_device_bulk_close, .enter = musbotg_device_bulk_enter, .start = musbotg_device_bulk_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -1938,8 +1936,6 @@ struct usb2_pipe_methods musbotg_device_ctrl_methods = .close = musbotg_device_ctrl_close, .enter = musbotg_device_ctrl_enter, .start = musbotg_device_ctrl_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -1977,8 +1973,6 @@ struct usb2_pipe_methods musbotg_device_intr_methods = .close = musbotg_device_intr_close, .enter = musbotg_device_intr_enter, .start = musbotg_device_intr_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -2068,8 +2062,6 @@ struct usb2_pipe_methods musbotg_device_isoc_methods = .close = musbotg_device_isoc_close, .enter = musbotg_device_isoc_enter, .start = musbotg_device_isoc_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* diff --git a/sys/dev/usb/controller/ohci.c b/sys/dev/usb/controller/ohci.c index 114311d3b4b6..c41225348e4e 100644 --- a/sys/dev/usb/controller/ohci.c +++ b/sys/dev/usb/controller/ohci.c @@ -1720,8 +1720,6 @@ struct usb2_pipe_methods ohci_device_bulk_methods = .close = ohci_device_bulk_close, .enter = ohci_device_bulk_enter, .start = ohci_device_bulk_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -1763,8 +1761,6 @@ struct usb2_pipe_methods ohci_device_ctrl_methods = .close = ohci_device_ctrl_close, .enter = ohci_device_ctrl_enter, .start = ohci_device_ctrl_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -1837,8 +1833,6 @@ struct usb2_pipe_methods ohci_device_intr_methods = .close = ohci_device_intr_close, .enter = ohci_device_intr_enter, .start = ohci_device_intr_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -2047,8 +2041,6 @@ struct usb2_pipe_methods ohci_device_isoc_methods = .close = ohci_device_isoc_close, .enter = ohci_device_isoc_enter, .start = ohci_device_isoc_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* diff --git a/sys/dev/usb/controller/uhci.c b/sys/dev/usb/controller/uhci.c index 1b96b7c4f078..59e29867d412 100644 --- a/sys/dev/usb/controller/uhci.c +++ b/sys/dev/usb/controller/uhci.c @@ -1940,8 +1940,6 @@ struct usb2_pipe_methods uhci_device_bulk_methods = .close = uhci_device_bulk_close, .enter = uhci_device_bulk_enter, .start = uhci_device_bulk_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -2004,8 +2002,6 @@ struct usb2_pipe_methods uhci_device_ctrl_methods = .close = uhci_device_ctrl_close, .enter = uhci_device_ctrl_enter, .start = uhci_device_ctrl_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -2095,8 +2091,6 @@ struct usb2_pipe_methods uhci_device_intr_methods = .close = uhci_device_intr_close, .enter = uhci_device_intr_enter, .start = uhci_device_intr_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -2305,8 +2299,6 @@ struct usb2_pipe_methods uhci_device_isoc_methods = .close = uhci_device_isoc_close, .enter = uhci_device_isoc_enter, .start = uhci_device_isoc_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* diff --git a/sys/dev/usb/controller/uss820dci.c b/sys/dev/usb/controller/uss820dci.c index 0009664d5620..2cd04c1a16b7 100644 --- a/sys/dev/usb/controller/uss820dci.c +++ b/sys/dev/usb/controller/uss820dci.c @@ -1542,8 +1542,6 @@ struct usb2_pipe_methods uss820dci_device_bulk_methods = .close = uss820dci_device_bulk_close, .enter = uss820dci_device_bulk_enter, .start = uss820dci_device_bulk_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -1581,8 +1579,6 @@ struct usb2_pipe_methods uss820dci_device_ctrl_methods = .close = uss820dci_device_ctrl_close, .enter = uss820dci_device_ctrl_enter, .start = uss820dci_device_ctrl_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -1620,8 +1616,6 @@ struct usb2_pipe_methods uss820dci_device_intr_methods = .close = uss820dci_device_intr_close, .enter = uss820dci_device_intr_enter, .start = uss820dci_device_intr_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* @@ -1704,8 +1698,6 @@ struct usb2_pipe_methods uss820dci_device_isoc_fs_methods = .close = uss820dci_device_isoc_fs_close, .enter = uss820dci_device_isoc_fs_enter, .start = uss820dci_device_isoc_fs_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, }; /*------------------------------------------------------------------------* diff --git a/sys/dev/usb/usb_controller.h b/sys/dev/usb/usb_controller.h index 16adbbd6aad5..c1a2e634ff99 100644 --- a/sys/dev/usb/usb_controller.h +++ b/sys/dev/usb/usb_controller.h @@ -108,20 +108,15 @@ struct usb2_pipe_methods { /* Mandatory USB Device and Host mode callbacks: */ - void (*open) (struct usb2_xfer *xfer); - void (*close) (struct usb2_xfer *xfer); + usb2_callback_t *open; + usb2_callback_t *close; - void (*enter) (struct usb2_xfer *xfer); - void (*start) (struct usb2_xfer *xfer); + usb2_callback_t *enter; + usb2_callback_t *start; /* Optional */ void *info; - - /* Flags */ - - uint8_t enter_is_cancelable:1; - uint8_t start_is_cancelable:1; }; /* diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c index 4ffc03f6c1ef..160f8245d8a3 100644 --- a/sys/dev/usb/usb_transfer.c +++ b/sys/dev/usb/usb_transfer.c @@ -1541,18 +1541,14 @@ usb2_pipe_enter(struct usb2_xfer *xfer) /* enter the transfer */ (pipe->methods->enter) (xfer); - /* check cancelability */ - if (pipe->methods->enter_is_cancelable) { - xfer->flags_int.can_cancel_immed = 1; - /* check for transfer error */ - if (xfer->error) { - /* some error has happened */ - usb2_transfer_done(xfer, 0); - USB_BUS_UNLOCK(xfer->xroot->bus); - return; - } - } else { - xfer->flags_int.can_cancel_immed = 0; + xfer->flags_int.can_cancel_immed = 1; + + /* check for transfer error */ + if (xfer->error) { + /* some error has happened */ + usb2_transfer_done(xfer, 0); + USB_BUS_UNLOCK(xfer->xroot->bus); + return; } /* start the transfer */ @@ -1866,8 +1862,8 @@ usb2_callback_wrapper(struct usb2_xfer_queue *pq) struct usb2_xfer *xfer = pq->curr; struct usb2_xfer_root *info = xfer->xroot; - USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); - if (!mtx_owned(xfer->xroot->xfer_mtx)) { + USB_BUS_LOCK_ASSERT(info->bus, MA_OWNED); + if (!mtx_owned(info->xfer_mtx)) { /* * Cases that end up here: * @@ -1898,22 +1894,22 @@ usb2_callback_wrapper(struct usb2_xfer_queue *pq) /* get next USB transfer in the queue */ info->done_q.curr = NULL; - USB_BUS_UNLOCK(xfer->xroot->bus); - USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_NOTOWNED); + USB_BUS_UNLOCK(info->bus); + USB_BUS_LOCK_ASSERT(info->bus, MA_NOTOWNED); /* set correct USB state for callback */ if (!xfer->flags_int.transferring) { xfer->usb2_state = USB_ST_SETUP; if (!xfer->flags_int.started) { /* we got stopped before we even got started */ - USB_BUS_LOCK(xfer->xroot->bus); + USB_BUS_LOCK(info->bus); goto done; } } else { if (usb2_callback_wrapper_sub(xfer)) { /* the callback has been deferred */ - USB_BUS_LOCK(xfer->xroot->bus); + USB_BUS_LOCK(info->bus); goto done; } #if USB_HAVE_POWERD @@ -1941,7 +1937,7 @@ usb2_callback_wrapper(struct usb2_xfer_queue *pq) (xfer->callback) (xfer); /* pickup the USB mutex again */ - USB_BUS_LOCK(xfer->xroot->bus); + USB_BUS_LOCK(info->bus); /* * Check if we got started after that we got cancelled, but @@ -1963,7 +1959,7 @@ usb2_callback_wrapper(struct usb2_xfer_queue *pq) (!xfer->flags_int.transferring)) { /* "usb2_transfer_drain()" is waiting for end of transfer */ xfer->flags_int.draining = 0; - usb2_cv_broadcast(&xfer->xroot->cv_drain); + usb2_cv_broadcast(&info->cv_drain); } /* do the next callback, if any */ @@ -2122,15 +2118,12 @@ usb2_transfer_start_cb(void *arg) /* start the transfer */ (pipe->methods->start) (xfer); - /* check cancelability */ - if (pipe->methods->start_is_cancelable) { - xfer->flags_int.can_cancel_immed = 1; - if (xfer->error) { - /* some error has happened */ - usb2_transfer_done(xfer, 0); - } - } else { - xfer->flags_int.can_cancel_immed = 0; + xfer->flags_int.can_cancel_immed = 1; + + /* check for error */ + if (xfer->error) { + /* some error has happened */ + usb2_transfer_done(xfer, 0); } } @@ -2276,15 +2269,12 @@ usb2_pipe_start(struct usb2_xfer_queue *pq) /* start USB transfer */ (pipe->methods->start) (xfer); - /* check cancelability */ - if (pipe->methods->start_is_cancelable) { - xfer->flags_int.can_cancel_immed = 1; - if (xfer->error) { - /* some error has happened */ - usb2_transfer_done(xfer, 0); - } - } else { - xfer->flags_int.can_cancel_immed = 0; + xfer->flags_int.can_cancel_immed = 1; + + /* check for error */ + if (xfer->error) { + /* some error has happened */ + usb2_transfer_done(xfer, 0); } }