usb: native_posix: Fix ep_configure() and ep_mps()

Fix issues found in unit tests.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2019-02-07 15:03:30 +02:00 committed by Anas Nashif
commit bd7d48a61f

View file

@ -188,13 +188,22 @@ int usb_dc_ep_check_cap(const struct usb_dc_ep_cfg_data * const cfg)
int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data * const cfg)
{
LOG_DBG("ep %x, mps %d, type %d", cfg->ep_addr, cfg->ep_mps,
cfg->ep_type);
u16_t ep_mps = cfg->ep_mps;
u8_t ep = cfg->ep_addr;
u8_t ep_idx = USBIP_EP_ADDR2IDX(ep);
if (!usbip_ctrl.attached && !usbip_ep_is_valid(cfg->ep_addr)) {
LOG_DBG("ep %x, mps %d, type %d", ep, ep_mps, cfg->ep_type);
if (!usbip_ctrl.attached && !usbip_ep_is_valid(ep)) {
return -EINVAL;
}
if (USBIP_EP_ADDR2DIR(ep) == USB_EP_DIR_OUT) {
usbip_ctrl.out_ep_ctrl[ep_idx].mps = ep_mps;
} else {
usbip_ctrl.in_ep_ctrl[ep_idx].mps = ep_mps;
}
return 0;
}
@ -459,6 +468,12 @@ int usb_dc_ep_mps(const u8_t ep)
{
u8_t ep_idx = USBIP_EP_ADDR2IDX(ep);
LOG_DBG("ep %x", ep);
if (!usbip_ep_is_valid(ep)) {
return -EINVAL;
}
if (USBIP_EP_ADDR2DIR(ep) == USB_EP_DIR_OUT) {
return usbip_ctrl.out_ep_ctrl[ep_idx].mps;
} else {