Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 957ea3a in mainline


Ignore:
Timestamp:
2018-01-15T20:13:40Z (4 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master
Children:
309d9865
Parents:
9ff99e8
Message:

usbhub: make adding device readable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhub/port.c

    r9ff99e8 r957ea3a  
    389389        assert(params);
    390390
     391        bool release_default_address = false;
     392
    391393        int ret = EOK;
    392394        usb_hub_dev_t *hub = params->hub;
     
    410412        }
    411413        if (ret != EOK) {
    412                 usb_log_error("(%p-%u): Failed to reserve default address: %s",
    413                     hub, port->port_number, str_error(ret));
     414                usb_log_error("(%p-%u): Failed to reserve default address: %s", hub, port->port_number, str_error(ret));
    414415                goto out;
    415416        }
    416 
    417         usb_log_debug("(%p-%u): Got default address reseting port.", hub,
    418             port->port_number);
     417        release_default_address = true;
     418
     419        usb_log_debug("(%p-%u): Got default address. Reseting port.", hub, port->port_number);
     420
    419421        /* Reset port */
    420         ret = port_enable(port, hub, true);
    421         if (ret != EOK) {
    422                 usb_log_error("(%p-%u): Failed to reset port.", hub,
    423                     port->port_number);
    424                 if (usbhc_release_default_address(exch) != EOK)
    425                         usb_log_warning("(%p-%u): Failed to release default "
    426                             "address.", hub, port->port_number);
     422        if ((ret = port_enable(port, hub, true))) {
     423                usb_log_error("(%p-%u): Failed to reset port.", hub, port->port_number);
    427424                ret = EIO;
    428                 goto out;
    429         }
    430         usb_log_debug("(%p-%u): Port reset, enumerating device", hub,
    431             port->port_number);
    432 
    433         ret = usbhc_device_enumerate(exch, port->port_number);
    434         if (ret != EOK) {
    435                 usb_log_error("(%p-%u): Failed to enumerate device: %s", hub,
    436                     port->port_number, str_error(ret));
    437                 const int ret = port_enable(port, hub, false);
    438                 if (ret != EOK) {
    439                         usb_log_warning("(%p-%u)Failed to disable port (%s), "
    440                             "NOT releasing default address.", hub,
    441                             port->port_number, str_error(ret));
    442                 } else {
    443                         const int ret = usbhc_release_default_address(exch);
    444                         if (ret != EOK)
    445                                 usb_log_warning("(%p-%u): Failed to release "
    446                                     "default address: %s", hub,
    447                                     port->port_number, str_error(ret));
    448                 }
    449         } else {
    450                 usb_log_debug("(%p-%u): Device enumerated", hub,
    451                     port->port_number);
    452                 port->device_attached = true;
    453                 if (usbhc_release_default_address(exch) != EOK)
    454                         usb_log_warning("(%p-%u): Failed to release default "
    455                             "address", hub, port->port_number);
    456         }
     425                goto out_address;
     426        }
     427
     428        usb_log_debug("(%p-%u): Port reset, enumerating device", hub, port->port_number);
     429
     430        if ((ret = usbhc_device_enumerate(exch, port->port_number))) {
     431                usb_log_error("(%p-%u): Failed to enumerate device: %s", hub, port->port_number, str_error(ret));
     432                goto out_port;
     433        }
     434
     435        usb_log_debug("(%p-%u): Device enumerated", hub, port->port_number);
     436        port->device_attached = true;
     437
     438out_port:
     439        if (!port->device_attached && (ret = port_enable(port, hub, false))) {
     440                usb_log_warning("(%p-%u)Failed to disable port (%s), NOT releasing default address.", hub, port->port_number, str_error(ret));
     441                release_default_address = false;
     442        }
     443
     444out_address:
     445        if (release_default_address && (ret = usbhc_release_default_address(exch)))
     446                usb_log_warning("(%p-%u): Failed to release default address: %s", hub, port->port_number, str_error(ret));
     447
    457448out:
    458449        usb_device_bus_exchange_end(exch);
Note: See TracChangeset for help on using the changeset viewer.