From 2ef8c9ed41e696b2d7d2a8fa84ae682393e4d127 Mon Sep 17 00:00:00 2001 From: ftrvxmtrx Date: Wed, 23 Apr 2014 23:45:00 +0200 Subject: 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. --- sys/src/cmd/nusb/lib/parse.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sys/src') diff --git a/sys/src/cmd/nusb/lib/parse.c b/sys/src/cmd/nusb/lib/parse.c index cc5f20c02..cf942ed7c 100644 --- a/sys/src/cmd/nusb/lib/parse.c +++ b/sys/src/cmd/nusb/lib/parse.c @@ -96,7 +96,7 @@ extern Ep* mkep(Usbdev *, int); 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 @@ parseendpt(Usbdev *d, Conf *c, Iface *ip, Altc *altc, uchar *b, int n, Ep **epp) 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; -- cgit v1.2.3