summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2014-03-25 20:27:38 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2014-03-25 20:27:38 +0000
commit3392fd3119db5e6a9c63c934fed6faa4a1970f69 (patch)
tree331c9e0cad371dd7b79eb5d5920f8c497729a959
parenta3554f2ddd62572187d3fc11b3418c6377b332c4 (diff)
Instead of matching root hubs with a custom address, that only works
because USB_START_ADDR is defined to 0 and the softc is M_ZERO'd, assume that root hubs are the only devices with a depth of 0. Root hubs can now happily be detached and reattached.
-rw-r--r--sys/dev/usb/ehci.c10
-rw-r--r--sys/dev/usb/ehcivar.h3
-rw-r--r--sys/dev/usb/ohci.c10
-rw-r--r--sys/dev/usb/ohcivar.h3
-rw-r--r--sys/dev/usb/uhci.c11
-rw-r--r--sys/dev/usb/uhcivar.h3
-rw-r--r--sys/dev/usb/xhci.c3
-rw-r--r--sys/dev/usb/xhcivar.h3
8 files changed, 20 insertions, 26 deletions
diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c
index 5f232d43654..195e0caef31 100644
--- a/sys/dev/usb/ehci.c
+++ b/sys/dev/usb/ehci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ehci.c,v 1.145 2014/03/15 09:49:28 mpi Exp $ */
+/* $OpenBSD: ehci.c,v 1.146 2014/03/25 20:27:37 mpi Exp $ */
/* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */
/*
@@ -1460,8 +1460,8 @@ ehci_open(struct usbd_pipe *pipe)
int ival, speed, naks;
int hshubaddr, hshubport;
- DPRINTFN(1, ("ehci_open: pipe=%p, addr=%d, endpt=%d (%d)\n",
- pipe, addr, ed->bEndpointAddress, sc->sc_addr));
+ DPRINTFN(1, ("ehci_open: pipe=%p, addr=%d, endpt=%d\n",
+ pipe, addr, ed->bEndpointAddress));
if (sc->sc_bus.dying)
return (USBD_IOERROR);
@@ -1474,7 +1474,8 @@ ehci_open(struct usbd_pipe *pipe)
hshubport = 0;
}
- if (addr == sc->sc_addr) {
+ /* Root Hub */
+ if (pipe->device->depth == 0) {
switch (ed->bEndpointAddress) {
case USB_CONTROL_ENDPOINT:
pipe->methods = &ehci_root_ctrl_methods;
@@ -2025,7 +2026,6 @@ ehci_root_ctrl_start(struct usbd_xfer *xfer)
err = USBD_IOERROR;
goto ret;
}
- sc->sc_addr = value;
break;
case C(UR_SET_CONFIG, UT_WRITE_DEVICE):
if (value != 0 && value != 1) {
diff --git a/sys/dev/usb/ehcivar.h b/sys/dev/usb/ehcivar.h
index ce4d9124d31..98a90e71539 100644
--- a/sys/dev/usb/ehcivar.h
+++ b/sys/dev/usb/ehcivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ehcivar.h,v 1.28 2013/11/07 10:15:15 mpi Exp $ */
+/* $OpenBSD: ehcivar.h,v 1.29 2014/03/25 20:27:37 mpi Exp $ */
/* $NetBSD: ehcivar.h,v 1.19 2005/04/29 15:04:29 augustss Exp $ */
/*
@@ -141,7 +141,6 @@ struct ehci_softc {
LIST_HEAD(sc_freeitds, ehci_soft_itd) sc_freeitds;
int sc_noport;
- u_int8_t sc_addr; /* device address */
u_int8_t sc_conf; /* device configuration */
struct usbd_xfer *sc_intrxfer;
char sc_isreset;
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index ef46ab4518c..9134bffbc1c 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ohci.c,v 1.123 2014/03/15 09:49:28 mpi Exp $ */
+/* $OpenBSD: ohci.c,v 1.124 2014/03/25 20:27:37 mpi Exp $ */
/* $NetBSD: ohci.c,v 1.139 2003/02/22 05:24:16 tsutsui Exp $ */
/* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */
@@ -1950,8 +1950,8 @@ ohci_open(struct usbd_pipe *pipe)
int s;
int ival;
- DPRINTFN(1, ("ohci_open: pipe=%p, addr=%d, endpt=%d (%d)\n",
- pipe, addr, ed->bEndpointAddress, sc->sc_addr));
+ DPRINTFN(1, ("ohci_open: pipe=%p, addr=%d, endpt=%d\n",
+ pipe, addr, ed->bEndpointAddress));
if (sc->sc_bus.dying)
return (USBD_IOERROR);
@@ -1959,7 +1959,8 @@ ohci_open(struct usbd_pipe *pipe)
std = NULL;
sed = NULL;
- if (addr == sc->sc_addr) {
+ /* Root Hub */
+ if (pipe->device->depth == 0) {
switch (ed->bEndpointAddress) {
case USB_CONTROL_ENDPOINT:
pipe->methods = &ohci_root_ctrl_methods;
@@ -2408,7 +2409,6 @@ ohci_root_ctrl_start(struct usbd_xfer *xfer)
err = USBD_IOERROR;
goto ret;
}
- sc->sc_addr = value;
break;
case C(UR_SET_CONFIG, UT_WRITE_DEVICE):
if (value != 0 && value != 1) {
diff --git a/sys/dev/usb/ohcivar.h b/sys/dev/usb/ohcivar.h
index 755e5ecdb91..dde77bb5efc 100644
--- a/sys/dev/usb/ohcivar.h
+++ b/sys/dev/usb/ohcivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ohcivar.h,v 1.34 2013/11/01 12:00:54 mpi Exp $ */
+/* $OpenBSD: ohcivar.h,v 1.35 2014/03/25 20:27:37 mpi Exp $ */
/* $NetBSD: ohcivar.h,v 1.32 2003/02/22 05:24:17 tsutsui Exp $ */
/* $FreeBSD: src/sys/dev/usb/ohcivar.h,v 1.13 1999/11/17 22:33:41 n_hibma Exp $ */
@@ -97,7 +97,6 @@ struct ohci_softc {
LIST_HEAD(, ohci_soft_itd) sc_hash_itds[OHCI_HASH_SIZE];
int sc_noport;
- u_int8_t sc_addr; /* device address */
u_int8_t sc_conf; /* device configuration */
char sc_softwake;
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index cf63fcaab8e..78ae7fd2765 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhci.c,v 1.109 2014/03/15 09:49:28 mpi Exp $ */
+/* $OpenBSD: uhci.c,v 1.110 2014/03/25 20:27:37 mpi Exp $ */
/* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */
@@ -2742,14 +2742,14 @@ uhci_open(struct usbd_pipe *pipe)
usbd_status err;
int ival;
- DPRINTFN(1, ("uhci_open: pipe=%p, addr=%d, endpt=%d (%d)\n",
- pipe, pipe->device->address,
- ed->bEndpointAddress, sc->sc_addr));
+ DPRINTFN(1, ("uhci_open: pipe=%p, addr=%d, endpt=%d\n",
+ pipe, pipe->device->address, ed->bEndpointAddress));
upipe->aborting = 0;
upipe->nexttoggle = pipe->endpoint->savedtoggle;
- if (pipe->device->address == sc->sc_addr) {
+ /* Root Hub */
+ if (pipe->device->depth == 0) {
switch (ed->bEndpointAddress) {
case USB_CONTROL_ENDPOINT:
pipe->methods = &uhci_root_ctrl_methods;
@@ -3108,7 +3108,6 @@ uhci_root_ctrl_start(struct usbd_xfer *xfer)
err = USBD_IOERROR;
goto ret;
}
- sc->sc_addr = value;
break;
case C(UR_SET_CONFIG, UT_WRITE_DEVICE):
if (value != 0 && value != 1) {
diff --git a/sys/dev/usb/uhcivar.h b/sys/dev/usb/uhcivar.h
index 753504147f7..4f042657363 100644
--- a/sys/dev/usb/uhcivar.h
+++ b/sys/dev/usb/uhcivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhcivar.h,v 1.28 2013/11/01 17:29:02 mpi Exp $ */
+/* $OpenBSD: uhcivar.h,v 1.29 2014/03/25 20:27:37 mpi Exp $ */
/* $NetBSD: uhcivar.h,v 1.36 2002/12/31 00:39:11 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhcivar.h,v 1.14 1999/11/17 22:33:42 n_hibma Exp $ */
@@ -142,7 +142,6 @@ struct uhci_softc {
SIMPLEQ_HEAD(, usbd_xfer) sc_free_xfers; /* free xfers */
- u_int8_t sc_addr; /* device address */
u_int8_t sc_conf; /* device configuration */
u_int8_t sc_saved_sof;
diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c
index 155e0b5e42a..7a08d57b65b 100644
--- a/sys/dev/usb/xhci.c
+++ b/sys/dev/usb/xhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xhci.c,v 1.4 2014/03/25 17:23:40 mpi Exp $ */
+/* $OpenBSD: xhci.c,v 1.5 2014/03/25 20:27:37 mpi Exp $ */
/*
* Copyright (c) 2014 Martin Pieuchot
@@ -1839,7 +1839,6 @@ xhci_root_ctrl_start(struct usbd_xfer *xfer)
err = USBD_IOERROR;
goto ret;
}
- sc->sc_addr = value;
break;
case C(UR_SET_CONFIG, UT_WRITE_DEVICE):
if (value != 0 && value != 1) {
diff --git a/sys/dev/usb/xhcivar.h b/sys/dev/usb/xhcivar.h
index 4634eacfbef..2ac61fb4be0 100644
--- a/sys/dev/usb/xhcivar.h
+++ b/sys/dev/usb/xhcivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: xhcivar.h,v 1.2 2014/03/25 17:23:40 mpi Exp $ */
+/* $OpenBSD: xhcivar.h,v 1.3 2014/03/25 20:27:37 mpi Exp $ */
/*
* Copyright (c) 2014 Martin Pieuchot
@@ -87,7 +87,6 @@ struct xhci_softc {
int sc_noport; /* Maximum number of ports */
- u_int8_t sc_addr; /* Device address */
u_int8_t sc_conf; /* Device configuration */
struct usbd_xfer *sc_intrxfer; /* Root HUB interrupt xfer */