diff --git a/drivers/usb/device/usb_dc_native_posix.c b/drivers/usb/device/usb_dc_native_posix.c index cb4ea0f0c21..e20669527aa 100644 --- a/drivers/usb/device/usb_dc_native_posix.c +++ b/drivers/usb/device/usb_dc_native_posix.c @@ -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 {