From d294826cfd34c2c13b22a94894562350cabd44a0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 3 Sep 2013 16:24:11 -0600 Subject: [PATCH] SAMA5 UDPHS: Small change to zero length packet handling --- arch/arm/src/sama5/sam_udphs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/sama5/sam_udphs.c b/arch/arm/src/sama5/sam_udphs.c index 71e3e19412..e87378e691 100644 --- a/arch/arm/src/sama5/sam_udphs.c +++ b/arch/arm/src/sama5/sam_udphs.c @@ -1395,11 +1395,17 @@ static int sam_req_write(struct sam_usbdev_s *priv, struct sam_ep_s *privep) } } - /* No data to send... is there a trailing zero length packet transfer - * pending? + /* No data to send... This can happen on one of two ways: + * (1) The last packet sent was the final packet of a transfer + * and was exactly maxpacketsize and the protocol expects + * a zero length packet to follow (privep->txnullpkt will be + * set). Or (2) we called with a request packet that has + * len == 0 (privep->txnullpkt will not be set). Either case + * means that it is time to send a NULL packet and complete + * this transfer. */ - else if (privep->txnullpkt) + else { /* If we get here, then we sent the last of the data on the * previous pass and we need to send the zero length packet now.