ref: 2ef8c9ed41e696b2d7d2a8fa84ae682393e4d127
parent: 99c0abc76db4e534a6e2dd76ef57c37f297bf735
author: ftrvxmtrx <devnull@localhost>
date: Wed Apr 23 19:45:00 EDT 2014
nusb: workaround for endpoints with same index but different types nusb code assumes endpoint numbers are unique. It's true in general case, but it becomes false once the direction bit is ignored. The commit adds a check so that two endpoints of different types are not merged into one with Eboth direction. It does overwrite endpoint though, so it shouldn't be considered as a full fix.
--- a/sys/src/cmd/nusb/lib/parse.c
+++ b/sys/src/cmd/nusb/lib/parse.c
@@ -96,7 +96,7 @@
static int
parseendpt(Usbdev *d, Conf *c, Iface *ip, Altc *altc, uchar *b, int n, Ep **epp)
{
- int i, dir, epid;
+ int i, dir, epid, type;
Ep *ep;
DEp *dep;
@@ -115,17 +115,20 @@
dir = Ein;
else
dir = Eout;
+ type = dep->bmAttributes & 0x03;
ep = d->ep[epid];
if(ep == nil){
ep = mkep(d, epid);
ep->dir = dir;
- }else if((ep->addr & 0x80) != (dep->bEndpointAddress & 0x80))
+ }else if((ep->addr & 0x80) != (dep->bEndpointAddress & 0x80) && ep->type == type)
ep->dir = Eboth;
+ else
+ ep->dir = dir;
ep->maxpkt = GET2(dep->wMaxPacketSize);
ep->ntds = 1 + ((ep->maxpkt >> 11) & 3);
ep->maxpkt &= 0x7FF;
ep->addr = dep->bEndpointAddress;
- ep->type = dep->bmAttributes & 0x03;
+ ep->type = type;
ep->isotype = (dep->bmAttributes>>2) & 0x03;
ep->conf = c;
ep->iface = ip;