Fix USB drivers.

Thanks to Jeremy Drake for the report.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka
2019-09-04 08:57:07 +09:00
parent d4ba52b0d1
commit 4bde2ae1fc
4 changed files with 12 additions and 5 deletions

View File

@@ -1,3 +1,10 @@
2019-09-04 NIIBE Yutaka <gniibe@fsij.org>
When it was exactly 64-byte, two ZLPs were sent wrongly.
* mcu/usb-st-common.c (usb_lld_ctrl_send): Fix for 64-byte.
* mcu/usb-usbip.c (usb_lld_ctrl_send): Likewise.
* mcu/usb-mkl27z.c (usb_lld_ctrl_send): Likewise.
2019-05-22 NIIBE Yutaka <gniibe@fsij.org>
* VERSION: 1.16.

View File

@@ -956,7 +956,7 @@ usb_lld_ctrl_send (struct usb_dev *dev, const void *buf, size_t buflen)
else if (data_p->len != 0 && (data_p->len % USB_MAX_PACKET_SIZE) == 0)
data_p->require_zlp = 1;
if (data_p->len < USB_MAX_PACKET_SIZE)
if (data_p->len <= USB_MAX_PACKET_SIZE)
{
len = data_p->len;
dev->state = LAST_IN_DATA;

View File

@@ -329,7 +329,7 @@ handle_datastage_out (struct usb_dev *dev)
static void
handle_datastage_in (struct usb_dev *dev)
{
uint32_t len = USB_MAX_PACKET_SIZE;;
uint32_t len = USB_MAX_PACKET_SIZE;
struct ctrl_data *data_p = &dev->ctrl_data;
if ((data_p->len == 0) && (dev->state == LAST_IN_DATA))
@@ -887,14 +887,14 @@ usb_lld_ctrl_send (struct usb_dev *dev, const void *buf, size_t buflen)
data_p->addr = (void *)buf;
data_p->len = buflen;
/* Restrict the data length to be the one host asks for */
/* Restrict the data length to be the one which host asks for. */
if (data_p->len >= len_asked)
data_p->len = len_asked;
/* ZLP is only required when host doesn't expect the end of packets. */
else if (data_p->len != 0 && (data_p->len % USB_MAX_PACKET_SIZE) == 0)
data_p->require_zlp = 1;
if (data_p->len < USB_MAX_PACKET_SIZE)
if (data_p->len <= USB_MAX_PACKET_SIZE)
{
len = data_p->len;
dev->state = LAST_IN_DATA;

View File

@@ -2175,7 +2175,7 @@ usb_lld_ctrl_send (struct usb_dev *dev, const void *buf, size_t buflen)
else if (data_p->len != 0 && (data_p->len % USB_MAX_PACKET_SIZE) == 0)
data_p->require_zlp = 1;
if (data_p->len < USB_MAX_PACKET_SIZE)
if (data_p->len <= USB_MAX_PACKET_SIZE)
{
len = data_p->len;
dev->state = LAST_IN_DATA;