[SeaBIOS] [PATCH 07/11] xhci: Change xhci_update_pipe() to xhci_realloc_pipe() and use for alloc too
Kevin O'Connor
kevin at koconnor.net
Thu Oct 16 22:22:59 CEST 2014
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 at koconnor.net>
---
src/hw/usb-xhci.c | 12 +++++++++---
src/hw/usb-xhci.h | 8 +++-----
src/hw/usb.c | 4 ++--
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c
index 0b8ed64..3bcc465 100644
--- a/src/hw/usb-xhci.c
+++ b/src/hw/usb-xhci.c
@@ -972,7 +972,7 @@ 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)
{
@@ -1077,11 +1077,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);
diff --git a/src/hw/usb-xhci.h b/src/hw/usb-xhci.h
index 7639409..807d597 100644
--- a/src/hw/usb-xhci.h
+++ b/src/hw/usb-xhci.h
@@ -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);
diff --git a/src/hw/usb.c b/src/hw/usb.c
index f7d5502..1fb5051 100644
--- a/src/hw/usb.c
+++ b/src/hw/usb.c
@@ -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);
--
1.9.3
More information about the SeaBIOS
mailing list