-/* $OpenBSD: uhub.c,v 1.69 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: uhub.c,v 1.70 2014/08/09 09:45:14 mpi Exp $ */
/* $NetBSD: uhub.c,v 1.64 2003/02/08 03:32:51 ichiro Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */
struct usbd_device *dev = uaa->device;
struct usbd_hub *hub = NULL;
usb_hub_descriptor_t hubdesc;
- int p, port, nports, pwrdly;
+ int p, port, nports, powerdelay;
struct usbd_interface *iface;
usb_endpoint_descriptor_t *ed;
struct usbd_tt *tts = NULL;
/* Get hub descriptor. */
err = usbd_get_hub_descriptor(dev, &hubdesc, 1);
nports = hubdesc.bNbrPorts;
+ powerdelay = (hubdesc.bPwrOn2PwrGood * UHD_PWRON_FACTOR);
if (!err && nports > 7)
usbd_get_hub_descriptor(dev, &hubdesc, nports);
if (err) {
dev->hub = hub;
dev->hub->hubsoftc = sc;
hub->explore = uhub_explore;
- hub->hubdesc = hubdesc;
+ hub->nports = nports;
+ hub->powerdelay = powerdelay;
if (!dev->self_powered && dev->powersrc->parent != NULL &&
!dev->powersrc->parent->self_powered) {
}
}
- /* XXX should check for none, individual, or ganged power? */
-
- pwrdly = dev->hub->hubdesc.bPwrOn2PwrGood * UHD_PWRON_FACTOR
- + USB_EXTRA_POWER_UP_TIME;
for (port = 1; port <= nports; port++) {
/* Turn the power on. */
err = usbd_set_port_feature(dev, port, UHF_PORT_POWER);
usbd_errstr(err));
}
- /* Wait for stable power. Root hubs delay in their event thread. */
+ /* Wait for stable power. */
if (dev->powersrc->parent != NULL)
- usbd_delay_ms(dev, pwrdly);
+ usbd_delay_ms(dev, powerdelay + USB_EXTRA_POWER_UP_TIME);
/* The usual exploration will finish the setup. */
int
uhub_explore(struct usbd_device *dev)
{
- usb_hub_descriptor_t *hd = &dev->hub->hubdesc;
struct uhub_softc *sc = dev->hub->hubsoftc;
struct usbd_port *up;
usbd_status err;
if (dev->depth > USB_HUB_MAX_DEPTH)
return (EOPNOTSUPP);
- for (port = 1; port <= hd->bNbrPorts; port++) {
+ for (port = 1; port <= dev->hub->nports; port++) {
up = &dev->hub->ports[port-1];
err = usbd_get_port_status(dev, port, &up->status);
if (err) {
struct uhub_softc *sc = (struct uhub_softc *)self;
struct usbd_hub *hub = sc->sc_hub->hub;
struct usbd_port *rup;
- int port, nports;
+ int port;
if (hub == NULL) /* Must be partially working */
return (0);
usbd_abort_pipe(sc->sc_ipipe);
usbd_close_pipe(sc->sc_ipipe);
- nports = hub->hubdesc.bNbrPorts;
- for(port = 0; port < nports; port++) {
+ for (port = 0; port < hub->nports; port++) {
rup = &hub->ports[port];
if (rup->device != NULL) {
usbd_detach(rup->device, self);
-/* $OpenBSD: usb.c,v 1.100 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: usb.c,v 1.101 2014/08/09 09:45:14 mpi Exp $ */
/* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */
/*
timersub(&now, &sc->sc_ptime, &waited);
waited_ms = waited.tv_sec * 1000 + waited.tv_usec / 1000;
- pwrdly = sc->sc_bus->root_hub->hub->hubdesc.bPwrOn2PwrGood *
- UHD_PWRON_FACTOR + USB_EXTRA_POWER_UP_TIME;
+ pwrdly = sc->sc_bus->root_hub->hub->powerdelay +
+ USB_EXTRA_POWER_UP_TIME;
if (pwrdly > waited_ms)
usb_delay_ms(sc->sc_bus, pwrdly - waited_ms);
}
-/* $OpenBSD: usb_subr.c,v 1.106 2014/07/12 18:48:53 tedu Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.107 2014/08/09 09:45: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 $ */
adev = hub, hub = hub->myhub)
;
if (hub) {
- for (p = 0; p < hub->hub->hubdesc.bNbrPorts; p++) {
+ for (p = 0; p < hub->hub->nports; p++) {
if (hub->hub->ports[p].device == adev) {
dev->myhsport = &hub->hub->ports[p];
goto found;
if (dev->hub) {
for (i = 0;
- i < nitems(di->udi_ports) &&
- i < dev->hub->hubdesc.bNbrPorts; i++) {
+ i < nitems(di->udi_ports) && i < dev->hub->nports; i++) {
p = &dev->hub->ports[i];
if (p->device)
err = p->device->address;
}
di->udi_ports[i] = err;
}
- di->udi_nports = dev->hub->hubdesc.bNbrPorts;
+ di->udi_nports = dev->hub->nports;
} else
di->udi_nports = 0;