From bbbaf17cc4e7b85de595f06a696daaaf7a71c300 Mon Sep 17 00:00:00 2001 From: rumble Date: Thu, 8 Jul 2004 00:54:21 +0000 Subject: The MCT advertises both the interrupt and bulkin endpoints as interrupts. Go from assuming that the first enumerated interrupt is the bulkin (since this may not be the case) to assuming that the true interrupt endpoint will have a 0x2 wMaxPacketSize. From FreeBSD's umct.c, ok'd by mycroft@, closes PR25959. --- sys/dev/usb/umct.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'sys/dev/usb') diff --git a/sys/dev/usb/umct.c b/sys/dev/usb/umct.c index 7d09e70892d..c0e1c16547c 100644 --- a/sys/dev/usb/umct.c +++ b/sys/dev/usb/umct.c @@ -1,4 +1,4 @@ -/* $NetBSD: umct.c,v 1.13 2004/04/23 17:25:25 itojun Exp $ */ +/* $NetBSD: umct.c,v 1.14 2004/07/08 00:54:21 rumble Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. * All rights reserved. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umct.c,v 1.13 2004/04/23 17:25:25 itojun Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umct.c,v 1.14 2004/07/08 00:54:21 rumble Exp $"); #include #include @@ -180,7 +180,7 @@ USB_ATTACH(umct) char devinfo[1024]; char *devname = USBDEVNAME(sc->sc_dev); usbd_status err; - int i, found; + int i; struct ucom_attach_args uca; usbd_devinfo(dev, 0, devinfo, sizeof(devinfo)); @@ -230,7 +230,6 @@ USB_ATTACH(umct) id = usbd_get_interface_descriptor(sc->sc_iface); sc->sc_iface_number = id->bInterfaceNumber; - found = 0; for (i = 0; i < id->bNumEndpoints; i++) { ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i); @@ -241,11 +240,15 @@ USB_ATTACH(umct) USB_ATTACH_ERROR_RETURN; } + /* + * The Bulkin endpoint is marked as an interrupt. Since + * we can't rely on the endpoint descriptor order, we'll + * check the wMaxPacketSize field to differentiate. + */ if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT && - found == 0) { + UGETW(ed->wMaxPacketSize) != 0x2) { uca.bulkin = ed->bEndpointAddress; - found = 1; } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT && UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) { uca.bulkout = ed->bEndpointAddress; -- cgit