]> xenbits.xensource.com Git - seabios.git/commitdiff
xhci: Change xhci_update_pipe() to xhci_realloc_pipe() and use for alloc too
authorKevin O'Connor <kevin@koconnor.net>
Thu, 16 Oct 2014 17:23:08 +0000 (13:23 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 16 Oct 2014 20:30:10 +0000 (16:30 -0400)
Instead of exporting both xhci_alloc_pipe() and xhci_update_pipe(),
export only xhci_realloc_pipe() and support alloc, update, and free
from it.

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

index 0b8ed641dd1f9542ab3f77e316c3535c47a2730b..d6caa77bd987396d55005862731da02a8aa265b6 100644 (file)
@@ -972,12 +972,10 @@ static int xhci_config_hub(struct usbhub_s *hub)
     return 0;
 }
 
-struct usb_pipe *
+static struct usb_pipe *
 xhci_alloc_pipe(struct usbdevice_s *usbdev
                 , struct usb_endpoint_descriptor *epdesc)
 {
-    if (!CONFIG_USB_XHCI)
-        return NULL;
     u8 eptype = epdesc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
     struct usb_xhci_s *xhci = container_of(
         usbdev->hub->cntl, struct usb_xhci_s, usb);
@@ -1077,11 +1075,17 @@ fail:
 }
 
 struct usb_pipe *
-xhci_update_pipe(struct usbdevice_s *usbdev, struct usb_pipe *upipe
-                , struct usb_endpoint_descriptor *epdesc)
+xhci_realloc_pipe(struct usbdevice_s *usbdev, struct usb_pipe *upipe
+                  , struct usb_endpoint_descriptor *epdesc)
 {
     if (!CONFIG_USB_XHCI)
         return NULL;
+    if (!epdesc) {
+        usb_add_freelist(upipe);
+        return NULL;
+    }
+    if (!upipe)
+        return xhci_alloc_pipe(usbdev, epdesc);
     u8 eptype = epdesc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
     int oldmaxpacket = upipe->maxpacket;
     usb_desc2pipe(upipe, usbdev, epdesc);
index 7639409bd6d855063ee742a81a2e92a16cb354d3..807d59752ff9f2949db343ccef1d65de8f7d7891 100644 (file)
@@ -9,11 +9,9 @@ struct usb_pipe;
 
 // usb-xhci.c
 void xhci_setup(void);
-struct usb_pipe *xhci_alloc_pipe(struct usbdevice_s *usbdev
-                                 , struct usb_endpoint_descriptor *epdesc);
-struct usb_pipe *xhci_update_pipe(struct usbdevice_s *usbdev
-                                  , struct usb_pipe *pipe
-                                  , struct usb_endpoint_descriptor *epdesc);
+struct usb_pipe *xhci_realloc_pipe(struct usbdevice_s *usbdev
+                                   , struct usb_pipe *upipe
+                                   , struct usb_endpoint_descriptor *epdesc);
 int xhci_send_control(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
                       , void *data, int datasize);
 int xhci_send_bulk(struct usb_pipe *p, int dir, void *data, int datasize);
index f7d550205f01a2dfec1f2d23857ebfe8ed2f7ef8..1fb5051303851436e4d03d333fd60827ae3840cf 100644 (file)
@@ -40,7 +40,7 @@ usb_alloc_pipe(struct usbdevice_s *usbdev
     case USB_TYPE_EHCI:
         return ehci_alloc_pipe(usbdev, epdesc);
     case USB_TYPE_XHCI:
-        return xhci_alloc_pipe(usbdev, epdesc);
+        return xhci_realloc_pipe(usbdev, NULL, epdesc);
     }
 }
 
@@ -51,7 +51,7 @@ usb_update_pipe(struct usbdevice_s *usbdev, struct usb_pipe *pipe
 {
     switch (usbdev->hub->cntl->type) {
     case USB_TYPE_XHCI:
-        return xhci_update_pipe(usbdev, pipe, epdesc);
+        return xhci_realloc_pipe(usbdev, pipe, epdesc);
     default:
         usb_free_pipe(usbdev, pipe);
         return usb_alloc_pipe(usbdev, epdesc);