usb: usb_dc_native_posix: Fix valid endpoints check

Fix check for valid endpoints; issue is found in harness testing.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2019-03-26 16:53:15 +02:00 committed by Anas Nashif
commit 81fbf0f4b5

View file

@ -196,7 +196,8 @@ int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data * const cfg)
return -EINVAL;
}
if (!usbip_ctrl.attached && !usbip_ep_is_valid(ep)) {
if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) {
LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep);
return -EINVAL;
}
@ -213,7 +214,8 @@ int usb_dc_ep_set_stall(const u8_t ep)
{
LOG_DBG("ep %x", ep);
if (!usbip_ctrl.attached && !usbip_ep_is_valid(ep)) {
if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) {
LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep);
return -EINVAL;
}
@ -229,7 +231,8 @@ int usb_dc_ep_clear_stall(const u8_t ep)
LOG_DBG("ep %x", ep);
if (!usbip_ctrl.attached && !usbip_ep_is_valid(ep)) {
if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) {
LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep);
return -EINVAL;
}
@ -247,7 +250,8 @@ int usb_dc_ep_halt(const u8_t ep)
LOG_DBG("ep %x", ep);
if (!usbip_ctrl.attached && !usbip_ep_is_valid(ep)) {
if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) {
LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep);
return -EINVAL;
}
@ -263,7 +267,8 @@ int usb_dc_ep_is_stalled(const u8_t ep, u8_t *const stalled)
{
LOG_DBG("ep %x", ep);
if (!usbip_ctrl.attached && !usbip_ep_is_valid(ep)) {
if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) {
LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep);
return -EINVAL;
}
@ -280,7 +285,8 @@ int usb_dc_ep_enable(const u8_t ep)
LOG_DBG("ep %x", ep);
if (!usbip_ctrl.attached && !usbip_ep_is_valid(ep)) {
if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) {
LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep);
return -EINVAL;
}
@ -305,7 +311,8 @@ int usb_dc_ep_flush(const u8_t ep)
{
LOG_DBG("ep %x", ep);
if (!usbip_ctrl.attached && !usbip_ep_is_valid(ep)) {
if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) {
LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep);
return -EINVAL;
}
@ -322,7 +329,8 @@ int usb_dc_ep_write(const u8_t ep, const u8_t *const data,
{
LOG_DBG("ep %x len %u", ep, data_len);
if (!usbip_ctrl.attached && !usbip_ep_is_valid(ep)) {
if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) {
LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep);
return -EINVAL;
}
@ -360,8 +368,8 @@ int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len,
{
u32_t bytes;
if (!usbip_ctrl.attached && !usbip_ep_is_valid(ep)) {
LOG_ERR("No valid endpoint");
if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) {
LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep);
return -EINVAL;
}
@ -398,8 +406,8 @@ int usb_dc_ep_read_continue(u8_t ep)
{
u8_t ep_idx = USBIP_EP_ADDR2IDX(ep);
if (!usbip_ctrl.attached && !usbip_ep_is_valid(ep)) {
LOG_ERR("No valid endpoint");
if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) {
LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep);
return -EINVAL;
}
@ -446,7 +454,8 @@ int usb_dc_ep_set_callback(const u8_t ep, const usb_dc_ep_callback cb)
LOG_DBG("ep %x callback %p", ep, cb);
if (!usbip_ctrl.attached && !usbip_ep_is_valid(ep)) {
if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) {
LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep);
return -EINVAL;
}
@ -472,7 +481,8 @@ int usb_dc_ep_mps(const u8_t ep)
LOG_DBG("ep %x", ep);
if (!usbip_ep_is_valid(ep)) {
if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) {
LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep);
return -EINVAL;
}