usb: usb_dc_native_posix: Fix buffer and max data 0 case
When both buffer and max data to read are zero return the available data in buffer. Fixes #20838 Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
5b22c88184
commit
1d81c0cf31
1 changed files with 13 additions and 0 deletions
|
@ -401,6 +401,19 @@ int usb_dc_ep_read_wait(u8_t ep, u8_t *data, u32_t max_data_len,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!data && !max_data_len) {
|
||||
/* When both buffer and max data to read are zero return
|
||||
* the available data in buffer
|
||||
*/
|
||||
if (read_bytes) {
|
||||
u8_t ep_idx = USBIP_EP_ADDR2IDX(ep);
|
||||
|
||||
*read_bytes = usbip_ctrl.out_ep_ctrl[ep_idx].data_len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOG_DBG("ep %x max_data_len %u", ep, max_data_len);
|
||||
|
||||
bytes = usbip_recv(data, max_data_len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue