summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-12-14 14:35:42 +0100
committerGerd Hoffmann <kraxel@redhat.com>2013-01-07 12:57:24 +0100
commit7e9638d3eb5c0b4c5920dac72bb2e6885652c029 (patch)
tree6d25e4dcb8c9ded4391e6005e1d19b74f8f8b7a0
parentf8c126f329892ec8941e5bbe6ba411d78cfc66cb (diff)
downloadqemu-7e9638d3eb5c0b4c5920dac72bb2e6885652c029.tar.gz
qemu-7e9638d3eb5c0b4c5920dac72bb2e6885652c029.tar.bz2
qemu-7e9638d3eb5c0b4c5920dac72bb2e6885652c029.zip
usbredir: Add USBEP2I and I2USBEP helper macros
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r--hw/usb/redirect.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index c5704c176a..0ffcc7db48 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -44,6 +44,11 @@
#define NO_INTERFACE_INFO 255 /* Valid interface_count always <= 32 */
#define EP2I(ep_address) (((ep_address & 0x80) >> 3) | (ep_address & 0x0f))
#define I2EP(i) (((i & 0x10) << 3) | (i & 0x0f))
+#define USBEP2I(usb_ep) (((usb_ep)->pid == USB_TOKEN_IN) ? \
+ ((usb_ep)->nr | 0x10) : ((usb_ep)->nr))
+#define I2USBEP(d, i) (usb_ep_get(&(d)->dev, \
+ ((i) & 0x10) ? USB_TOKEN_IN : USB_TOKEN_OUT, \
+ (i) & 0x0f))
typedef struct USBRedirDevice USBRedirDevice;
@@ -1351,11 +1356,10 @@ static void usbredir_set_pipeline(USBRedirDevice *dev, struct USBEndpoint *uep)
static void usbredir_setup_usb_eps(USBRedirDevice *dev)
{
struct USBEndpoint *usb_ep;
- int i, pid;
+ int i;
for (i = 0; i < MAX_ENDPOINTS; i++) {
- pid = (i & 0x10) ? USB_TOKEN_IN : USB_TOKEN_OUT;
- usb_ep = usb_ep_get(&dev->dev, pid, i & 0x0f);
+ usb_ep = I2USBEP(dev, i);
usb_ep->type = dev->endpoint[i].type;
usb_ep->ifnum = dev->endpoint[i].interface;
usb_ep->max_packet_size = dev->endpoint[i].max_packet_size;