Changeset 9ee13a7 in mainline


Ignore:
Timestamp:
2017-08-09T17:05:08Z (7 years ago)
Author:
Jaroslav Jindrak <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d31705d
Parents:
6fa91e4c
Message:

Fixed deallocation, corrected cstyle, removed trailing whitespace, removed unnecessary slot enable command tests in hc_schedule.

Location:
uspace/drv/bus/usb/xhci
Files:
2 edited

Legend:

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

    r6fa91e4c r9ee13a7  
    367367        xhci_free_command(cmd);
    368368
    369         for (int i = 0; i < 10; ++i) {
    370                 xhci_cmd_t *cmd2 = xhci_alloc_command();
    371                 xhci_send_enable_slot_command(hc, cmd2);
    372                 xhci_wait_for_command(cmd2, 1000000);
    373                 usb_log_error("Enabled slot ID: %u.", cmd2->slot_id);
    374                 xhci_free_command(cmd2);
    375         }
    376 
    377369        return EOK;
    378370}
  • uspace/drv/bus/usb/xhci/rh.c

    r6fa91e4c r9ee13a7  
    8282
    8383        // TODO: where do we save this? the ring should be associated with device structure somewhere
    84         xhci_trb_ring_t* ep_ring = malloc32(sizeof(xhci_trb_ring_t));
     84        xhci_trb_ring_t *ep_ring = malloc32(sizeof(xhci_trb_ring_t));
    8585        if (!ep_ring) {
    8686                err = ENOMEM;
    87                 goto err_ring;   
    88         }
     87                goto err_ictx;
     88        }
     89
    8990        err = xhci_trb_ring_init(ep_ring, hc);
    90         if (err) {
    91                 xhci_trb_ring_fini(ep_ring);
     91        if (err)
    9292                goto err_ring;
    93         }
    94 
    95         xhci_port_regs_t* regs = &hc->op_regs->portrs[port - 1];
     93
     94        xhci_port_regs_t *regs = &hc->op_regs->portrs[port - 1];
    9695        uint8_t port_speed_id = XHCI_REG_RD(regs, XHCI_PORT_PS);
    9796
    9897        XHCI_EP_TYPE_SET(ictx->endpoint_ctx[0], 4);
    99         XHCI_EP_MAX_PACKET_SIZE_SET(ictx->endpoint_ctx[0], 
     98        XHCI_EP_MAX_PACKET_SIZE_SET(ictx->endpoint_ctx[0],
    10099            hc->speeds[port_speed_id].tx_bps);
    101100        XHCI_EP_MAX_BURST_SIZE_SET(ictx->endpoint_ctx[0], 0);
     
    106105        XHCI_EP_MULT_SET(ictx->endpoint_ctx[0], 0);
    107106        XHCI_EP_ERROR_COUNT_SET(ictx->endpoint_ctx[0], 3);
    108        
     107
    109108        // TODO: What's the alignment?
    110109        xhci_device_ctx_t *dctx = malloc32(sizeof(xhci_device_ctx_t));
    111110        if (!dctx) {
    112111                err = ENOMEM;
    113                 goto err_ctx;
     112                goto err_ring;
    114113        }
    115114        memset(dctx, 0, sizeof(xhci_device_ctx_t));
    116        
     115
    117116        hc->dcbaa[slot_id] = addr_to_phys(dctx);
    118117        hc->dcbaa_virt[slot_id] = dctx;
    119        
     118
    120119        cmd = xhci_alloc_command();
    121120        cmd->ictx = ictx;
    122121        xhci_send_address_device_command(hc, cmd);
    123122        if ((err = xhci_wait_for_command(cmd, 100000)) != EOK)
    124                 goto err_ctx;
    125 
    126         return EOK;
    127 
    128 err_ctx:
     123                goto err_dctx;
     124
     125        return EOK;
     126
     127err_dctx:
     128        if (dctx) {
     129                free32(dctx);
     130                hc->dcbaa[slot_id] = 0;
     131                hc->dcbaa_virt[slot_id] = NULL;
     132        }
     133err_ring:
     134        if (ep_ring) {
     135                xhci_trb_ring_fini(ep_ring);
     136                free32(ep_ring);
     137        }
     138err_ictx:
    129139        if (ictx) {
    130140                /* Avoid double free. */
    131141                if (cmd && cmd->ictx && cmd->ictx == ictx)
    132142                        cmd->ictx = NULL;
    133         }
    134 err_ring:
    135         if (ep_ring)
    136                 free32(ep_ring);
     143                free32(ictx);
     144        }
    137145err_command:
    138146        if (cmd)
Note: See TracChangeset for help on using the changeset viewer.