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


Ignore:
Timestamp:
2017-11-14T23:17:54Z (6 years ago)
Author:
Aearsis <Hlavaty.Ondrej@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e76c0ea
Parents:
cfe4852
git-author:
Aearsis <Hlavaty.Ondrej@…> (2017-11-14 23:15:24)
git-committer:
Aearsis <Hlavaty.Ondrej@…> (2017-11-14 23:17:54)
Message:

xhci: use dma_buffers instead of malloc32 util

A bit of refactoring was needed to adapt scratchpad buffers.

File:
1 edited

Legend:

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

    rcfe4852 rb80c1ab  
    3838#include <usb/request.h>
    3939#include <usb/debug.h>
    40 #include <usb/host/utils/malloc32.h>
    4140#include <usb/host/bus.h>
    4241#include <usb/host/ddf_helpers.h>
     42#include <usb/host/dma_buffer.h>
    4343#include <usb/host/hcd.h>
    4444
     
    305305}
    306306
    307 static inline int get_hub_available_bandwidth(xhci_hc_t *hc, xhci_device_t* dev, uint8_t speed, xhci_port_bandwidth_ctx_t *ctx) {
     307static inline int get_hub_available_bandwidth(xhci_hc_t *hc, xhci_device_t* dev, uint8_t speed, xhci_port_bandwidth_ctx_t *ctx)
     308{
     309        int err = EOK;
     310
    308311        // TODO: find a correct place for this function + API
    309312        // We need speed, because a root hub device has both USB 2 and USB 3 speeds
     
    313316        assert(ctx);
    314317
    315         xhci_port_bandwidth_ctx_t *in_ctx = malloc32(sizeof(xhci_port_bandwidth_ctx_t));
    316         if (!in_ctx) {
    317                 return ENOMEM;
    318         }
    319 
    320318        xhci_cmd_t cmd;
    321319        xhci_cmd_init(&cmd, XHCI_CMD_GET_PORT_BANDWIDTH);
    322320
    323         cmd.bandwidth_ctx = in_ctx;
     321        if ((err = dma_buffer_alloc(&cmd.bandwidth_ctx, sizeof(xhci_port_bandwidth_ctx_t))))
     322                goto end;
     323
    324324        cmd.device_speed = speed;
    325325
    326         int err;
    327         if ((err = xhci_cmd_sync(hc, &cmd))) {
     326        if ((err = xhci_cmd_sync(hc, &cmd)))
    328327                goto end;
    329         }
    330 
    331         memcpy(ctx, in_ctx, sizeof(xhci_port_bandwidth_ctx_t));
     328
     329        memcpy(ctx, cmd.bandwidth_ctx.virt, sizeof(xhci_port_bandwidth_ctx_t));
    332330
    333331end:
    334332        xhci_cmd_fini(&cmd);
    335         return EOK;
     333        return err;
    336334}
    337335
Note: See TracChangeset for help on using the changeset viewer.