From f35cdfc1e4d3a59541bffcaefea739def7cd5468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20S=C3=A1nchez=20Siles?= Date: Tue, 2 Nov 2021 19:58:57 +0100 Subject: [PATCH] drivers: usb_dc_native_posix fill in data amount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fill in received bytes in USBIP_RET_SUBMIT packet Currently this field is unconditionally set to 0 and therefore not filled in conveniently. This may mislead the USB host which is correctly acknowledged that the transaction was sucessful but it cannot check the actual received bytes. Test application: ```python import usb data = (0xFF, 0xFF) print("Opening loopback device") device = usb.core.find(idVendor=0x2FE3, idProduct=0x0009) print("Writing test data", data) written = device.write(0x1, data) print("Written", written, "bytes") ``` Before: ``` $ ./test_loopback.py Opening loopback device Writing test data (255, 255) Written 0 bytes ``` After: ``` $ ./test_loopback.py Opening loopback device Writing test data (255, 255) Written 2 bytes ``` Signed-off-by: Raúl Sánchez Siles --- drivers/usb/device/usb_dc_native_posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/device/usb_dc_native_posix.c b/drivers/usb/device/usb_dc_native_posix.c index 2c3e23821bf..9d7f74c77f1 100644 --- a/drivers/usb/device/usb_dc_native_posix.c +++ b/drivers/usb/device/usb_dc_native_posix.c @@ -560,7 +560,7 @@ int handle_usb_data(struct usbip_header *hdr) ep_ctrl->cb(ep, USB_DC_EP_DATA_OUT); /* Send ACK reply */ - if (!usbip_send_common(ep, 0)) { + if (!usbip_send_common(ep, ep_ctrl->data_len)) { return -EIO; } } else {