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


Ignore:
Timestamp:
2017-10-25T08:03:13Z (6 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a5b3de6
Parents:
0206d35
Message:

Big command refactoring. Unified and encapsulated command function API. Removed explicit heap command (de)allocation functions. Added three functions for (a)synchronous command issuing and neat inline macro with syntax sugar.

File:
1 edited

Legend:

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

    r0206d35 rc3d926f  
    374374        // ctx is an out parameter as of now
    375375        assert(dev);
    376 
    377         ctx = malloc(sizeof(xhci_port_bandwidth_ctx_t));
    378         if(!ctx)
     376        assert(ctx);
     377
     378        xhci_port_bandwidth_ctx_t *in_ctx = malloc32(sizeof(xhci_port_bandwidth_ctx_t));
     379        if (!in_ctx) {
    379380                return ENOMEM;
     381        }
    380382
    381383        xhci_cmd_t cmd;
    382         xhci_cmd_init(&cmd);
    383 
    384         xhci_get_port_bandwidth_command(dev->hc, &cmd, ctx, speed);
    385 
    386         int err = xhci_cmd_wait(&cmd, XHCI_DEFAULT_TIMEOUT);
    387         if(err != EOK) {
    388                 free(ctx);
    389                 ctx = NULL;
    390         }
    391 
     384        xhci_cmd_init(&cmd, XHCI_CMD_GET_PORT_BANDWIDTH);
     385
     386        cmd.bandwidth_ctx = in_ctx;
     387        cmd.device_speed = speed;
     388
     389        int err;
     390        if ((err = xhci_cmd_sync(dev->hc, &cmd))) {
     391                goto end;
     392        }
     393
     394        memcpy(ctx, in_ctx, sizeof(xhci_port_bandwidth_ctx_t));
     395
     396end:
     397        xhci_cmd_fini(&cmd);
    392398        return EOK;
    393399}
Note: See TracChangeset for help on using the changeset viewer.