Changeset 5f0b366 in mainline for uspace/lib/usbhost/src/usb2_bus.c


Ignore:
Timestamp:
2018-01-25T02:05:57Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b357377
Parents:
e8277c0
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-24 19:34:07)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-25 02:05:57)
Message:

usbhost: prepare bandwidth accounting privatization to usb2_bus

The endpoint does not account the bandwidth by default. The next step is
moving the count_bw callback to the usb2 bus.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/usb2_bus.c

    re8277c0 r5f0b366  
    210210
    211211/**
     212 * Call the bus operation to count bandwidth.
     213 *
     214 * @param ep Endpoint on which the transfer will take place.
     215 * @param size The payload size.
     216 */
     217static ssize_t endpoint_count_bw(endpoint_t *ep)
     218{
     219        assert(ep);
     220
     221        bus_t *bus = ep->device->bus;
     222        const bus_ops_t *ops = BUS_OPS_LOOKUP(bus->ops, endpoint_count_bw);
     223        if (!ops)
     224                return 0;
     225
     226        return ops->endpoint_count_bw(ep, ep->max_transfer_size);
     227}
     228
     229/**
    212230 * Register an endpoint to the bus. Reserves bandwidth.
    213231 */
     
    218236        assert(ep);
    219237
     238        size_t bw = endpoint_count_bw(ep);
     239
    220240        /* Check for available bandwidth */
    221         if (ep->bandwidth > bus->free_bw)
     241        if (bw > bus->free_bw)
    222242                return ENOSPC;
    223243
    224         bus->free_bw -= ep->bandwidth;
     244        bus->free_bw -= bw;
    225245
    226246        return EOK;
     
    235255        assert(ep);
    236256
    237         bus->free_bw += ep->bandwidth;
     257        bus->free_bw += endpoint_count_bw(ep);
    238258}
    239259
Note: See TracChangeset for help on using the changeset viewer.