Changeset 472235a in mainline for uspace/drv/bus/usb/xhci/rh.c


Ignore:
Timestamp:
2017-10-03T16:53:47Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
65e079b
Parents:
efe9463
Message:

xhci: refactoring

Revise error paths, refactor some code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/rh.c

    refe9463 r472235a  
    135135        xhci_cmd_fini(&cmd);
    136136
    137         // TODO: Issue configure endpoint commands (sec 4.3.5).
     137        // TODO: Issue configure endpoint commands (sec 4.3.5).
    138138
    139139        return EOK;
     
    165165                        usb_log_debug("Detected new device on port %u, port speed id %u.", port_id, port_speed);
    166166
    167                         alloc_dev(hc, port_id, 0);
     167                        return alloc_dev(hc, port_id, 0);
    168168                }
    169169                else if (link_state == 5) {
    170170                        /* USB 3 failed to enable. */
    171171                        usb_log_error("USB 3 port couldn't be enabled.");
     172                        return EAGAIN;
    172173                }
    173174                else {
    174175                        usb_log_error("USB 3 port is in invalid state %u.", link_state);
     176                        return EINVAL;
    175177                }
    176178        }
     
    183185                        going around?
    184186                */
    185         }
    186 
    187         return EOK;
     187                return EOK;
     188        }
    188189}
    189190
    190191int xhci_handle_port_status_change_event(xhci_hc_t *hc, xhci_trb_t *trb)
    191192{
     193        int err;
     194
    192195        uint8_t port_id = xhci_get_hub_port(trb);
    193196        usb_log_debug("Port status change event detected for port %u.", port_id);
     
    202205                usb_log_debug2("Detected port reset on port %u, port speed id %u.", port_id, port_speed);
    203206                /** FIXME: only if that port is not yet initialized */
    204                 alloc_dev(hc, port_id, 0);
     207                if ((err = alloc_dev(hc, port_id, 0)) != EOK)
     208                        return err;
    205209        }
    206210
     
    210214
    211215                if (XHCI_REG_RD(regs, XHCI_PORT_CCS) == 1) {
    212                         handle_connected_device(hc, regs, port_id);
     216                        if ((err = handle_connected_device(hc, regs, port_id)) != EOK)
     217                                return err;
    213218                } else {
    214219                        // TODO: Device disconnected
     220                        return ENOTSUP;
    215221                }
    216222        }
Note: See TracChangeset for help on using the changeset viewer.