From c427deff961c022d06bc3527e37dea654393e5cb Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 16 Oct 2014 13:23:08 -0400 Subject: xhci: Change xhci_update_pipe() to xhci_realloc_pipe() and use for alloc too 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 --- src/hw/usb-xhci.c | 14 +++++++++----- src/hw/usb-xhci.h | 8 +++----- src/hw/usb.c | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src/hw') diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c index 0b8ed64..d6caa77 100644 --- a/src/hw/usb-xhci.c +++ b/src/hw/usb-xhci.c @@ -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); 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); -- cgit v1.1