aboutsummaryrefslogtreecommitdiff
path: root/hw/usb/core.c
diff options
context:
space:
mode:
authorLiam Merwick <liam.merwick@oracle.com>2019-02-06 13:36:48 +0000
committerGerd Hoffmann <kraxel@redhat.com>2019-02-20 09:41:23 +0100
commit56090d78a799015adadde759ee5de9e7b292126a (patch)
tree91f3f31dbb60932f8fb6565f111e85fb60b86bb2 /hw/usb/core.c
parent2e68b8620637a4ee8c79b5724144b726af1e261b (diff)
usb: rearrange usb_ep_get()
There is no need to calculate the 'eps' variable in usb_ep_get() if 'ep' is the control endpoint. Instead the calculation should be done after validating the input before returning an entry indexed by the endpoint 'ep'. Signed-off-by: Liam Merwick <liam.merwick@oracle.com> Reviewed-by: Darren Kenny <Darren.Kenny@oracle.com> Reviewed-by: Mark Kanda <Mark.Kanda@oracle.com> Reviewed-by: Ameya More <ameya.more@oracle.com> Message-id: 1549460216-25808-2-git-send-email-liam.merwick@oracle.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb/core.c')
-rw-r--r--hw/usb/core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/usb/core.c b/hw/usb/core.c
index 241ae66b15..bfb7ae67bb 100644
--- a/hw/usb/core.c
+++ b/hw/usb/core.c
@@ -720,12 +720,12 @@ struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep)
if (dev == NULL) {
return NULL;
}
- eps = (pid == USB_TOKEN_IN) ? dev->ep_in : dev->ep_out;
if (ep == 0) {
return &dev->ep_ctl;
}
assert(pid == USB_TOKEN_IN || pid == USB_TOKEN_OUT);
assert(ep > 0 && ep <= USB_MAX_ENDPOINTS);
+ eps = (pid == USB_TOKEN_IN) ? dev->ep_in : dev->ep_out;
return eps + ep - 1;
}