提交 56090d78 编写于 作者: L Liam Merwick 提交者: Gerd Hoffmann

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: NLiam Merwick <liam.merwick@oracle.com>
Reviewed-by: NDarren Kenny <Darren.Kenny@oracle.com>
Reviewed-by: NMark Kanda <Mark.Kanda@oracle.com>
Reviewed-by: NAmeya More <ameya.more@oracle.com>
Message-id: 1549460216-25808-2-git-send-email-liam.merwick@oracle.com
Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
上级 2e68b862
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册