]> xenbits.xensource.com Git - people/andrewcoop/seabios.git/commitdiff
usb: Clarify usb freelist manipulations
authorKevin O'Connor <kevin@koconnor.net>
Thu, 16 Oct 2014 16:31:42 +0000 (12:31 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 16 Oct 2014 18:46:38 +0000 (14:46 -0400)
Rename usb_getFreePipe() to usb_get_freelist().  Add usb_is_freelist()
and usb_add_freelist() functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/hw/usb-ehci.c
src/hw/usb-ohci.c
src/hw/usb-uhci.c
src/hw/usb.c
src/hw/usb.h

index 2376b1fb1bd8aa983fba4528268ca3787a9927fe..1df7ec877097776b8018f0ea20ccfdd3d0d412ad 100644 (file)
@@ -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);
index a91e24d7f70eb394c8245a3448f03e9ea4d98f3d..d19b667d053eaab6c5b0dd07042150b510026585 100644 (file)
@@ -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);
index a270a82b8997da3bcfa42caa43d1e2038c3cfbbc..e940d917ba4b5dd038c1c5ff12ee4cbc8fedac5a 100644 (file)
@@ -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);
index c7cb674b750e7849380270cbbe52c0778df534a3..f7d550205f01a2dfec1f2d23857ebfe8ed2f7ef8 100644 (file)
@@ -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
index e6948de0880545519ab8e742e35b0b727fbd6fda..8e3e60a077a18c068636228f8c7f662c60af221c 100644 (file)
@@ -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