Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Make it possible to move a device to its unconfi...
details: https://anonhg.NetBSD.org/src/rev/657a741d0154
branches: trunk
changeset: 485249:657a741d0154
user: augustss <augustss%NetBSD.org@localhost>
date: Sun Apr 23 00:46:59 2000 +0000
description:
Make it possible to move a device to its unconfigured state by
using config #0.
diffstat:
sys/dev/usb/usb.h | 6 +++++-
sys/dev/usb/usb_subr.c | 23 ++++++++++++++++-------
2 files changed, 21 insertions(+), 8 deletions(-)
diffs (92 lines):
diff -r cace2f1cbbcd -r 657a741d0154 sys/dev/usb/usb.h
--- a/sys/dev/usb/usb.h Sat Apr 22 22:52:15 2000 +0000
+++ b/sys/dev/usb/usb.h Sun Apr 23 00:46:59 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usb.h,v 1.46 2000/04/21 18:57:40 augustss Exp $ */
+/* $NetBSD: usb.h,v 1.47 2000/04/23 00:46:59 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb.h,v 1.14 1999/11/17 22:33:46 n_hibma Exp $ */
/*
@@ -445,6 +445,10 @@
#define USB_BUS_RESET_DELAY 100 /* ms XXX?*/
+
+#define USB_UNCONFIG_NO 0
+#define USB_UNCONFIG_INDEX (-1)
+
/*** ioctl() related stuff ***/
struct usb_ctl_request {
diff -r cace2f1cbbcd -r 657a741d0154 sys/dev/usb/usb_subr.c
--- a/sys/dev/usb/usb_subr.c Sat Apr 22 22:52:15 2000 +0000
+++ b/sys/dev/usb/usb_subr.c Sun Apr 23 00:46:59 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_subr.c,v 1.74 2000/04/21 20:58:56 augustss Exp $ */
+/* $NetBSD: usb_subr.c,v 1.75 2000/04/23 00:47:00 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
/*
@@ -302,8 +302,6 @@
usbd_bus_handle bus;
u_int ms;
{
- extern int cold;
-
/* Wait at least two clock ticks so we know the time has passed. */
if (bus->use_polling || cold)
delay((ms+1) * 1000);
@@ -526,7 +524,6 @@
return (usbd_do_request(dev, &req, 0));
}
-/* XXX should allow moving the device to the unconfigured state. */
usbd_status
usbd_set_config_no(dev, no, msg)
usbd_device_handle dev;
@@ -537,6 +534,9 @@
usb_config_descriptor_t cd;
usbd_status err;
+ if (no == USB_UNCONFIG_NO)
+ return (usbd_set_config_index(dev, USB_UNCONFIG_INDEX, msg));
+
DPRINTFN(5,("usbd_set_config_no: %d\n", no));
/* Figure out what config index to use. */
for (index = 0; index < dev->ddesc.bNumConfigurations; index++) {
@@ -549,7 +549,6 @@
return (USBD_INVAL);
}
-/* XXX should allow moving the device to the unconfigured state. */
usbd_status
usbd_set_config_index(dev, index, msg)
usbd_device_handle dev;
@@ -564,7 +563,7 @@
DPRINTFN(5,("usbd_set_config_index: dev=%p index=%d\n", dev, index));
/* XXX check that all interfaces are idle */
- if (dev->config != 0) {
+ if (dev->config != USB_UNCONFIG_NO) {
DPRINTF(("usbd_set_config_index: free old config\n"));
/* Free all configuration data structures. */
nifc = dev->cdesc->bNumInterface;
@@ -574,7 +573,17 @@
free(dev->cdesc, M_USB);
dev->ifaces = NULL;
dev->cdesc = NULL;
- dev->config = 0;
+ dev->config = USB_UNCONFIG_NO;
+ }
+
+ if (index == USB_UNCONFIG_INDEX) {
+ /* We are unconfiguring the device, so leave unallocated. */
+ DPRINTF(("usbd_set_config_index: set config 0\n"));
+ err = usbd_set_config(dev, USB_UNCONFIG_NO);
+ if (err)
+ DPRINTF(("usbd_set_config_index: setting config=0 "
+ "failed, error=%s\n", usbd_errstr(err)));
+ return (err);
}
/* Get the short descriptor. */
Home |
Main Index |
Thread Index |
Old Index