diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-07-10 11:47:15 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-07-10 11:47:15 +0000 |
commit | 1ca8bbf6a849b59870cfa1fa31290c3677979beb (patch) | |
tree | 118add11277a409b393b8a13ae1ec423170df302 | |
parent | 5c10f14236537b49465dd2c50a34903b04dad380 (diff) |
Always assign the device address found by the USB stack even if it
does not match the hardware address.
This change only matters for xHCI buses where the controller assigns
device addresses. But it is the simplest way to comply with the stack
requirement of assigning the first `logical' address to the root hub
device.
Device addresses are not much used anyway and a cleanup will follow to
avoid possible confusions.
This makes usbdevs(8) correctly report devices connected to xhci(4).
-rw-r--r-- | sys/dev/usb/usb_subr.c | 12 | ||||
-rw-r--r-- | sys/dev/usb/xhci.c | 7 |
2 files changed, 10 insertions, 9 deletions
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c index 2bdeaeb6053..2bf4124fba2 100644 --- a/sys/dev/usb/usb_subr.c +++ b/sys/dev/usb/usb_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb_subr.c,v 1.102 2014/07/09 18:15:04 mpi Exp $ */ +/* $OpenBSD: usb_subr.c,v 1.103 2014/07/10 11:47:14 mpi Exp $ */ /* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ @@ -828,9 +828,6 @@ usbd_set_address(struct usbd_device *dev, int addr) if (usbd_do_request(dev, &req, 0)) return (1); - dev->address = addr; - dev->bus->devices[addr] = dev; - /* Allow device time to set new address */ usbd_delay_ms(dev, USB_SET_ADDRESS_SETTLE); @@ -1200,6 +1197,13 @@ usbd_new_device(struct device *parent, struct usbd_bus *bus, int depth, return (USBD_SET_ADDR_FAILED); } + /* + * If this device is attached to an xHCI controller, this + * address does not correspond to the hardware one. + */ + dev->address = addr; + bus->devices[addr] = dev; + /* Re-establish the default pipe with the new address. */ usbd_close_pipe(dev->default_pipe); err = usbd_setup_pipe(dev, 0, &dev->def_ep, USBD_DEFAULT_INTERVAL, diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c index 608213237eb..411dbf794a5 100644 --- a/sys/dev/usb/xhci.c +++ b/sys/dev/usb/xhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xhci.c,v 1.14 2014/07/09 15:54:39 mpi Exp $ */ +/* $OpenBSD: xhci.c,v 1.15 2014/07/10 11:47:14 mpi Exp $ */ /* * Copyright (c) 2014 Martin Pieuchot @@ -960,10 +960,7 @@ xhci_device_setup(struct xhci_softc *sc, struct usbd_device *dev, uint8_t slot) if (addr == 0) return (EINVAL); - DPRINTF(("%s: dev %d new addr %d\n", DEVNAME(sc), slot, addr)); - - dev->address = addr; - dev->bus->devices[addr] = dev; + DPRINTF(("%s: dev %d internal addr %d\n", DEVNAME(sc), slot, addr)); return (0); } |