From 0966143d780d669d8208ab2ac77254fb20f779d2 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 2 Oct 2013 07:00:17 +0200
Subject: [PATCH 5/8] usb: add usb_update_pipe()
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
Message-id: <1380697219-1860-6-git-send-email-kraxel@redhat.com>
Patchwork-id: 54632
O-Subject: [RHEL-7 seabios PATCH 5/7] usb: add usb_update_pipe()
Bugzilla: 947051
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Bandan Das <bsd@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
Preparation for better xhci support: allows to notify host controllers
instead of going through a free+alloc cycle.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 63cbab1628dc406ed5d765bd85bae3a1a525a2c0)
---
src/usb.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
src/usb.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/usb.c b/src/usb.c
index 421d0b8..3efa367 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -40,6 +40,18 @@ usb_alloc_pipe(struct usbdevice_s *usbdev
}
}
+// Update an pipe (used for control only)
+struct usb_pipe *
+usb_update_pipe(struct usbdevice_s *usbdev, struct usb_pipe *pipe
+ , struct usb_endpoint_descriptor *epdesc)
+{
+ switch (usbdev->hub->cntl->type) {
+ default:
+ free_pipe(pipe);
+ return usb_alloc_pipe(usbdev, epdesc);
+ }
+}
+
// Send a message on a control pipe using the default control descriptor.
static int
send_control(struct usb_pipe *pipe, int dir, const void *cmd, int cmdsize
@@ -258,15 +270,16 @@ usb_set_address(struct usbdevice_s *usbdev)
req.wIndex = 0;
req.wLength = 0;
int ret = send_default_control(usbdev->defpipe, &req, NULL);
- free_pipe(usbdev->defpipe);
- if (ret)
+ if (ret) {
+ free_pipe(usbdev->defpipe);
return -1;
+ }
msleep(USB_TIME_SETADDR_RECOVERY);
cntl->maxaddr++;
usbdev->devaddr = cntl->maxaddr;
- usbdev->defpipe = usb_alloc_pipe(usbdev, &epdesc);
+ usbdev->defpipe = usb_update_pipe(usbdev, usbdev->defpipe, &epdesc);
if (!usbdev->defpipe)
return -1;
return 0;
@@ -290,12 +303,11 @@ configure_usb_device(struct usbdevice_s *usbdev)
, dinfo.bDeviceProtocol, dinfo.bMaxPacketSize0);
if (dinfo.bMaxPacketSize0 < 8 || dinfo.bMaxPacketSize0 > 64)
return 0;
- free_pipe(usbdev->defpipe);
struct usb_endpoint_descriptor epdesc = {
.wMaxPacketSize = dinfo.bMaxPacketSize0,
.bmAttributes = USB_ENDPOINT_XFER_CONTROL,
};
- usbdev->defpipe = usb_alloc_pipe(usbdev, &epdesc);
+ usbdev->defpipe = usb_update_pipe(usbdev, usbdev->defpipe, &epdesc);
if (!usbdev->defpipe)
return -1;
--
1.7.1