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 <kra...@redhat.com> --- hw/usb.c | 5 +++++ hw/usb.h | 2 ++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/hw/usb.c b/hw/usb.c index 9f44565..73b3ec2 100644 --- a/hw/usb.c +++ b/hw/usb.c @@ -409,10 +409,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; diff --git a/hw/usb.h b/hw/usb.h index 2c834d7..5202f3c 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -169,6 +169,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; -- 1.7.1