Merge from NetBSD:

----------------------------
    revision 1.73
    date: 2000/05/31 16:14:42;  author: augustss;  state: Exp;  lines: +19 -6
    Be more careful when setting the alternate interface so we don't
    end up with nothing set at all if it fails.
    ----------------------------
This commit is contained in:
joe 2002-04-01 13:43:02 +00:00
parent 6b00e274ed
commit 6cfa1c12f7

View File

@ -1,4 +1,4 @@
/* $NetBSD: usbdi.c,v 1.71 2000/03/29 01:45:21 augustss Exp $ */
/* $NetBSD: usbdi.c,v 1.73 2000/05/31 16:14:42 augustss Exp $ */
/* $FreeBSD$ */
/*
@ -635,6 +635,12 @@ usbd_endpoint_count(iface, count)
usbd_interface_handle iface;
u_int8_t *count;
{
#ifdef DIAGNOSTIC
if (iface == NULL || iface->idesc == NULL) {
printf("usbd_endpoint_count: NULL pointer\n");
return (USBD_INVAL);
}
#endif
*count = iface->idesc->bNumEndpoints;
return (USBD_NORMAL_COMPLETION);
}
@ -688,19 +694,27 @@ usbd_set_interface(iface, altidx)
{
usb_device_request_t req;
usbd_status err;
void *endpoints;
if (LIST_FIRST(&iface->pipes) != 0)
return (USBD_IN_USE);
if (iface->endpoints)
free(iface->endpoints, M_USB);
iface->endpoints = 0;
iface->idesc = 0;
endpoints = iface->endpoints;
err = usbd_fill_iface_data(iface->device, iface->index, altidx);
if (err)
return (err);
/* new setting work, we can free old endpoints */
if (endpoints != NULL)
free(endpoints, M_USB);
#ifdef DIAGNOSTIC
if (iface->idesc == NULL) {
printf("usbd_set_interface: NULL pointer\n");
return (USBD_INVAL);
}
#endif
req.bmRequestType = UT_WRITE_INTERFACE;
req.bRequest = UR_SET_INTERFACE;
USETW(req.wValue, iface->idesc->bAlternateSetting);