usb: logs: Rename USB_ERR to LOG_ERR
Since logger is now suitable for our logs use it directly. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
92c7ab74c0
commit
17f7abd3dc
18 changed files with 153 additions and 154 deletions
|
@ -148,7 +148,7 @@ static int usb_dw_reset(void)
|
||||||
while (!(USB_DW->grstctl & USB_DW_GRSTCTL_AHB_IDLE)) {
|
while (!(USB_DW->grstctl & USB_DW_GRSTCTL_AHB_IDLE)) {
|
||||||
usb_dw_udelay(1);
|
usb_dw_udelay(1);
|
||||||
if (++cnt > USB_DW_CORE_RST_TIMEOUT_US) {
|
if (++cnt > USB_DW_CORE_RST_TIMEOUT_US) {
|
||||||
USB_ERR("USB reset HANG! AHB Idle GRSTCTL=0x%08x",
|
LOG_ERR("USB reset HANG! AHB Idle GRSTCTL=0x%08x",
|
||||||
USB_DW->grstctl);
|
USB_DW->grstctl);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
@ -400,7 +400,7 @@ static int usb_dw_tx(u8_t ep, const u8_t *const data,
|
||||||
|
|
||||||
avail_space *= 4;
|
avail_space *= 4;
|
||||||
if (!avail_space) {
|
if (!avail_space) {
|
||||||
USB_ERR("USB IN EP%d no space available, DTXFSTS %x", ep_idx,
|
LOG_ERR("USB IN EP%d no space available, DTXFSTS %x", ep_idx,
|
||||||
USB_DW->in_ep_reg[ep_idx].dtxfsts);
|
USB_DW->in_ep_reg[ep_idx].dtxfsts);
|
||||||
irq_unlock(key);
|
irq_unlock(key);
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
@ -809,7 +809,7 @@ int usb_dc_ep_check_cap(const struct usb_dc_ep_cfg_data * const cfg)
|
||||||
cfg->ep_type);
|
cfg->ep_type);
|
||||||
|
|
||||||
if ((cfg->ep_type == USB_DC_EP_CONTROL) && ep_idx) {
|
if ((cfg->ep_type == USB_DC_EP_CONTROL) && ep_idx) {
|
||||||
USB_ERR("invalid endpoint configuration");
|
LOG_ERR("invalid endpoint configuration");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1026,7 +1026,7 @@ int usb_dc_ep_flush(const u8_t ep)
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
do {
|
do {
|
||||||
if (++cnt > USB_DW_CORE_RST_TIMEOUT_US) {
|
if (++cnt > USB_DW_CORE_RST_TIMEOUT_US) {
|
||||||
USB_ERR("USB TX FIFO flush HANG!");
|
LOG_ERR("USB TX FIFO flush HANG!");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
usb_dw_udelay(1);
|
usb_dw_udelay(1);
|
||||||
|
@ -1073,25 +1073,25 @@ int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len,
|
||||||
u32_t i, j, data_len, bytes_to_copy;
|
u32_t i, j, data_len, bytes_to_copy;
|
||||||
|
|
||||||
if (!usb_dw_ctrl.attached && !usb_dw_ep_is_valid(ep)) {
|
if (!usb_dw_ctrl.attached && !usb_dw_ep_is_valid(ep)) {
|
||||||
USB_ERR("No valid endpoint");
|
LOG_ERR("No valid endpoint");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if OUT ep */
|
/* Check if OUT ep */
|
||||||
if (USB_DW_EP_ADDR2DIR(ep) != USB_EP_DIR_OUT) {
|
if (USB_DW_EP_ADDR2DIR(ep) != USB_EP_DIR_OUT) {
|
||||||
USB_ERR("Wrong endpoint direction");
|
LOG_ERR("Wrong endpoint direction");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allow to read 0 bytes */
|
/* Allow to read 0 bytes */
|
||||||
if (!data && max_data_len) {
|
if (!data && max_data_len) {
|
||||||
USB_ERR("Wrong arguments");
|
LOG_ERR("Wrong arguments");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if ep enabled */
|
/* Check if ep enabled */
|
||||||
if (!usb_dw_ep_is_enabled(ep)) {
|
if (!usb_dw_ep_is_enabled(ep)) {
|
||||||
USB_ERR("Not enabled endpoint");
|
LOG_ERR("Not enabled endpoint");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1109,7 +1109,7 @@ int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len,
|
||||||
|
|
||||||
|
|
||||||
if (data_len > max_data_len) {
|
if (data_len > max_data_len) {
|
||||||
USB_ERR("Not enough room to copy all the rcvd data!");
|
LOG_ERR("Not enough room to copy all the rcvd data!");
|
||||||
bytes_to_copy = max_data_len;
|
bytes_to_copy = max_data_len;
|
||||||
} else {
|
} else {
|
||||||
bytes_to_copy = data_len;
|
bytes_to_copy = data_len;
|
||||||
|
@ -1147,13 +1147,13 @@ int usb_dc_ep_read_continue(u8_t ep)
|
||||||
u8_t ep_idx = USB_DW_EP_ADDR2IDX(ep);
|
u8_t ep_idx = USB_DW_EP_ADDR2IDX(ep);
|
||||||
|
|
||||||
if (!usb_dw_ctrl.attached && !usb_dw_ep_is_valid(ep)) {
|
if (!usb_dw_ctrl.attached && !usb_dw_ep_is_valid(ep)) {
|
||||||
USB_ERR("No valid endpoint");
|
LOG_ERR("No valid endpoint");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if OUT ep */
|
/* Check if OUT ep */
|
||||||
if (USB_DW_EP_ADDR2DIR(ep) != USB_EP_DIR_OUT) {
|
if (USB_DW_EP_ADDR2DIR(ep) != USB_EP_DIR_OUT) {
|
||||||
USB_ERR("Wrong endpoint direction");
|
LOG_ERR("Wrong endpoint direction");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -272,12 +272,12 @@ int usb_dc_ep_check_cap(const struct usb_dc_ep_cfg_data * const cfg)
|
||||||
u8_t ep_idx = EP_ADDR2IDX(cfg->ep_addr);
|
u8_t ep_idx = EP_ADDR2IDX(cfg->ep_addr);
|
||||||
|
|
||||||
if ((cfg->ep_type == USB_DC_EP_CONTROL) && ep_idx) {
|
if ((cfg->ep_type == USB_DC_EP_CONTROL) && ep_idx) {
|
||||||
USB_ERR("invalid endpoint configuration");
|
LOG_ERR("invalid endpoint configuration");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ep_idx > NUM_OF_EP_MAX) {
|
if (ep_idx > NUM_OF_EP_MAX) {
|
||||||
USB_ERR("endpoint index/address out of range");
|
LOG_ERR("endpoint index/address out of range");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data * const cfg)
|
||||||
struct usb_ep_ctrl_data *ep_ctrl = &dev_data.ep_ctrl[ep_idx];
|
struct usb_ep_ctrl_data *ep_ctrl = &dev_data.ep_ctrl[ep_idx];
|
||||||
|
|
||||||
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
||||||
USB_ERR("Wrong endpoint index/address");
|
LOG_ERR("Wrong endpoint index/address");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data * const cfg)
|
||||||
if (k_mem_pool_alloc(&ep_buf_pool, block, cfg->ep_mps * 2, 10) == 0) {
|
if (k_mem_pool_alloc(&ep_buf_pool, block, cfg->ep_mps * 2, 10) == 0) {
|
||||||
(void)memset(block->data, 0, cfg->ep_mps * 2);
|
(void)memset(block->data, 0, cfg->ep_mps * 2);
|
||||||
} else {
|
} else {
|
||||||
USB_ERR("Memory allocation time-out");
|
LOG_ERR("Memory allocation time-out");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ int usb_dc_ep_set_stall(const u8_t ep)
|
||||||
u8_t bd_idx;
|
u8_t bd_idx;
|
||||||
|
|
||||||
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
||||||
USB_ERR("Wrong endpoint index/address");
|
LOG_ERR("Wrong endpoint index/address");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ int usb_dc_ep_clear_stall(const u8_t ep)
|
||||||
u8_t bd_idx;
|
u8_t bd_idx;
|
||||||
|
|
||||||
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
||||||
USB_ERR("Wrong endpoint index/address");
|
LOG_ERR("Wrong endpoint index/address");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,7 +454,7 @@ int usb_dc_ep_is_stalled(const u8_t ep, u8_t *const stalled)
|
||||||
u8_t ep_idx = EP_ADDR2IDX(ep);
|
u8_t ep_idx = EP_ADDR2IDX(ep);
|
||||||
|
|
||||||
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
||||||
USB_ERR("Wrong endpoint index/address");
|
LOG_ERR("Wrong endpoint index/address");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ int usb_dc_ep_enable(const u8_t ep)
|
||||||
u8_t ep_idx = EP_ADDR2IDX(ep);
|
u8_t ep_idx = EP_ADDR2IDX(ep);
|
||||||
|
|
||||||
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
||||||
USB_ERR("Wrong endpoint index/address");
|
LOG_ERR("Wrong endpoint index/address");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,7 +530,7 @@ int usb_dc_ep_disable(const u8_t ep)
|
||||||
u8_t ep_idx = EP_ADDR2IDX(ep);
|
u8_t ep_idx = EP_ADDR2IDX(ep);
|
||||||
|
|
||||||
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
||||||
USB_ERR("Wrong endpoint index/address");
|
LOG_ERR("Wrong endpoint index/address");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +552,7 @@ int usb_dc_ep_flush(const u8_t ep)
|
||||||
u8_t ep_idx = EP_ADDR2IDX(ep);
|
u8_t ep_idx = EP_ADDR2IDX(ep);
|
||||||
|
|
||||||
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
||||||
USB_ERR("Wrong endpoint index/address");
|
LOG_ERR("Wrong endpoint index/address");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,12 +571,12 @@ int usb_dc_ep_write(const u8_t ep, const u8_t *const data,
|
||||||
u32_t len_to_send = data_len;
|
u32_t len_to_send = data_len;
|
||||||
|
|
||||||
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
||||||
USB_ERR("Wrong endpoint index/address");
|
LOG_ERR("Wrong endpoint index/address");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EP_ADDR2DIR(ep) != USB_EP_DIR_IN) {
|
if (EP_ADDR2DIR(ep) != USB_EP_DIR_IN) {
|
||||||
USB_ERR("Wrong endpoint direction");
|
LOG_ERR("Wrong endpoint direction");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -633,12 +633,12 @@ int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len,
|
||||||
u32_t data_len;
|
u32_t data_len;
|
||||||
|
|
||||||
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
||||||
USB_ERR("Wrong endpoint index/address");
|
LOG_ERR("Wrong endpoint index/address");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EP_ADDR2DIR(ep) != USB_EP_DIR_OUT) {
|
if (EP_ADDR2DIR(ep) != USB_EP_DIR_OUT) {
|
||||||
USB_ERR("Wrong endpoint direction");
|
LOG_ERR("Wrong endpoint direction");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,12 +649,12 @@ int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len,
|
||||||
|
|
||||||
/* Allow to read 0 bytes */
|
/* Allow to read 0 bytes */
|
||||||
if (!data && max_data_len) {
|
if (!data && max_data_len) {
|
||||||
USB_ERR("Wrong arguments");
|
LOG_ERR("Wrong arguments");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (bdt[bd_idx].get.own) {
|
while (bdt[bd_idx].get.own) {
|
||||||
USB_ERR("Endpoint is occupied by the controller");
|
LOG_ERR("Endpoint is occupied by the controller");
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,12 +699,12 @@ int usb_dc_ep_read_continue(u8_t ep)
|
||||||
u8_t bd_idx = get_bdt_idx(ep, dev_data.ep_ctrl[ep_idx].status.out_odd);
|
u8_t bd_idx = get_bdt_idx(ep, dev_data.ep_ctrl[ep_idx].status.out_odd);
|
||||||
|
|
||||||
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
if (ep_idx > (NUM_OF_EP_MAX - 1)) {
|
||||||
USB_ERR("Wrong endpoint index/address");
|
LOG_ERR("Wrong endpoint index/address");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EP_ADDR2DIR(ep) != USB_EP_DIR_OUT) {
|
if (EP_ADDR2DIR(ep) != USB_EP_DIR_OUT) {
|
||||||
USB_ERR("Wrong endpoint direction");
|
LOG_ERR("Wrong endpoint direction");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -965,7 +965,7 @@ static void usb_kinetis_thread_main(void *arg1, void *unused1, void *unused2)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
USB_ERR("unknown msg");
|
LOG_ERR("unknown msg");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (dev_data.status_cb) {
|
} else if (dev_data.status_cb) {
|
||||||
|
@ -983,7 +983,7 @@ static void usb_kinetis_thread_main(void *arg1, void *unused1, void *unused2)
|
||||||
dev_data.status_cb(USB_DC_RESUME, NULL);
|
dev_data.status_cb(USB_DC_RESUME, NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
USB_ERR("unknown msg");
|
LOG_ERR("unknown msg");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,12 +265,12 @@ int usb_dc_ep_check_cap(const struct usb_dc_ep_cfg_data * const cfg)
|
||||||
u8_t ep_idx = cfg->ep_addr & ~USB_EP_DIR_MASK;
|
u8_t ep_idx = cfg->ep_addr & ~USB_EP_DIR_MASK;
|
||||||
|
|
||||||
if ((cfg->ep_type == USB_DC_EP_CONTROL) && ep_idx) {
|
if ((cfg->ep_type == USB_DC_EP_CONTROL) && ep_idx) {
|
||||||
USB_ERR("invalid endpoint configuration");
|
LOG_ERR("invalid endpoint configuration");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ep_idx > CONFIG_USB_DC_SAM0_NUM_BIDIR_ENDPOINTS) {
|
if (ep_idx > CONFIG_USB_DC_SAM0_NUM_BIDIR_ENDPOINTS) {
|
||||||
USB_ERR("endpoint index/address too high");
|
LOG_ERR("endpoint index/address too high");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ static int usb_dc_stm32_clock_enable(void)
|
||||||
if (LL_APB2_GRP1_IsEnabledClock(LL_APB2_GRP1_PERIPH_SYSCFG)) {
|
if (LL_APB2_GRP1_IsEnabledClock(LL_APB2_GRP1_PERIPH_SYSCFG)) {
|
||||||
LL_SYSCFG_VREFINT_EnableHSI48();
|
LL_SYSCFG_VREFINT_EnableHSI48();
|
||||||
} else {
|
} else {
|
||||||
USB_ERR("System Configuration Controller clock is "
|
LOG_ERR("System Configuration Controller clock is "
|
||||||
"disabled. Unable to enable VREFINT which "
|
"disabled. Unable to enable VREFINT which "
|
||||||
"is required by HSI48.");
|
"is required by HSI48.");
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ static int usb_dc_stm32_clock_enable(void)
|
||||||
if (LL_RCC_PLL_IsReady()) {
|
if (LL_RCC_PLL_IsReady()) {
|
||||||
LL_RCC_SetUSBClockSource(LL_RCC_USB_CLKSOURCE_PLL);
|
LL_RCC_SetUSBClockSource(LL_RCC_USB_CLKSOURCE_PLL);
|
||||||
} else {
|
} else {
|
||||||
USB_ERR("Unable to set USB clock source to PLL.");
|
LOG_ERR("Unable to set USB clock source to PLL.");
|
||||||
}
|
}
|
||||||
#endif /* RCC_HSI48_SUPPORT / LL_RCC_USB_CLKSOURCE_NONE */
|
#endif /* RCC_HSI48_SUPPORT / LL_RCC_USB_CLKSOURCE_NONE */
|
||||||
|
|
||||||
|
@ -345,14 +345,14 @@ static int usb_dc_stm32_init(void)
|
||||||
LOG_DBG("HAL_PCD_Init");
|
LOG_DBG("HAL_PCD_Init");
|
||||||
status = HAL_PCD_Init(&usb_dc_stm32_state.pcd);
|
status = HAL_PCD_Init(&usb_dc_stm32_state.pcd);
|
||||||
if (status != HAL_OK) {
|
if (status != HAL_OK) {
|
||||||
USB_ERR("PCD_Init failed, %d", (int)status);
|
LOG_ERR("PCD_Init failed, %d", (int)status);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DBG("HAL_PCD_Start");
|
LOG_DBG("HAL_PCD_Start");
|
||||||
status = HAL_PCD_Start(&usb_dc_stm32_state.pcd);
|
status = HAL_PCD_Start(&usb_dc_stm32_state.pcd);
|
||||||
if (status != HAL_OK) {
|
if (status != HAL_OK) {
|
||||||
USB_ERR("PCD_Start failed, %d", (int)status);
|
LOG_ERR("PCD_Start failed, %d", (int)status);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ int usb_dc_attach(void)
|
||||||
if (LL_APB1_GRP2_IsEnabledClock(LL_APB1_GRP2_PERIPH_SYSCFG)) {
|
if (LL_APB1_GRP2_IsEnabledClock(LL_APB1_GRP2_PERIPH_SYSCFG)) {
|
||||||
LL_SYSCFG_EnablePinRemap();
|
LL_SYSCFG_EnablePinRemap();
|
||||||
} else {
|
} else {
|
||||||
USB_ERR("System Configuration Controller clock is "
|
LOG_ERR("System Configuration Controller clock is "
|
||||||
"disable. Unable to enable pin remapping."
|
"disable. Unable to enable pin remapping."
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -466,7 +466,7 @@ int usb_dc_set_address(const u8_t addr)
|
||||||
|
|
||||||
status = HAL_PCD_SetAddress(&usb_dc_stm32_state.pcd, addr);
|
status = HAL_PCD_SetAddress(&usb_dc_stm32_state.pcd, addr);
|
||||||
if (status != HAL_OK) {
|
if (status != HAL_OK) {
|
||||||
USB_ERR("HAL_PCD_SetAddress failed(0x%02x), %d", addr,
|
LOG_ERR("HAL_PCD_SetAddress failed(0x%02x), %d", addr,
|
||||||
(int)status);
|
(int)status);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
@ -482,7 +482,7 @@ int usb_dc_ep_start_read(u8_t ep, u8_t *data, u32_t max_data_len)
|
||||||
|
|
||||||
/* we flush EP0_IN by doing a 0 length receive on it */
|
/* we flush EP0_IN by doing a 0 length receive on it */
|
||||||
if (!EP_IS_OUT(ep) && (ep != EP0_IN || max_data_len)) {
|
if (!EP_IS_OUT(ep) && (ep != EP0_IN || max_data_len)) {
|
||||||
USB_ERR("invalid ep 0x%02x", ep);
|
LOG_ERR("invalid ep 0x%02x", ep);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ int usb_dc_ep_start_read(u8_t ep, u8_t *data, u32_t max_data_len)
|
||||||
usb_dc_stm32_state.ep_buf[EP_IDX(ep)],
|
usb_dc_stm32_state.ep_buf[EP_IDX(ep)],
|
||||||
max_data_len);
|
max_data_len);
|
||||||
if (status != HAL_OK) {
|
if (status != HAL_OK) {
|
||||||
USB_ERR("HAL_PCD_EP_Receive failed(0x%02x), %d", ep,
|
LOG_ERR("HAL_PCD_EP_Receive failed(0x%02x), %d", ep,
|
||||||
(int)status);
|
(int)status);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
@ -505,7 +505,7 @@ int usb_dc_ep_start_read(u8_t ep, u8_t *data, u32_t max_data_len)
|
||||||
int usb_dc_ep_get_read_count(u8_t ep, u32_t *read_bytes)
|
int usb_dc_ep_get_read_count(u8_t ep, u32_t *read_bytes)
|
||||||
{
|
{
|
||||||
if (!EP_IS_OUT(ep)) {
|
if (!EP_IS_OUT(ep)) {
|
||||||
USB_ERR("invalid ep 0x%02x", ep);
|
LOG_ERR("invalid ep 0x%02x", ep);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,12 +522,12 @@ int usb_dc_ep_check_cap(const struct usb_dc_ep_cfg_data * const cfg)
|
||||||
cfg->ep_type);
|
cfg->ep_type);
|
||||||
|
|
||||||
if ((cfg->ep_type == USB_DC_EP_CONTROL) && ep_idx) {
|
if ((cfg->ep_type == USB_DC_EP_CONTROL) && ep_idx) {
|
||||||
USB_ERR("invalid endpoint configuration");
|
LOG_ERR("invalid endpoint configuration");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ep_idx > CONFIG_USB_NUM_BIDIR_ENDPOINTS) {
|
if (ep_idx > CONFIG_USB_NUM_BIDIR_ENDPOINTS) {
|
||||||
USB_ERR("endpoint index/address out of range");
|
LOG_ERR("endpoint index/address out of range");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +590,7 @@ int usb_dc_ep_set_stall(const u8_t ep)
|
||||||
|
|
||||||
status = HAL_PCD_EP_SetStall(&usb_dc_stm32_state.pcd, ep);
|
status = HAL_PCD_EP_SetStall(&usb_dc_stm32_state.pcd, ep);
|
||||||
if (status != HAL_OK) {
|
if (status != HAL_OK) {
|
||||||
USB_ERR("HAL_PCD_EP_SetStall failed(0x%02x), %d", ep,
|
LOG_ERR("HAL_PCD_EP_SetStall failed(0x%02x), %d", ep,
|
||||||
(int)status);
|
(int)status);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
@ -613,7 +613,7 @@ int usb_dc_ep_clear_stall(const u8_t ep)
|
||||||
|
|
||||||
status = HAL_PCD_EP_ClrStall(&usb_dc_stm32_state.pcd, ep);
|
status = HAL_PCD_EP_ClrStall(&usb_dc_stm32_state.pcd, ep);
|
||||||
if (status != HAL_OK) {
|
if (status != HAL_OK) {
|
||||||
USB_ERR("HAL_PCD_EP_ClrStall failed(0x%02x), %d", ep,
|
LOG_ERR("HAL_PCD_EP_ClrStall failed(0x%02x), %d", ep,
|
||||||
(int)status);
|
(int)status);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
@ -656,7 +656,7 @@ int usb_dc_ep_enable(const u8_t ep)
|
||||||
status = HAL_PCD_EP_Open(&usb_dc_stm32_state.pcd, ep,
|
status = HAL_PCD_EP_Open(&usb_dc_stm32_state.pcd, ep,
|
||||||
ep_state->ep_mps, ep_state->ep_type);
|
ep_state->ep_mps, ep_state->ep_type);
|
||||||
if (status != HAL_OK) {
|
if (status != HAL_OK) {
|
||||||
USB_ERR("HAL_PCD_EP_Open failed(0x%02x), %d", ep,
|
LOG_ERR("HAL_PCD_EP_Open failed(0x%02x), %d", ep,
|
||||||
(int)status);
|
(int)status);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
@ -683,7 +683,7 @@ int usb_dc_ep_disable(const u8_t ep)
|
||||||
|
|
||||||
status = HAL_PCD_EP_Close(&usb_dc_stm32_state.pcd, ep);
|
status = HAL_PCD_EP_Close(&usb_dc_stm32_state.pcd, ep);
|
||||||
if (status != HAL_OK) {
|
if (status != HAL_OK) {
|
||||||
USB_ERR("HAL_PCD_EP_Close failed(0x%02x), %d", ep,
|
LOG_ERR("HAL_PCD_EP_Close failed(0x%02x), %d", ep,
|
||||||
(int)status);
|
(int)status);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
@ -702,13 +702,13 @@ int usb_dc_ep_write(const u8_t ep, const u8_t *const data,
|
||||||
LOG_DBG("ep 0x%02x, len %u", ep, data_len);
|
LOG_DBG("ep 0x%02x, len %u", ep, data_len);
|
||||||
|
|
||||||
if (!EP_IS_IN(ep)) {
|
if (!EP_IS_IN(ep)) {
|
||||||
USB_ERR("invalid ep 0x%02x", ep);
|
LOG_ERR("invalid ep 0x%02x", ep);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = k_sem_take(&ep_state->write_sem, K_NO_WAIT);
|
ret = k_sem_take(&ep_state->write_sem, K_NO_WAIT);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
USB_ERR("Unable to write ep 0x%02x (%d)", ep, ret);
|
LOG_ERR("Unable to write ep 0x%02x (%d)", ep, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,7 +723,7 @@ int usb_dc_ep_write(const u8_t ep, const u8_t *const data,
|
||||||
status = HAL_PCD_EP_Transmit(&usb_dc_stm32_state.pcd, ep,
|
status = HAL_PCD_EP_Transmit(&usb_dc_stm32_state.pcd, ep,
|
||||||
(void *)data, len);
|
(void *)data, len);
|
||||||
if (status != HAL_OK) {
|
if (status != HAL_OK) {
|
||||||
USB_ERR("HAL_PCD_EP_Transmit failed(0x%02x), %d", ep,
|
LOG_ERR("HAL_PCD_EP_Transmit failed(0x%02x), %d", ep,
|
||||||
(int)status);
|
(int)status);
|
||||||
k_sem_give(&ep_state->write_sem);
|
k_sem_give(&ep_state->write_sem);
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
|
@ -757,7 +757,7 @@ int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len,
|
||||||
ep_state->read_offset, read_count, data);
|
ep_state->read_offset, read_count, data);
|
||||||
|
|
||||||
if (!EP_IS_OUT(ep)) { /* check if OUT ep */
|
if (!EP_IS_OUT(ep)) { /* check if OUT ep */
|
||||||
USB_ERR("Wrong endpoint direction: 0x%02x", ep);
|
LOG_ERR("Wrong endpoint direction: 0x%02x", ep);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -772,7 +772,7 @@ int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len,
|
||||||
ep_state->read_count -= read_count;
|
ep_state->read_count -= read_count;
|
||||||
ep_state->read_offset += read_count;
|
ep_state->read_offset += read_count;
|
||||||
} else if (max_data_len) {
|
} else if (max_data_len) {
|
||||||
USB_ERR("Wrong arguments");
|
LOG_ERR("Wrong arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_bytes) {
|
if (read_bytes) {
|
||||||
|
@ -787,7 +787,7 @@ int usb_dc_ep_read_continue(u8_t ep)
|
||||||
struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep);
|
struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep);
|
||||||
|
|
||||||
if (!EP_IS_OUT(ep)) { /* Check if OUT ep */
|
if (!EP_IS_OUT(ep)) { /* Check if OUT ep */
|
||||||
USB_ERR("Not valid endpoint: %02x", ep);
|
LOG_ERR("Not valid endpoint: %02x", ep);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USB_ERR(fmt, ...) LOG_ERR(fmt, ##__VA_ARGS__)
|
|
||||||
#define USB_WRN(fmt, ...) LOG_WRN(fmt, ##__VA_ARGS__)
|
#define USB_WRN(fmt, ...) LOG_WRN(fmt, ##__VA_ARGS__)
|
||||||
#define USB_INF(fmt, ...) LOG_INF(fmt, ##__VA_ARGS__)
|
#define USB_INF(fmt, ...) LOG_INF(fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
|
|
@ -290,7 +290,7 @@ static int tx(struct net_pkt *pkt)
|
||||||
} while (ret && retries--);
|
} while (ret && retries--);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
USB_ERR("Error sending data, seq %u", seq);
|
LOG_ERR("Error sending data, seq %u", seq);
|
||||||
/* Send seq = 0 for unsuccessful send */
|
/* Send seq = 0 for unsuccessful send */
|
||||||
seq = 0;
|
seq = 0;
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ static void tx_thread(void)
|
||||||
set_pan_id(buf->data, buf->len);
|
set_pan_id(buf->data, buf->len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
USB_ERR("%x: Not handled for now", cmd);
|
LOG_ERR("%x: Not handled for now", cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,14 +419,14 @@ static int wpanusb_init(struct device *dev)
|
||||||
/* Initialize the USB driver with the right configuration */
|
/* Initialize the USB driver with the right configuration */
|
||||||
ret = usb_set_config(&wpanusb_config);
|
ret = usb_set_config(&wpanusb_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to configure USB");
|
LOG_ERR("Failed to configure USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable USB driver */
|
/* Enable USB driver */
|
||||||
ret = usb_enable(&wpanusb_config);
|
ret = usb_enable(&wpanusb_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to enable USB");
|
LOG_ERR("Failed to enable USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@ void main(void)
|
||||||
|
|
||||||
ieee802154_dev = device_get_binding(CONFIG_NET_CONFIG_IEEE802154_DEV_NAME);
|
ieee802154_dev = device_get_binding(CONFIG_NET_CONFIG_IEEE802154_DEV_NAME);
|
||||||
if (!ieee802154_dev) {
|
if (!ieee802154_dev) {
|
||||||
USB_ERR("Cannot get IEEE802.15.4 device");
|
LOG_ERR("Cannot get IEEE802.15.4 device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ static void hci_rx_thread(void)
|
||||||
USB_TRANS_WRITE);
|
USB_TRANS_WRITE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
USB_ERR("Unknown type %u", bt_buf_get_type(buf));
|
LOG_ERR("Unknown type %u", bt_buf_get_type(buf));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ static void hci_tx_thread(void)
|
||||||
buf = net_buf_get(&tx_queue, K_FOREVER);
|
buf = net_buf_get(&tx_queue, K_FOREVER);
|
||||||
|
|
||||||
if (bt_send(buf)) {
|
if (bt_send(buf)) {
|
||||||
USB_ERR("Error sending to driver");
|
LOG_ERR("Error sending to driver");
|
||||||
net_buf_unref(buf);
|
net_buf_unref(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ static void acl_read_cb(u8_t ep, int size, void *priv)
|
||||||
|
|
||||||
buf = net_buf_alloc(&acl_tx_pool, K_NO_WAIT);
|
buf = net_buf_alloc(&acl_tx_pool, K_NO_WAIT);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
USB_ERR("Cannot get free buffer\n");
|
LOG_ERR("Cannot get free buffer\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
net_buf_reserve(buf, CONFIG_BT_HCI_RESERVE);
|
net_buf_reserve(buf, CONFIG_BT_HCI_RESERVE);
|
||||||
|
@ -246,13 +246,13 @@ static int bluetooth_class_handler(struct usb_setup_packet *setup,
|
||||||
LOG_DBG("len %u", *len);
|
LOG_DBG("len %u", *len);
|
||||||
|
|
||||||
if (!*len || *len > CMD_BUF_SIZE) {
|
if (!*len || *len > CMD_BUF_SIZE) {
|
||||||
USB_ERR("Incorrect length: %d\n", *len);
|
LOG_ERR("Incorrect length: %d\n", *len);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = net_buf_alloc(&tx_pool, K_NO_WAIT);
|
buf = net_buf_alloc(&tx_pool, K_NO_WAIT);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
USB_ERR("Cannot get free buffer\n");
|
LOG_ERR("Cannot get free buffer\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ static int bluetooth_init(struct device *dev)
|
||||||
|
|
||||||
ret = bt_enable_raw(&rx_queue);
|
ret = bt_enable_raw(&rx_queue);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
USB_ERR("Failed to open Bluetooth raw channel: %d", ret);
|
LOG_ERR("Failed to open Bluetooth raw channel: %d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,14 +305,14 @@ static int bluetooth_init(struct device *dev)
|
||||||
/* Initialize the USB driver with the right configuration */
|
/* Initialize the USB driver with the right configuration */
|
||||||
ret = usb_set_config(&bluetooth_config);
|
ret = usb_set_config(&bluetooth_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to config USB");
|
LOG_ERR("Failed to config USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable USB driver */
|
/* Enable USB driver */
|
||||||
ret = usb_enable(&bluetooth_config);
|
ret = usb_enable(&bluetooth_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to enable USB");
|
LOG_ERR("Failed to enable USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -351,7 +351,7 @@ static void cdc_acm_bulk_out(u8_t ep,
|
||||||
if (((buf_head + 1) % CDC_ACM_BUFFER_SIZE) ==
|
if (((buf_head + 1) % CDC_ACM_BUFFER_SIZE) ==
|
||||||
dev_data->rx_buf_tail) {
|
dev_data->rx_buf_tail) {
|
||||||
/* FIFO full, discard data */
|
/* FIFO full, discard data */
|
||||||
USB_ERR("CDC buffer full!");
|
LOG_ERR("CDC buffer full!");
|
||||||
} else {
|
} else {
|
||||||
dev_data->rx_buf[buf_head] = tmp_buf[j];
|
dev_data->rx_buf[buf_head] = tmp_buf[j];
|
||||||
buf_head = (buf_head + 1) % CDC_ACM_BUFFER_SIZE;
|
buf_head = (buf_head + 1) % CDC_ACM_BUFFER_SIZE;
|
||||||
|
@ -514,14 +514,14 @@ static int cdc_acm_init(struct device *dev)
|
||||||
/* Initialize the USB driver with the right configuration */
|
/* Initialize the USB driver with the right configuration */
|
||||||
ret = usb_set_config(&cdc_acm_config);
|
ret = usb_set_config(&cdc_acm_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to config USB");
|
LOG_ERR("Failed to config USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable USB driver */
|
/* Enable USB driver */
|
||||||
ret = usb_enable(&cdc_acm_config);
|
ret = usb_enable(&cdc_acm_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to enable USB");
|
LOG_ERR("Failed to enable USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -144,12 +144,12 @@ static int hid_class_handle_req(struct usb_setup_packet *setup,
|
||||||
return hid_device.ops->get_report(setup, len,
|
return hid_device.ops->get_report(setup, len,
|
||||||
data);
|
data);
|
||||||
} else {
|
} else {
|
||||||
USB_ERR("Mandatory request not supported");
|
LOG_ERR("Mandatory request not supported");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
USB_ERR("Unhandled request 0x%x", setup->bRequest);
|
LOG_ERR("Unhandled request 0x%x", setup->bRequest);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -163,12 +163,12 @@ static int hid_class_handle_req(struct usb_setup_packet *setup,
|
||||||
break;
|
break;
|
||||||
case HID_SET_REPORT:
|
case HID_SET_REPORT:
|
||||||
if (hid_device.ops->set_report == NULL) {
|
if (hid_device.ops->set_report == NULL) {
|
||||||
USB_ERR("set_report not implemented");
|
LOG_ERR("set_report not implemented");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
return hid_device.ops->set_report(setup, len, data);
|
return hid_device.ops->set_report(setup, len, data);
|
||||||
default:
|
default:
|
||||||
USB_ERR("Unhandled request 0x%x", setup->bRequest);
|
LOG_ERR("Unhandled request 0x%x", setup->bRequest);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,14 +288,14 @@ int usb_hid_init(void)
|
||||||
/* Initialize the USB driver with the right configuration */
|
/* Initialize the USB driver with the right configuration */
|
||||||
ret = usb_set_config(&hid_config);
|
ret = usb_set_config(&hid_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to config USB");
|
LOG_ERR("Failed to config USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable USB driver */
|
/* Enable USB driver */
|
||||||
ret = usb_enable(&hid_config);
|
ret = usb_enable(&hid_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to enable USB");
|
LOG_ERR("Failed to enable USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -192,7 +192,7 @@ static int loopback_init(struct device *dev)
|
||||||
/* usb.rst configure USB controller start */
|
/* usb.rst configure USB controller start */
|
||||||
ret = usb_set_config(&loopback_config);
|
ret = usb_set_config(&loopback_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to config USB");
|
LOG_ERR("Failed to config USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/* usb.rst configure USB controller end */
|
/* usb.rst configure USB controller end */
|
||||||
|
@ -200,7 +200,7 @@ static int loopback_init(struct device *dev)
|
||||||
/* usb.rst enable USB controller start */
|
/* usb.rst enable USB controller start */
|
||||||
ret = usb_enable(&loopback_config);
|
ret = usb_enable(&loopback_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to enable USB");
|
LOG_ERR("Failed to enable USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/* usb.rst enable USB controller end */
|
/* usb.rst enable USB controller end */
|
||||||
|
|
|
@ -191,7 +191,7 @@ static void sendCSW(void)
|
||||||
csw.Signature = CSW_Signature;
|
csw.Signature = CSW_Signature;
|
||||||
if (usb_write(mass_ep_data[MSD_IN_EP_IDX].ep_addr, (u8_t *)&csw,
|
if (usb_write(mass_ep_data[MSD_IN_EP_IDX].ep_addr, (u8_t *)&csw,
|
||||||
sizeof(struct CSW), NULL) != 0) {
|
sizeof(struct CSW), NULL) != 0) {
|
||||||
USB_ERR("usb write failure");
|
LOG_ERR("usb write failure");
|
||||||
}
|
}
|
||||||
stage = WAIT_CSW;
|
stage = WAIT_CSW;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ static bool write(u8_t *buf, u16_t size)
|
||||||
stage = SEND_CSW;
|
stage = SEND_CSW;
|
||||||
|
|
||||||
if (usb_write(mass_ep_data[MSD_IN_EP_IDX].ep_addr, buf, size, NULL)) {
|
if (usb_write(mass_ep_data[MSD_IN_EP_IDX].ep_addr, buf, size, NULL)) {
|
||||||
USB_ERR("USB write failed");
|
LOG_ERR("USB write failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ static void thread_memory_read_done(void)
|
||||||
|
|
||||||
if (usb_write(mass_ep_data[MSD_IN_EP_IDX].ep_addr,
|
if (usb_write(mass_ep_data[MSD_IN_EP_IDX].ep_addr,
|
||||||
&page[addr % BLOCK_SIZE], n, NULL) != 0) {
|
&page[addr % BLOCK_SIZE], n, NULL) != 0) {
|
||||||
USB_ERR("Failed to write EP 0x%x",
|
LOG_ERR("Failed to write EP 0x%x",
|
||||||
mass_ep_data[MSD_IN_EP_IDX].ep_addr);
|
mass_ep_data[MSD_IN_EP_IDX].ep_addr);
|
||||||
}
|
}
|
||||||
addr += n;
|
addr += n;
|
||||||
|
@ -467,13 +467,13 @@ static void fail(void)
|
||||||
static void CBWDecode(u8_t *buf, u16_t size)
|
static void CBWDecode(u8_t *buf, u16_t size)
|
||||||
{
|
{
|
||||||
if (size != sizeof(cbw)) {
|
if (size != sizeof(cbw)) {
|
||||||
USB_ERR("size != sizeof(cbw)");
|
LOG_ERR("size != sizeof(cbw)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy((u8_t *)&cbw, buf, size);
|
memcpy((u8_t *)&cbw, buf, size);
|
||||||
if (cbw.Signature != CBW_Signature) {
|
if (cbw.Signature != CBW_Signature) {
|
||||||
USB_ERR("CBW Signature Mismatch");
|
LOG_ERR("CBW Signature Mismatch");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,7 +589,7 @@ static void memoryVerify(u8_t *buf, u16_t size)
|
||||||
if (!(addr % BLOCK_SIZE)) {
|
if (!(addr % BLOCK_SIZE)) {
|
||||||
LOG_DBG("Disk READ sector %d", addr/BLOCK_SIZE);
|
LOG_DBG("Disk READ sector %d", addr/BLOCK_SIZE);
|
||||||
if (disk_access_read(disk_pdrv, page, addr/BLOCK_SIZE, 1)) {
|
if (disk_access_read(disk_pdrv, page, addr/BLOCK_SIZE, 1)) {
|
||||||
USB_ERR("---- Disk Read Error %d", addr/BLOCK_SIZE);
|
LOG_ERR("---- Disk Read Error %d", addr/BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ static void mass_storage_bulk_out(u8_t ep,
|
||||||
memoryVerify(bo_buf, bytes_read);
|
memoryVerify(bo_buf, bytes_read);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
USB_ERR("> BO - PROC_CBW default <<ERROR!!!>>");
|
LOG_ERR("> BO - PROC_CBW default <<ERROR!!!>>");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -747,7 +747,7 @@ static void mass_storage_bulk_in(u8_t ep,
|
||||||
memoryRead();
|
memoryRead();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
USB_ERR("< BI-PROC_CBW default <<ERROR!!>>");
|
LOG_ERR("< BI-PROC_CBW default <<ERROR!!>>");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -852,7 +852,7 @@ static void mass_thread_main(int arg1, int unused)
|
||||||
case THREAD_OP_READ_QUEUED:
|
case THREAD_OP_READ_QUEUED:
|
||||||
if (disk_access_read(disk_pdrv,
|
if (disk_access_read(disk_pdrv,
|
||||||
page, (addr/BLOCK_SIZE), 1)) {
|
page, (addr/BLOCK_SIZE), 1)) {
|
||||||
USB_ERR("!! Disk Read Error %d !",
|
LOG_ERR("!! Disk Read Error %d !",
|
||||||
addr/BLOCK_SIZE);
|
addr/BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,13 +861,13 @@ static void mass_thread_main(int arg1, int unused)
|
||||||
case THREAD_OP_WRITE_QUEUED:
|
case THREAD_OP_WRITE_QUEUED:
|
||||||
if (disk_access_write(disk_pdrv,
|
if (disk_access_write(disk_pdrv,
|
||||||
page, (addr/BLOCK_SIZE), 1)) {
|
page, (addr/BLOCK_SIZE), 1)) {
|
||||||
USB_ERR("!!!!! Disk Write Error %d !!!!!",
|
LOG_ERR("!!!!! Disk Write Error %d !!!!!",
|
||||||
addr/BLOCK_SIZE);
|
addr/BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
thread_memory_write_done();
|
thread_memory_write_done();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
USB_ERR("XXXXXX thread_op %d ! XXXXX", thread_op);
|
LOG_ERR("XXXXXX thread_op %d ! XXXXX", thread_op);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -894,24 +894,24 @@ static int mass_storage_init(struct device *dev)
|
||||||
ARG_UNUSED(dev);
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
if (disk_access_init(disk_pdrv) != 0) {
|
if (disk_access_init(disk_pdrv) != 0) {
|
||||||
USB_ERR("Storage init ERROR !!!! - Aborting USB init");
|
LOG_ERR("Storage init ERROR !!!! - Aborting USB init");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disk_access_ioctl(disk_pdrv,
|
if (disk_access_ioctl(disk_pdrv,
|
||||||
DISK_IOCTL_GET_SECTOR_COUNT, &block_count)) {
|
DISK_IOCTL_GET_SECTOR_COUNT, &block_count)) {
|
||||||
USB_ERR("Unable to get sector count - Aborting USB init");
|
LOG_ERR("Unable to get sector count - Aborting USB init");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disk_access_ioctl(disk_pdrv,
|
if (disk_access_ioctl(disk_pdrv,
|
||||||
DISK_IOCTL_GET_SECTOR_SIZE, &block_size)) {
|
DISK_IOCTL_GET_SECTOR_SIZE, &block_size)) {
|
||||||
USB_ERR("Unable to get sector size - Aborting USB init");
|
LOG_ERR("Unable to get sector size - Aborting USB init");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block_size != BLOCK_SIZE) {
|
if (block_size != BLOCK_SIZE) {
|
||||||
USB_ERR("Block Size reported by the storage side is "
|
LOG_ERR("Block Size reported by the storage side is "
|
||||||
"different from Mass Storgae Class page Buffer - "
|
"different from Mass Storgae Class page Buffer - "
|
||||||
"Aborting");
|
"Aborting");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -934,14 +934,14 @@ static int mass_storage_init(struct device *dev)
|
||||||
/* Initialize the USB driver with the right configuration */
|
/* Initialize the USB driver with the right configuration */
|
||||||
ret = usb_set_config(&mass_storage_config);
|
ret = usb_set_config(&mass_storage_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to config USB");
|
LOG_ERR("Failed to config USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable USB driver */
|
/* Enable USB driver */
|
||||||
ret = usb_enable(&mass_storage_config);
|
ret = usb_enable(&mass_storage_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to enable USB");
|
LOG_ERR("Failed to enable USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -279,7 +279,7 @@ static int ecm_send(struct net_pkt *pkt)
|
||||||
ret = usb_transfer_sync(ecm_ep_data[ECM_IN_EP_IDX].ep_addr,
|
ret = usb_transfer_sync(ecm_ep_data[ECM_IN_EP_IDX].ep_addr,
|
||||||
tx_buf, b_idx, USB_TRANS_WRITE);
|
tx_buf, b_idx, USB_TRANS_WRITE);
|
||||||
if (ret != b_idx) {
|
if (ret != b_idx) {
|
||||||
USB_ERR("Transfer failure");
|
LOG_ERR("Transfer failure");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,13 +309,13 @@ static void ecm_read_cb(u8_t ep, int size, void *priv)
|
||||||
|
|
||||||
pkt = net_pkt_get_reserve_rx(0, K_FOREVER);
|
pkt = net_pkt_get_reserve_rx(0, K_FOREVER);
|
||||||
if (!pkt) {
|
if (!pkt) {
|
||||||
USB_ERR("no memory for network packet\n");
|
LOG_ERR("no memory for network packet\n");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
frag = net_pkt_get_frag(pkt, K_FOREVER);
|
frag = net_pkt_get_frag(pkt, K_FOREVER);
|
||||||
if (!frag) {
|
if (!frag) {
|
||||||
USB_ERR("no memory for network packet\n");
|
LOG_ERR("no memory for network packet\n");
|
||||||
net_pkt_unref(pkt);
|
net_pkt_unref(pkt);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ static void ecm_read_cb(u8_t ep, int size, void *priv)
|
||||||
net_pkt_frag_insert(pkt, frag);
|
net_pkt_frag_insert(pkt, frag);
|
||||||
|
|
||||||
if (!net_pkt_append_all(pkt, size, rx_buf, K_FOREVER)) {
|
if (!net_pkt_append_all(pkt, size, rx_buf, K_FOREVER)) {
|
||||||
USB_ERR("no memory for network packet\n");
|
LOG_ERR("no memory for network packet\n");
|
||||||
net_pkt_unref(pkt);
|
net_pkt_unref(pkt);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ static int eem_send(struct net_pkt *pkt)
|
||||||
tx_buf, b_idx,
|
tx_buf, b_idx,
|
||||||
USB_TRANS_WRITE);
|
USB_TRANS_WRITE);
|
||||||
if (ret != b_idx) {
|
if (ret != b_idx) {
|
||||||
USB_ERR("Transfer failure");
|
LOG_ERR("Transfer failure");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ static void eem_read_cb(u8_t ep, int size, void *priv)
|
||||||
|
|
||||||
if (eem_size + sizeof(u16_t) > size) {
|
if (eem_size + sizeof(u16_t) > size) {
|
||||||
/* eem pkt greater than transferred data */
|
/* eem pkt greater than transferred data */
|
||||||
USB_ERR("pkt size error");
|
LOG_ERR("pkt size error");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,13 +179,13 @@ static void eem_read_cb(u8_t ep, int size, void *priv)
|
||||||
|
|
||||||
pkt = net_pkt_get_reserve_rx(0, K_FOREVER);
|
pkt = net_pkt_get_reserve_rx(0, K_FOREVER);
|
||||||
if (!pkt) {
|
if (!pkt) {
|
||||||
USB_ERR("Unable to alloc pkt\n");
|
LOG_ERR("Unable to alloc pkt\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
frag = net_pkt_get_frag(pkt, K_FOREVER);
|
frag = net_pkt_get_frag(pkt, K_FOREVER);
|
||||||
if (!frag) {
|
if (!frag) {
|
||||||
USB_ERR("Unable to alloc fragment");
|
LOG_ERR("Unable to alloc fragment");
|
||||||
net_pkt_unref(pkt);
|
net_pkt_unref(pkt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ static void eem_read_cb(u8_t ep, int size, void *priv)
|
||||||
|
|
||||||
/* copy payload and discard 32-bit sentinel */
|
/* copy payload and discard 32-bit sentinel */
|
||||||
if (!net_pkt_append_all(pkt, eem_size - 4, ptr, K_FOREVER)) {
|
if (!net_pkt_append_all(pkt, eem_size - 4, ptr, K_FOREVER)) {
|
||||||
USB_ERR("Unable to append pkt\n");
|
LOG_ERR("Unable to append pkt\n");
|
||||||
net_pkt_unref(pkt);
|
net_pkt_unref(pkt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,12 +290,12 @@ static int parse_rndis_header(const u8_t *buffer, u32_t buf_len)
|
||||||
u32_t len;
|
u32_t len;
|
||||||
|
|
||||||
if (buf_len < sizeof(*hdr)) {
|
if (buf_len < sizeof(*hdr)) {
|
||||||
USB_ERR("Too small packet len %u", buf_len);
|
LOG_ERR("Too small packet len %u", buf_len);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hdr->type != sys_cpu_to_le32(RNDIS_DATA_PACKET)) {
|
if (hdr->type != sys_cpu_to_le32(RNDIS_DATA_PACKET)) {
|
||||||
USB_ERR("Wrong data packet type 0x%x",
|
LOG_ERR("Wrong data packet type 0x%x",
|
||||||
sys_le32_to_cpu(hdr->type));
|
sys_le32_to_cpu(hdr->type));
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ static int parse_rndis_header(const u8_t *buffer, u32_t buf_len)
|
||||||
if (len < sys_le32_to_cpu(hdr->payload_offset) +
|
if (len < sys_le32_to_cpu(hdr->payload_offset) +
|
||||||
sys_le32_to_cpu(hdr->payload_len) +
|
sys_le32_to_cpu(hdr->payload_len) +
|
||||||
offsetof(struct rndis_payload_packet, payload_offset)) {
|
offsetof(struct rndis_payload_packet, payload_offset)) {
|
||||||
USB_ERR("Incorrect RNDIS packet");
|
LOG_ERR("Incorrect RNDIS packet");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ static void rndis_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status)
|
||||||
|
|
||||||
usb_read(ep, buffer, len, &read);
|
usb_read(ep, buffer, len, &read);
|
||||||
if (len != read) {
|
if (len != read) {
|
||||||
USB_ERR("Read %u instead of expected %u, skip the rest",
|
LOG_ERR("Read %u instead of expected %u, skip the rest",
|
||||||
read, len);
|
read, len);
|
||||||
rndis.skip_bytes = len - read;
|
rndis.skip_bytes = len - read;
|
||||||
return;
|
return;
|
||||||
|
@ -374,7 +374,7 @@ static void rndis_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status)
|
||||||
rndis.skip_bytes -= len;
|
rndis.skip_bytes -= len;
|
||||||
|
|
||||||
if (rndis.skip_bytes < 0) {
|
if (rndis.skip_bytes < 0) {
|
||||||
USB_ERR("Error skipping bytes");
|
LOG_ERR("Error skipping bytes");
|
||||||
|
|
||||||
rndis.skip_bytes = 0;
|
rndis.skip_bytes = 0;
|
||||||
}
|
}
|
||||||
|
@ -389,7 +389,7 @@ static void rndis_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status)
|
||||||
|
|
||||||
rndis.in_pkt_len = parse_rndis_header(buffer, len);
|
rndis.in_pkt_len = parse_rndis_header(buffer, len);
|
||||||
if (rndis.in_pkt_len < 0) {
|
if (rndis.in_pkt_len < 0) {
|
||||||
USB_ERR("Error parsing RNDIS header");
|
LOG_ERR("Error parsing RNDIS header");
|
||||||
|
|
||||||
rndis.rx_err++;
|
rndis.rx_err++;
|
||||||
return;
|
return;
|
||||||
|
@ -403,7 +403,7 @@ static void rndis_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status)
|
||||||
rndis.skip_bytes = rndis.in_pkt_len - len;
|
rndis.skip_bytes = rndis.in_pkt_len - len;
|
||||||
rndis.rx_no_buf++;
|
rndis.rx_no_buf++;
|
||||||
|
|
||||||
USB_ERR("Not enough pkt buffers, len %u, skip %u",
|
LOG_ERR("Not enough pkt buffers, len %u, skip %u",
|
||||||
rndis.in_pkt_len, rndis.skip_bytes);
|
rndis.in_pkt_len, rndis.skip_bytes);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -416,7 +416,7 @@ static void rndis_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status)
|
||||||
*/
|
*/
|
||||||
rndis.skip_bytes = rndis.in_pkt_len - len;
|
rndis.skip_bytes = rndis.in_pkt_len - len;
|
||||||
|
|
||||||
USB_ERR("Not enough net buffers, len %u, skip %u",
|
LOG_ERR("Not enough net buffers, len %u, skip %u",
|
||||||
rndis.in_pkt_len, rndis.skip_bytes);
|
rndis.in_pkt_len, rndis.skip_bytes);
|
||||||
|
|
||||||
net_pkt_unref(pkt);
|
net_pkt_unref(pkt);
|
||||||
|
@ -435,7 +435,7 @@ static void rndis_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status)
|
||||||
ret = net_pkt_append_all(rndis.in_pkt, len - hdr_offset,
|
ret = net_pkt_append_all(rndis.in_pkt, len - hdr_offset,
|
||||||
buffer + hdr_offset, K_FOREVER);
|
buffer + hdr_offset, K_FOREVER);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Error appending data to pkt: %p", rndis.in_pkt);
|
LOG_ERR("Error appending data to pkt: %p", rndis.in_pkt);
|
||||||
rndis_clean();
|
rndis_clean();
|
||||||
rndis.rx_err++;
|
rndis.rx_err++;
|
||||||
return;
|
return;
|
||||||
|
@ -456,7 +456,7 @@ static void rndis_bulk_out(u8_t ep, enum usb_dc_ep_cb_status_code ep_status)
|
||||||
/* Start over for new packets */
|
/* Start over for new packets */
|
||||||
rndis.in_pkt = NULL;
|
rndis.in_pkt = NULL;
|
||||||
} else if (rndis.in_pkt_len < 0) {
|
} else if (rndis.in_pkt_len < 0) {
|
||||||
USB_ERR("Error assembling packet, drop and start over");
|
LOG_ERR("Error assembling packet, drop and start over");
|
||||||
rndis_clean();
|
rndis_clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,7 @@ static void rndis_queue_rsp(struct net_buf *rsp)
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
|
|
||||||
while ((buf = net_buf_get(&rndis_tx_queue, K_NO_WAIT))) {
|
while ((buf = net_buf_get(&rndis_tx_queue, K_NO_WAIT))) {
|
||||||
USB_ERR("Drop buffer %p", buf);
|
LOG_ERR("Drop buffer %p", buf);
|
||||||
net_buf_unref(buf);
|
net_buf_unref(buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -546,7 +546,7 @@ static void rndis_notify_rsp(void)
|
||||||
*/
|
*/
|
||||||
ret = k_delayed_work_submit(¬ify_work, K_NO_WAIT);
|
ret = k_delayed_work_submit(¬ify_work, K_NO_WAIT);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
USB_ERR("Error submittinf delaying queue: %d", ret);
|
LOG_ERR("Error submittinf delaying queue: %d", ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ static int rndis_init_handle(u8_t *data, u32_t len)
|
||||||
|
|
||||||
buf = net_buf_alloc(&rndis_tx_pool, K_NO_WAIT);
|
buf = net_buf_alloc(&rndis_tx_pool, K_NO_WAIT);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
USB_ERR("Cannot get free buffer");
|
LOG_ERR("Cannot get free buffer");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,7 +623,7 @@ static int rndis_query_handle(u8_t *data, u32_t len)
|
||||||
|
|
||||||
buf = net_buf_alloc(&rndis_tx_pool, K_NO_WAIT);
|
buf = net_buf_alloc(&rndis_tx_pool, K_NO_WAIT);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
USB_ERR("Cannot get free buffer");
|
LOG_ERR("Cannot get free buffer");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -765,7 +765,7 @@ static int rndis_set_handle(u8_t *data, u32_t len)
|
||||||
u8_t *param;
|
u8_t *param;
|
||||||
|
|
||||||
if (len < sizeof(*cmd)) {
|
if (len < sizeof(*cmd)) {
|
||||||
USB_ERR("Packet is shorter then header");
|
LOG_ERR("Packet is shorter then header");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -774,13 +774,13 @@ static int rndis_set_handle(u8_t *data, u32_t len)
|
||||||
|
|
||||||
if (len - ((u32_t)param - (u32_t)cmd) !=
|
if (len - ((u32_t)param - (u32_t)cmd) !=
|
||||||
sys_le32_to_cpu(cmd->buf_len)) {
|
sys_le32_to_cpu(cmd->buf_len)) {
|
||||||
USB_ERR("Packet parsing error");
|
LOG_ERR("Packet parsing error");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = net_buf_alloc(&rndis_tx_pool, K_NO_WAIT);
|
buf = net_buf_alloc(&rndis_tx_pool, K_NO_WAIT);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
USB_ERR("Cannot get free buffer");
|
LOG_ERR("Cannot get free buffer");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -799,7 +799,7 @@ static int rndis_set_handle(u8_t *data, u32_t len)
|
||||||
switch (object_id) {
|
switch (object_id) {
|
||||||
case RNDIS_OBJECT_ID_GEN_PKT_FILTER:
|
case RNDIS_OBJECT_ID_GEN_PKT_FILTER:
|
||||||
if (sys_le32_to_cpu(cmd->buf_len) < sizeof(rndis.net_filter)) {
|
if (sys_le32_to_cpu(cmd->buf_len) < sizeof(rndis.net_filter)) {
|
||||||
USB_ERR("Packet is too small");
|
LOG_ERR("Packet is too small");
|
||||||
rsp->status = RNDIS_CMD_STATUS_INVALID_DATA;
|
rsp->status = RNDIS_CMD_STATUS_INVALID_DATA;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -816,7 +816,7 @@ static int rndis_set_handle(u8_t *data, u32_t len)
|
||||||
rsp->status = sys_cpu_to_le32(RNDIS_CMD_STATUS_SUCCESS);
|
rsp->status = sys_cpu_to_le32(RNDIS_CMD_STATUS_SUCCESS);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
USB_ERR("Unhandled object_id 0x%x", object_id);
|
LOG_ERR("Unhandled object_id 0x%x", object_id);
|
||||||
rsp->status = sys_cpu_to_le32(RNDIS_CMD_STATUS_NOT_SUPP);
|
rsp->status = sys_cpu_to_le32(RNDIS_CMD_STATUS_NOT_SUPP);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -836,7 +836,7 @@ static int rndis_reset_handle(u8_t *data, u32_t len)
|
||||||
|
|
||||||
buf = net_buf_alloc(&rndis_tx_pool, K_NO_WAIT);
|
buf = net_buf_alloc(&rndis_tx_pool, K_NO_WAIT);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
USB_ERR("Cannot get free buffer");
|
LOG_ERR("Cannot get free buffer");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -864,7 +864,7 @@ static int rndis_keepalive_handle(u8_t *data, u32_t len)
|
||||||
|
|
||||||
buf = net_buf_alloc(&rndis_tx_pool, K_NO_WAIT);
|
buf = net_buf_alloc(&rndis_tx_pool, K_NO_WAIT);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
USB_ERR("Cannot get free buffer");
|
LOG_ERR("Cannot get free buffer");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -890,7 +890,7 @@ static int queue_encapsulated_cmd(u8_t *data, u32_t len)
|
||||||
|
|
||||||
buf = net_buf_alloc(&rndis_cmd_pool, K_NO_WAIT);
|
buf = net_buf_alloc(&rndis_cmd_pool, K_NO_WAIT);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
USB_ERR("Cannot get free buffer");
|
LOG_ERR("Cannot get free buffer");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -932,7 +932,7 @@ static int handle_encapsulated_cmd(u8_t *data, u32_t len)
|
||||||
case RNDIS_CMD_KEEPALIVE:
|
case RNDIS_CMD_KEEPALIVE:
|
||||||
return rndis_keepalive_handle(data, len);
|
return rndis_keepalive_handle(data, len);
|
||||||
default:
|
default:
|
||||||
USB_ERR("Message 0x%x unhandled", msg->type);
|
LOG_ERR("Message 0x%x unhandled", msg->type);
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,7 +949,7 @@ static int rndis_send_media_status(u32_t media_status)
|
||||||
|
|
||||||
buf = net_buf_alloc(&rndis_tx_pool, K_NO_WAIT);
|
buf = net_buf_alloc(&rndis_tx_pool, K_NO_WAIT);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
USB_ERR("Cannot get free buffer");
|
LOG_ERR("Cannot get free buffer");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -983,7 +983,7 @@ static int handle_encapsulated_rsp(u8_t **data, u32_t *len)
|
||||||
|
|
||||||
buf = net_buf_get(&rndis_tx_queue, K_NO_WAIT);
|
buf = net_buf_get(&rndis_tx_queue, K_NO_WAIT);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
USB_ERR("Error getting response buffer");
|
LOG_ERR("Error getting response buffer");
|
||||||
*len = 0;
|
*len = 0;
|
||||||
return -ENODATA;
|
return -ENODATA;
|
||||||
}
|
}
|
||||||
|
@ -1006,7 +1006,7 @@ static int rndis_class_handler(struct usb_setup_packet *setup, s32_t *len,
|
||||||
netusb_enabled());
|
netusb_enabled());
|
||||||
|
|
||||||
if (!netusb_enabled()) {
|
if (!netusb_enabled()) {
|
||||||
USB_ERR("interface disabled");
|
LOG_ERR("interface disabled");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1102,7 +1102,7 @@ static int append_bytes(u8_t *out_buf, u16_t buf_len, u8_t *data,
|
||||||
out_buf,
|
out_buf,
|
||||||
buf_len);
|
buf_len);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
USB_ERR("Error sending data");
|
LOG_ERR("Error sending data");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ static int netusb_send(struct net_if *iface, struct net_pkt *pkt)
|
||||||
LOG_DBG("Send pkt, len %u", net_pkt_get_len(pkt));
|
LOG_DBG("Send pkt, len %u", net_pkt_get_len(pkt));
|
||||||
|
|
||||||
if (!netusb_enabled()) {
|
if (!netusb_enabled()) {
|
||||||
USB_ERR("interface disabled");
|
LOG_ERR("interface disabled");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ void netusb_recv(struct net_pkt *pkt)
|
||||||
LOG_DBG("Recv pkt, len %u", net_pkt_get_len(pkt));
|
LOG_DBG("Recv pkt, len %u", net_pkt_get_len(pkt));
|
||||||
|
|
||||||
if (net_recv_data(netusb.iface, pkt) < 0) {
|
if (net_recv_data(netusb.iface, pkt) < 0) {
|
||||||
USB_ERR("Packet %p dropped by NET stack", pkt);
|
LOG_ERR("Packet %p dropped by NET stack", pkt);
|
||||||
net_pkt_unref(pkt);
|
net_pkt_unref(pkt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ static int netusb_connect_media(void)
|
||||||
LOG_DBG("");
|
LOG_DBG("");
|
||||||
|
|
||||||
if (!netusb_enabled()) {
|
if (!netusb_enabled()) {
|
||||||
USB_ERR("interface disabled");
|
LOG_ERR("interface disabled");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ static int netusb_disconnect_media(void)
|
||||||
LOG_DBG("");
|
LOG_DBG("");
|
||||||
|
|
||||||
if (!netusb_enabled()) {
|
if (!netusb_enabled()) {
|
||||||
USB_ERR("interface disabled");
|
LOG_ERR("interface disabled");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,13 +206,13 @@ static void netusb_init(struct net_if *iface)
|
||||||
|
|
||||||
ret = usb_set_config(cfg);
|
ret = usb_set_config(cfg);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to configure USB device");
|
LOG_ERR("Failed to configure USB device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = usb_enable(cfg);
|
ret = usb_enable(cfg);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to enable USB");
|
LOG_ERR("Failed to enable USB");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,7 +329,7 @@ static void dfu_flash_write(u8_t *data, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flash_img_buffered_write(&dfu_data.ctx, data, len, flush)) {
|
if (flash_img_buffered_write(&dfu_data.ctx, data, len, flush)) {
|
||||||
USB_ERR("flash write error");
|
LOG_ERR("flash write error");
|
||||||
dfu_data.state = dfuERROR;
|
dfu_data.state = dfuERROR;
|
||||||
dfu_data.status = errWRITE;
|
dfu_data.status = errWRITE;
|
||||||
} else if (!len) {
|
} else if (!len) {
|
||||||
|
@ -426,7 +426,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
|
||||||
+ FLASH_AREA_IMAGE_1_OFFSET) {
|
+ FLASH_AREA_IMAGE_1_OFFSET) {
|
||||||
dfu_data.status = errWRITE;
|
dfu_data.status = errWRITE;
|
||||||
dfu_data.state = dfuERROR;
|
dfu_data.state = dfuERROR;
|
||||||
USB_ERR("This area can not be overwritten");
|
LOG_ERR("This area can not be overwritten");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
|
||||||
dfu_flash_write(*data, pSetup->wLength);
|
dfu_flash_write(*data, pSetup->wLength);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
USB_ERR("DFU_DNLOAD wrong state %d", dfu_data.state);
|
LOG_ERR("DFU_DNLOAD wrong state %d", dfu_data.state);
|
||||||
dfu_data.state = dfuERROR;
|
dfu_data.state = dfuERROR;
|
||||||
dfu_data.status = errUNKNOWN;
|
dfu_data.status = errUNKNOWN;
|
||||||
dfu_reset_counters();
|
dfu_reset_counters();
|
||||||
|
@ -507,7 +507,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
USB_ERR("DFU_UPLOAD wrong state %d", dfu_data.state);
|
LOG_ERR("DFU_UPLOAD wrong state %d", dfu_data.state);
|
||||||
dfu_data.state = dfuERROR;
|
dfu_data.state = dfuERROR;
|
||||||
dfu_data.status = errUNKNOWN;
|
dfu_data.status = errUNKNOWN;
|
||||||
dfu_reset_counters();
|
dfu_reset_counters();
|
||||||
|
@ -534,7 +534,7 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
|
||||||
/* Set the DFU mode descriptors to be used after reset */
|
/* Set the DFU mode descriptors to be used after reset */
|
||||||
dfu_config.usb_device_description = (u8_t *) &dfu_mode_desc;
|
dfu_config.usb_device_description = (u8_t *) &dfu_mode_desc;
|
||||||
if (usb_set_config(&dfu_config) != 0) {
|
if (usb_set_config(&dfu_config) != 0) {
|
||||||
USB_ERR("usb_set_config failed in DFU_DETACH");
|
LOG_ERR("usb_set_config failed in DFU_DETACH");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -685,7 +685,7 @@ static int usb_dfu_init(struct device *dev)
|
||||||
|
|
||||||
dfu_data.flash_dev = device_get_binding(FLASH_DEV_NAME);
|
dfu_data.flash_dev = device_get_binding(FLASH_DEV_NAME);
|
||||||
if (!dfu_data.flash_dev) {
|
if (!dfu_data.flash_dev) {
|
||||||
USB_ERR("Flash device not found\n");
|
LOG_ERR("Flash device not found\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -696,14 +696,14 @@ static int usb_dfu_init(struct device *dev)
|
||||||
/* Initialize the USB driver with the right configuration */
|
/* Initialize the USB driver with the right configuration */
|
||||||
ret = usb_set_config(&dfu_config);
|
ret = usb_set_config(&dfu_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to config USB");
|
LOG_ERR("Failed to config USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable USB driver */
|
/* Enable USB driver */
|
||||||
ret = usb_enable(&dfu_config);
|
ret = usb_enable(&dfu_config);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
USB_ERR("Failed to enable USB");
|
LOG_ERR("Failed to enable USB");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -313,7 +313,7 @@ usb_fix_ascii_sn_string_descriptor(struct usb_sn_descriptor *sn)
|
||||||
default_sn_len = strlen(CONFIG_USB_DEVICE_SN);
|
default_sn_len = strlen(CONFIG_USB_DEVICE_SN);
|
||||||
|
|
||||||
if (runtime_sn_len != default_sn_len) {
|
if (runtime_sn_len != default_sn_len) {
|
||||||
USB_ERR("the new SN descriptor doesn't has the same "
|
LOG_ERR("the new SN descriptor doesn't has the same "
|
||||||
"length as CONFIG_USB_DEVICE_SN");
|
"length as CONFIG_USB_DEVICE_SN");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ static int usb_fix_descriptor(struct usb_desc_header *head)
|
||||||
if (if_descr->bInterfaceNumber == 0) {
|
if (if_descr->bInterfaceNumber == 0) {
|
||||||
cfg_data = usb_get_cfg_data(if_descr);
|
cfg_data = usb_get_cfg_data(if_descr);
|
||||||
if (!cfg_data) {
|
if (!cfg_data) {
|
||||||
USB_ERR("There is no usb_cfg_data "
|
LOG_ERR("There is no usb_cfg_data "
|
||||||
"for %p", head);
|
"for %p", head);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ static int usb_fix_descriptor(struct usb_desc_header *head)
|
||||||
if (usb_validate_ep_cfg_data(ep_descr,
|
if (usb_validate_ep_cfg_data(ep_descr,
|
||||||
cfg_data,
|
cfg_data,
|
||||||
&requested_ep)) {
|
&requested_ep)) {
|
||||||
USB_ERR("Failed to validate endpoints");
|
LOG_ERR("Failed to validate endpoints");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ static int usb_fix_descriptor(struct usb_desc_header *head)
|
||||||
ascii7_to_utf16le(head);
|
ascii7_to_utf16le(head);
|
||||||
} else {
|
} else {
|
||||||
if (!cfg_descr) {
|
if (!cfg_descr) {
|
||||||
USB_ERR("Incomplete device descriptor");
|
LOG_ERR("Incomplete device descriptor");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +441,7 @@ u8_t *usb_get_device_descriptor(void)
|
||||||
LOG_DBG("__usb_descriptor_end %p", __usb_descriptor_end);
|
LOG_DBG("__usb_descriptor_end %p", __usb_descriptor_end);
|
||||||
|
|
||||||
if (usb_fix_descriptor(__usb_descriptor_start)) {
|
if (usb_fix_descriptor(__usb_descriptor_start)) {
|
||||||
USB_ERR("Failed to fixup USB descriptor");
|
LOG_ERR("Failed to fixup USB descriptor");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1233,7 +1233,7 @@ void usb_transfer_ep_callback(u8_t ep, enum usb_dc_ep_cb_status_code status)
|
||||||
usb_dc_ep_read_wait(ep, &data, 1, &bytes);
|
usb_dc_ep_read_wait(ep, &data, 1, &bytes);
|
||||||
} while (bytes);
|
} while (bytes);
|
||||||
|
|
||||||
USB_ERR("RX data lost, no transfer");
|
LOG_ERR("RX data lost, no transfer");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1265,7 +1265,7 @@ int usb_transfer(u8_t ep, u8_t *data, size_t dlen, unsigned int flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!trans) {
|
if (!trans) {
|
||||||
USB_ERR("no transfer slot available");
|
LOG_ERR("no transfer slot available");
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -1492,7 +1492,7 @@ static int usb_composite_init(struct device *dev)
|
||||||
/* register device descriptor */
|
/* register device descriptor */
|
||||||
device_descriptor = usb_get_device_descriptor();
|
device_descriptor = usb_get_device_descriptor();
|
||||||
if (!device_descriptor) {
|
if (!device_descriptor) {
|
||||||
USB_ERR("Failed to configure USB device stack");
|
LOG_ERR("Failed to configure USB device stack");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue