Changeset 3bacee1 in mainline for uspace/drv/bus/usb/xhci/hc.c


Ignore:
Timestamp:
2018-04-12T16:27:17Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3cf22f9
Parents:
76d0981d
git-author:
Jiri Svoboda <jiri@…> (2018-04-11 19:25:33)
git-committer:
Jiri Svoboda <jiri@…> (2018-04-12 16:27:17)
Message:

Make ccheck-fix again and commit more good files.

File:
1 edited

Legend:

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

    r76d0981d r3bacee1  
    8787        xhci_port_speed_t *speeds = hc->speeds;
    8888
    89         for (xhci_extcap_t *ec = hc->xecp; ec; ec = xhci_extcap_next(ec)) {
     89        for (xhci_extcap_t * ec = hc->xecp; ec; ec = xhci_extcap_next(ec)) {
    9090                xhci_dump_extcap(ec);
    9191                switch (XHCI_REG_RD(ec, XHCI_EC_CAP_ID)) {
     
    151151                                         * mapping also for devices connected to hubs.
    152152                                         */
    153                                         if (psiv < ARRAY_SIZE(default_psiv_to_port_speed)
    154                                            && default_psiv_to_port_speed[psiv].major == major
    155                                            && default_psiv_to_port_speed[psiv].minor == minor
    156                                            && default_psiv_to_port_speed[psiv].rx_bps == bps
    157                                            && default_psiv_to_port_speed[psiv].tx_bps == bps) {
     153                                        if (psiv < ARRAY_SIZE(default_psiv_to_port_speed) &&
     154                                            default_psiv_to_port_speed[psiv].major == major &&
     155                                            default_psiv_to_port_speed[psiv].minor == minor &&
     156                                            default_psiv_to_port_speed[psiv].rx_bps == bps &&
     157                                            default_psiv_to_port_speed[psiv].tx_bps == bps) {
    158158                                                speeds[psiv] = default_psiv_to_port_speed[psiv];
    159159                                                usb_log_debug("Assumed default %s speed of USB %u.",
    160                                                         usb_str_speed(speeds[psiv].usb_speed), major);
     160                                                    usb_str_speed(speeds[psiv].usb_speed), major);
    161161                                                continue;
    162162                                        }
     
    173173                                                speeds[psiv].tx_bps = bps;
    174174                                                usb_log_debug("Speed %u set up for bps %" PRIu64
    175                                                         " / %" PRIu64 ".", psiv, speeds[psiv].rx_bps,
    176                                                         speeds[psiv].tx_bps);
     175                                                    " / %" PRIu64 ".", psiv, speeds[psiv].rx_bps,
     176                                                    speeds[psiv].tx_bps);
    177177                                        }
    178178                                }
     
    384384        code->rangecount = 1;
    385385        code->ranges[0] = (irq_pio_range_t) {
    386             .base = RNGABS(hc->mmio_range),
    387             .size = RNGSZ(hc->mmio_range),
     386                .base = RNGABS(hc->mmio_range),
     387                .size = RNGSZ(hc->mmio_range),
    388388        };
    389389
     
    391391        memcpy(code->cmds, irq_commands, sizeof(irq_commands));
    392392
    393         void *intr0_iman = RNGABSPTR(hc->mmio_range)
    394             + XHCI_REG_RD(hc->cap_regs, XHCI_CAP_RTSOFF)
    395             + offsetof(xhci_rt_regs_t, ir[0]);
    396         void *usbsts = RNGABSPTR(hc->mmio_range)
    397             + XHCI_REG_RD(hc->cap_regs, XHCI_CAP_LENGTH)
    398             + offsetof(xhci_op_regs_t, usbsts);
     393        void *intr0_iman = RNGABSPTR(hc->mmio_range) +
     394            XHCI_REG_RD(hc->cap_regs, XHCI_CAP_RTSOFF) +
     395            offsetof(xhci_rt_regs_t, ir[0]);
     396        void *usbsts = RNGABSPTR(hc->mmio_range) +
     397            XHCI_REG_RD(hc->cap_regs, XHCI_CAP_LENGTH) +
     398            offsetof(xhci_op_regs_t, usbsts);
    399399
    400400        code->cmds[0].addr = intr0_iman;
     
    425425        for (int i = 0; i <= (XHCI_LEGSUP_BIOS_TIMEOUT_US / XHCI_LEGSUP_POLLING_DELAY_1MS); i++) {
    426426                usb_log_debug("LEGSUP: elapsed: %i ms, bios: %x, os: %x", i,
    427                         XHCI_REG_RD(hc->legsup, XHCI_LEGSUP_SEM_BIOS),
    428                         XHCI_REG_RD(hc->legsup, XHCI_LEGSUP_SEM_OS));
     427                    XHCI_REG_RD(hc->legsup, XHCI_LEGSUP_SEM_BIOS),
     428                    XHCI_REG_RD(hc->legsup, XHCI_LEGSUP_SEM_OS));
    429429                if (XHCI_REG_RD(hc->legsup, XHCI_LEGSUP_SEM_BIOS) == 0) {
    430430                        return XHCI_REG_RD(hc->legsup, XHCI_LEGSUP_SEM_OS) == 1 ? EOK : EIO;
     
    559559        const uint32_t usbsts = XHCI_REG_RD_FIELD(&hc->op_regs->usbsts, 32);
    560560
    561         return !(usbcmd & XHCI_REG_MASK(XHCI_OP_RS))
    562             ||  (usbsts & XHCI_REG_MASK(XHCI_OP_HCE))
    563             ||  (usbsts & XHCI_REG_MASK(XHCI_OP_HSE));
     561        return !(usbcmd & XHCI_REG_MASK(XHCI_OP_RS)) ||
     562            (usbsts & XHCI_REG_MASK(XHCI_OP_HCE)) ||
     563            (usbsts & XHCI_REG_MASK(XHCI_OP_HSE));
    564564}
    565565
     
    589589        struct timeval tv;
    590590        getuptime(&tv);
    591         usb_log_debug("Microframe index wrapped (@%lu.%li, %"PRIu64" total).",
     591        usb_log_debug("Microframe index wrapped (@%lu.%li, %" PRIu64 " total).",
    592592            tv.tv_sec, tv.tv_usec, hc->wrap_count);
    593593        hc->wrap_time = ((uint64_t) tv.tv_sec) * 1000000 + ((uint64_t) tv.tv_usec);
     
    634634        errno_t err;
    635635        xhci_trb_t trb;
    636         xhci_hc_t * const hc = arg;
     636        xhci_hc_t *const hc = arg;
    637637        assert(hc);
    638638
     
    654654 */
    655655static void hc_run_event_ring(xhci_hc_t *hc, xhci_event_ring_t *event_ring,
    656         xhci_interrupter_regs_t *intr)
     656    xhci_interrupter_regs_t *intr)
    657657{
    658658        errno_t err;
     
    720720        if (status) {
    721721                usb_log_error("Non-zero status after interrupt handling (%08x) "
    722                         " - missing something?", status);
     722                    " - missing something?", status);
    723723        }
    724724}
     
    766766{
    767767        return (2 * ep->base.endpoint) +
    768                 (ep->base.transfer_type == USB_TRANSFER_CONTROL
    769                  || ep->base.direction == USB_DIRECTION_IN);
     768            (ep->base.transfer_type == USB_TRANSFER_CONTROL ||
     769            ep->base.direction == USB_DIRECTION_IN);
    770770}
    771771
    772772void hc_ring_ep_doorbell(xhci_endpoint_t *ep, uint32_t stream_id)
    773773{
    774         xhci_device_t * const dev = xhci_ep_to_dev(ep);
    775         xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
     774        xhci_device_t *const dev = xhci_ep_to_dev(ep);
     775        xhci_hc_t *const hc = bus_to_hc(dev->base.bus);
    776776        const uint8_t dci = endpoint_dci(ep);
    777777        const uint32_t target = (stream_id << 16) | (dci & 0x1ff);
     
    786786{
    787787        errno_t err;
    788         xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
     788        xhci_hc_t *const hc = bus_to_hc(dev->base.bus);
    789789
    790790        /* Prepare memory for the context */
     
    821821{
    822822        errno_t err;
    823         xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
     823        xhci_hc_t *const hc = bus_to_hc(dev->base.bus);
    824824        xhci_cmd_t cmd;
    825825
     
    846846static errno_t create_configure_ep_input_ctx(xhci_device_t *dev, dma_buffer_t *dma_buf)
    847847{
    848         const xhci_hc_t * hc = bus_to_hc(dev->base.bus);
     848        const xhci_hc_t *hc = bus_to_hc(dev->base.bus);
    849849        const errno_t err = dma_buffer_alloc(dma_buf, XHCI_INPUT_CTX_SIZE(hc));
    850850        if (err)
     
    870870{
    871871        errno_t err = ENOMEM;
    872         xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
     872        xhci_hc_t *const hc = bus_to_hc(dev->base.bus);
    873873        xhci_endpoint_t *ep0 = xhci_endpoint_get(dev->base.endpoints[0]);
    874874
     
    920920errno_t hc_configure_device(xhci_device_t *dev)
    921921{
    922         xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
     922        xhci_hc_t *const hc = bus_to_hc(dev->base.bus);
    923923        xhci_cmd_t cmd;
    924924
     
    945945errno_t hc_deconfigure_device(xhci_device_t *dev)
    946946{
    947         xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
     947        xhci_hc_t *const hc = bus_to_hc(dev->base.bus);
    948948        xhci_cmd_t cmd;
    949949        errno_t err;
     
    972972errno_t hc_add_endpoint(xhci_endpoint_t *ep)
    973973{
    974         xhci_device_t * const dev = xhci_ep_to_dev(ep);
     974        xhci_device_t *const dev = xhci_ep_to_dev(ep);
    975975        const unsigned dci = endpoint_dci(ep);
    976976        xhci_cmd_t cmd;
     
    984984        xhci_input_ctx_t *ictx = ictx_dma_buf.virt;
    985985
    986         xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
     986        xhci_hc_t *const hc = bus_to_hc(dev->base.bus);
    987987        XHCI_INPUT_CTRL_CTX_ADD_SET(*XHCI_GET_CTRL_CTX(ictx, hc), dci);
    988988
     
    10071007errno_t hc_drop_endpoint(xhci_endpoint_t *ep)
    10081008{
    1009         xhci_device_t * const dev = xhci_ep_to_dev(ep);
    1010         xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
     1009        xhci_device_t *const dev = xhci_ep_to_dev(ep);
     1010        xhci_hc_t *const hc = bus_to_hc(dev->base.bus);
    10111011        const unsigned dci = endpoint_dci(ep);
    10121012        xhci_cmd_t cmd;
     
    10431043errno_t hc_update_endpoint(xhci_endpoint_t *ep)
    10441044{
    1045         xhci_device_t * const dev = xhci_ep_to_dev(ep);
     1045        xhci_device_t *const dev = xhci_ep_to_dev(ep);
    10461046        const unsigned dci = endpoint_dci(ep);
    10471047        xhci_cmd_t cmd;
    10481048
    10491049        dma_buffer_t ictx_dma_buf;
    1050         xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
     1050        xhci_hc_t *const hc = bus_to_hc(dev->base.bus);
    10511051
    10521052        errno_t err = dma_buffer_alloc(&ictx_dma_buf, XHCI_INPUT_CTX_SIZE(hc));
     
    10781078errno_t hc_stop_endpoint(xhci_endpoint_t *ep)
    10791079{
    1080         xhci_device_t * const dev = xhci_ep_to_dev(ep);
     1080        xhci_device_t *const dev = xhci_ep_to_dev(ep);
    10811081        const unsigned dci = endpoint_dci(ep);
    1082         xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
     1082        xhci_hc_t *const hc = bus_to_hc(dev->base.bus);
    10831083        xhci_cmd_t cmd;
    10841084        errno_t err;
     
    11041104errno_t hc_reset_endpoint(xhci_endpoint_t *ep)
    11051105{
    1106         xhci_device_t * const dev = xhci_ep_to_dev(ep);
     1106        xhci_device_t *const dev = xhci_ep_to_dev(ep);
    11071107        const unsigned dci = endpoint_dci(ep);
    1108         xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
     1108        xhci_hc_t *const hc = bus_to_hc(dev->base.bus);
    11091109        xhci_cmd_t cmd;
    11101110        errno_t err;
     
    11261126errno_t hc_reset_ring(xhci_endpoint_t *ep, uint32_t stream_id)
    11271127{
    1128         xhci_device_t * const dev = xhci_ep_to_dev(ep);
     1128        xhci_device_t *const dev = xhci_ep_to_dev(ep);
    11291129        const unsigned dci = endpoint_dci(ep);
    11301130        uintptr_t addr;
     
    11351135        xhci_trb_ring_reset_dequeue_state(ring, &addr);
    11361136
    1137         xhci_hc_t * const hc = bus_to_hc(endpoint_get_bus(&ep->base));
     1137        xhci_hc_t *const hc = bus_to_hc(endpoint_get_bus(&ep->base));
    11381138
    11391139        xhci_cmd_init(&cmd, XHCI_CMD_SET_TR_DEQUEUE_POINTER);
Note: See TracChangeset for help on using the changeset viewer.