aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hw/usb-ehci.c4
-rw-r--r--src/hw/usb-ohci.c4
-rw-r--r--src/hw/usb-uhci.c4
-rw-r--r--src/hw/usb.c25
-rw-r--r--src/hw/usb.h4
5 files changed, 29 insertions, 12 deletions
diff --git a/src/hw/usb-ehci.c b/src/hw/usb-ehci.c
index 2376b1f..1df7ec8 100644
--- a/src/hw/usb-ehci.c
+++ b/src/hw/usb-ehci.c
@@ -195,7 +195,7 @@ ehci_free_pipes(struct usb_ehci_s *cntl)
if (next == start)
break;
struct ehci_pipe *pipe = container_of(next, struct ehci_pipe, qh);
- if (pipe->pipe.cntl != &cntl->usb)
+ if (usb_is_freelist(&cntl->usb, &pipe->pipe))
pos->next = next->next;
else
pos = next;
@@ -457,7 +457,7 @@ ehci_alloc_pipe(struct usbdevice_s *usbdev
usbdev->hub->cntl, struct usb_ehci_s, usb);
dprintf(7, "ehci_alloc_async_pipe %p %d\n", &cntl->usb, eptype);
- struct usb_pipe *usbpipe = usb_getFreePipe(&cntl->usb, eptype);
+ struct usb_pipe *usbpipe = usb_get_freelist(&cntl->usb, eptype);
if (usbpipe) {
// Use previously allocated pipe.
struct ehci_pipe *pipe = container_of(usbpipe, struct ehci_pipe, pipe);
diff --git a/src/hw/usb-ohci.c b/src/hw/usb-ohci.c
index a91e24d..d19b667 100644
--- a/src/hw/usb-ohci.c
+++ b/src/hw/usb-ohci.c
@@ -152,7 +152,7 @@ ohci_free_pipes(struct usb_ohci_s *cntl)
if (!next)
break;
struct ohci_pipe *pipe = container_of(next, struct ohci_pipe, ed);
- if (pipe->pipe.cntl != &cntl->usb) {
+ if (usb_is_freelist(&cntl->usb, &pipe->pipe)) {
*pos = next->hwNextED;
free(pipe);
} else {
@@ -403,7 +403,7 @@ ohci_alloc_pipe(struct usbdevice_s *usbdev
usbdev->hub->cntl, struct usb_ohci_s, usb);
dprintf(7, "ohci_alloc_async_pipe %p\n", &cntl->usb);
- struct usb_pipe *usbpipe = usb_getFreePipe(&cntl->usb, eptype);
+ struct usb_pipe *usbpipe = usb_get_freelist(&cntl->usb, eptype);
if (usbpipe) {
// Use previously allocated pipe.
struct ohci_pipe *pipe = container_of(usbpipe, struct ohci_pipe, pipe);
diff --git a/src/hw/usb-uhci.c b/src/hw/usb-uhci.c
index a270a82..e940d91 100644
--- a/src/hw/usb-uhci.c
+++ b/src/hw/usb-uhci.c
@@ -138,7 +138,7 @@ uhci_free_pipes(struct usb_uhci_s *cntl)
break;
struct uhci_qh *next = (void*)(link & ~UHCI_PTR_BITS);
struct uhci_pipe *pipe = container_of(next, struct uhci_pipe, qh);
- if (pipe->pipe.cntl != &cntl->usb)
+ if (usb_is_freelist(&cntl->usb, &pipe->pipe))
pos->link = next->link;
else
pos = next;
@@ -364,7 +364,7 @@ uhci_alloc_pipe(struct usbdevice_s *usbdev
usbdev->hub->cntl, struct usb_uhci_s, usb);
dprintf(7, "uhci_alloc_async_pipe %p %d\n", &cntl->usb, eptype);
- struct usb_pipe *usbpipe = usb_getFreePipe(&cntl->usb, eptype);
+ struct usb_pipe *usbpipe = usb_get_freelist(&cntl->usb, eptype);
if (usbpipe) {
// Use previously allocated pipe.
usb_desc2pipe(usbpipe, usbdev, epdesc);
diff --git a/src/hw/usb.c b/src/hw/usb.c
index c7cb674..f7d5502 100644
--- a/src/hw/usb.c
+++ b/src/hw/usb.c
@@ -132,14 +132,19 @@ usb_send_default_control(struct usb_pipe *pipe, const struct usb_ctrlrequest *re
, req, sizeof(*req), data, req->wLength);
}
-// Free an allocated control or bulk pipe.
+// Check if a pipe for a given controller is on the freelist
+int
+usb_is_freelist(struct usb_s *cntl, struct usb_pipe *pipe)
+{
+ return pipe->cntl != cntl;
+}
+
+// Add a pipe to the controller's freelist
void
-usb_free_pipe(struct usbdevice_s *usbdev, struct usb_pipe *pipe)
+usb_add_freelist(struct usb_pipe *pipe)
{
- ASSERT32FLAT();
if (!pipe)
return;
- // Add to controller's free list.
struct usb_s *cntl = pipe->cntl;
pipe->freenext = cntl->freelist;
cntl->freelist = pipe;
@@ -147,7 +152,7 @@ usb_free_pipe(struct usbdevice_s *usbdev, struct usb_pipe *pipe)
// Check for an available pipe on the freelist.
struct usb_pipe *
-usb_getFreePipe(struct usb_s *cntl, u8 eptype)
+usb_get_freelist(struct usb_s *cntl, u8 eptype)
{
struct usb_pipe **pfree = &cntl->freelist;
for (;;) {
@@ -162,6 +167,16 @@ usb_getFreePipe(struct usb_s *cntl, u8 eptype)
}
}
+// Free an allocated control or bulk pipe.
+void
+usb_free_pipe(struct usbdevice_s *usbdev, struct usb_pipe *pipe)
+{
+ ASSERT32FLAT();
+ if (!pipe)
+ return;
+ usb_add_freelist(pipe);
+}
+
// Fill "pipe" endpoint info from an endpoint descriptor.
void
usb_desc2pipe(struct usb_pipe *pipe, struct usbdevice_s *usbdev
diff --git a/src/hw/usb.h b/src/hw/usb.h
index e6948de..8e3e60a 100644
--- a/src/hw/usb.h
+++ b/src/hw/usb.h
@@ -235,8 +235,10 @@ int usb_poll_intr(struct usb_pipe *pipe, void *data);
int usb_32bit_pipe(struct usb_pipe *pipe_fl);
int usb_send_default_control(struct usb_pipe *pipe
, const struct usb_ctrlrequest *req, void *data);
+int usb_is_freelist(struct usb_s *cntl, struct usb_pipe *pipe);
+void usb_add_freelist(struct usb_pipe *pipe);
+struct usb_pipe *usb_get_freelist(struct usb_s *cntl, u8 eptype);
void usb_free_pipe(struct usbdevice_s *usbdev, struct usb_pipe *pipe);
-struct usb_pipe *usb_getFreePipe(struct usb_s *cntl, u8 eptype);
void usb_desc2pipe(struct usb_pipe *pipe, struct usbdevice_s *usbdev
, struct usb_endpoint_descriptor *epdesc);
int usb_get_period(struct usbdevice_s *usbdev