usb: add USBEndpoint->{nr,pid}
authorGerd Hoffmann <kraxel@redhat.com>
Thu, 12 Jan 2012 12:24:22 +0000 (13:24 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 10 Feb 2012 10:31:57 +0000 (11:31 +0100)
Add a "nr" and "pid" fields to USBEndpoint so you can easily figure the
endpoint number and direction of any given endpoint.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb.c
hw/usb.h

index 8584db0decd5c301b75f844929786ac14b901a25..8bd1222ccdfedd2e388a51fdd14727f87981c12d 100644 (file)
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -402,10 +402,15 @@ void usb_ep_init(USBDevice *dev)
 {
     int ep;
 
+    dev->ep_ctl.nr = 0;
     dev->ep_ctl.type = USB_ENDPOINT_XFER_CONTROL;
     dev->ep_ctl.ifnum = 0;
     dev->ep_ctl.dev = dev;
     for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++) {
+        dev->ep_in[ep].nr = ep + 1;
+        dev->ep_out[ep].nr = ep + 1;
+        dev->ep_in[ep].pid = USB_TOKEN_IN;
+        dev->ep_out[ep].pid = USB_TOKEN_OUT;
         dev->ep_in[ep].type = USB_ENDPOINT_XFER_INVALID;
         dev->ep_out[ep].type = USB_ENDPOINT_XFER_INVALID;
         dev->ep_in[ep].ifnum = 0;
index 4e878d350ad901e6ae202a9b72e03f29405c43ef..1e629af682475e3adaa9e5f28fd018561b6d6315 100644 (file)
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -171,6 +171,8 @@ struct USBDescString {
 #define USB_MAX_INTERFACES 16
 
 struct USBEndpoint {
+    uint8_t nr;
+    uint8_t pid;
     uint8_t type;
     uint8_t ifnum;
     int max_packet_size;