Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/commands.h

    re2172284 rae3a941  
    144144extern errno_t xhci_cmd_async_fini(xhci_hc_t *, xhci_cmd_t *);
    145145
     146static inline errno_t xhci_cmd_sync_inline_wrapper(xhci_hc_t *hc, xhci_cmd_t cmd)
     147{
     148        /* Poor man's xhci_cmd_init (everything else is zeroed) */
     149        link_initialize(&cmd._header.link);
     150        fibril_mutex_initialize(&cmd._header.completed_mtx);
     151        fibril_condvar_initialize(&cmd._header.completed_cv);
     152
     153        /* Issue the command */
     154        const errno_t err = xhci_cmd_sync(hc, &cmd);
     155        xhci_cmd_fini(&cmd);
     156
     157        return err;
     158}
     159
     160/** The inline macro expects:
     161 *    - hc      - HC to schedule command on (xhci_hc_t *).
     162 *    - command - Member of `xhci_cmd_type_t` without the "XHCI_CMD_" prefix.
     163 *    - VA_ARGS - (optional) Command arguments in struct initialization notation.
     164 *
     165 *  The return code and semantics matches those of `xhci_cmd_sync_fini`.
     166 *
     167 *  Example:
     168 *    errno_t err = xhci_cmd_sync_inline(hc, DISABLE_SLOT, .slot_id = 42);
     169 */
     170
     171#define xhci_cmd_sync_inline(hc, command, ...) \
     172        xhci_cmd_sync_inline_wrapper(hc, \
     173        (xhci_cmd_t) { ._header.cmd = XHCI_CMD_##command, ##__VA_ARGS__ })
     174
    146175#endif
    147176
Note: See TracChangeset for help on using the changeset viewer.