summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usbdi.c
diff options
context:
space:
mode:
authorjoe <joe@FreeBSD.org>2002-04-01 13:43:02 +0000
committerjoe <joe@FreeBSD.org>2002-04-01 13:43:02 +0000
commit6cfa1c12f7ffdcfc3da561f6fd33bc76b7082996 (patch)
tree39be594ffaf2dffecbedc929cf691bbca9a9d29c /sys/dev/usb/usbdi.c
parent6b00e274ed6bdce287a85a9408ecc3c7f7ce6b0b (diff)
downloadFreeBSD-src-6cfa1c12f7ffdcfc3da561f6fd33bc76b7082996.zip
FreeBSD-src-6cfa1c12f7ffdcfc3da561f6fd33bc76b7082996.tar.gz
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. ----------------------------
Diffstat (limited to 'sys/dev/usb/usbdi.c')
-rw-r--r--sys/dev/usb/usbdi.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c
index 1ce6fd1..83b1fe6 100644
--- a/sys/dev/usb/usbdi.c
+++ b/sys/dev/usb/usbdi.c
@@ -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);
OpenPOWER on IntegriCloud