diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2000-07-04 11:44:27 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2000-07-04 11:44:27 +0000 |
commit | 90c5f215cf041b9a7e9d4045a6ea32f686e8fc28 (patch) | |
tree | 3405ddc669be426cfa7c9e74b8a655cd8e4c936f /sys/dev/usb/usbdi.c | |
parent | c543e41d0e0b608ebd7ae8249f32fc3b6ac1ad42 (diff) |
sync with NetBSD... well almost. someone w/ the hw should check umass.
Diffstat (limited to 'sys/dev/usb/usbdi.c')
-rw-r--r-- | sys/dev/usb/usbdi.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index c88d33d87ae..bf37703bb65 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi.c,v 1.10 2000/03/30 16:19:33 aaron Exp $ */ +/* $OpenBSD: usbdi.c,v 1.11 2000/07/04 11:44:25 fgsch Exp $ */ /* $NetBSD: usbdi.c,v 1.71 2000/03/29 01:45:21 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */ @@ -7,7 +7,7 @@ * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation - * by Lennart Augustsson (augustss@carlstedt.se) at + * by Lennart Augustsson (lennart@augustsson.net) at * Carlstedt Research & Technology. * * Redistribution and use in source and binary forms, with or without @@ -640,6 +640,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); } @@ -693,19 +699,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 works, 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); |