assert ( iob_headroom ( iobuf ) >= sizeof ( *packet ) );
/* Fail immediately if device has been unplugged */
- if ( port->speed == USB_SPEED_NONE )
+ if ( port->disconnected )
return -ENODEV;
/* Reset endpoint if required */
int rc;
/* Fail immediately if device has been unplugged */
- if ( port->speed == USB_SPEED_NONE )
+ if ( port->disconnected )
return -ENODEV;
/* Reset endpoint if required */
if ( ( rc = hub->driver->speed ( hub, port ) ) != 0 ) {
DBGC ( hub, "USB hub %s port %d could not get speed: %s\n",
hub->name, port->address, strerror ( rc ) );
- goto err_speed;
+ /* Treat as a disconnection */
+ port->disconnected = 1;
+ port->speed = USB_SPEED_NONE;
}
/* Detach device, if applicable */
if ( port->attached && ( port->disconnected || ! port->speed ) )
usb_detached ( port );
+ /* Clear any recorded disconnections */
+ port->disconnected = 0;
+
/* Attach device, if applicable */
if ( port->speed && ( ! port->attached ) &&
( ( rc = usb_attached ( port ) ) != 0 ) )
- goto err_attached;
+ return rc;
- err_attached:
- err_speed:
- /* Clear any recorded disconnections */
- port->disconnected = 0;
- return rc;
+ return 0;
}
/******************************************************************************
unsigned int i;
/* If hub has been unplugged, mark all ports as unplugged */
- if ( usb->port->speed == USB_SPEED_NONE ) {
+ if ( usb->port->disconnected ) {
for ( i = 1 ; i <= hub->ports ; i++ ) {
port = usb_port ( hub, i );
+ port->disconnected = 1;
port->speed = USB_SPEED_NONE;
}
}