Changeset 296d22fc in mainline


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

usbhub: revert the runtime binding of bus methods

It was just a dead end.

Location:
uspace/lib/usbhost
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/bus.h

    rd369b3b r296d22fc  
    102102 */
    103103struct bus_ops {
    104         /* Undefined operations will be delegated to parent ops */
    105         const bus_ops_t *parent;
    106 
    107104        /* Global operations on the bus */
    108105        void (*interrupt)(bus_t *, uint32_t);
     
    126123        void (*batch_destroy)(usb_transfer_batch_t *);          /**< Optional */
    127124};
    128 
    129 /**
    130  * Use this macro to lookup virtual function.
    131  */
    132 #define BUS_OPS_LOOKUP(start, fn) ({ bus_ops_t const * ops = (start); while (ops && ops->fn == NULL) ops = ops->parent; ops; })
    133125
    134126/** Endpoint management structure */
  • uspace/lib/usbhost/src/bus.c

    rd369b3b r296d22fc  
    129129        assert(dev);
    130130
    131         const bus_ops_t *ops = BUS_OPS_LOOKUP(dev->bus->ops, device_enumerate);
    132         if (!ops)
     131        if (!dev->bus->ops->device_enumerate)
    133132                return ENOTSUP;
    134133
     
    138137        device_setup_tt(dev);
    139138
    140         const int r = ops->device_enumerate(dev);
     139        const int r = dev->bus->ops->device_enumerate(dev);
    141140        if (r)
    142141                return r;
     
    208207        assert(dev->fun != NULL);
    209208
    210         const bus_ops_t *ops = BUS_OPS_LOOKUP(dev->bus->ops, device_gone);
    211         const bus_ops_t *ep_ops = BUS_OPS_LOOKUP(dev->bus->ops, endpoint_unregister);
     209        const bus_ops_t *ops = dev->bus->ops;
    212210
    213211        /* First, block new transfers and operations. */
     
    241239
    242240        /* Tell the HC to release its resources. */
    243         if (ops)
     241        if (ops->device_gone)
    244242                ops->device_gone(dev);
    245243
    246244        /* Check whether the driver didn't forgot EP0 */
    247245        if (dev->endpoints[0]) {
    248                 if (ep_ops)
    249                         ep_ops->endpoint_unregister(dev->endpoints[0]);
     246                if (ops->endpoint_unregister)
     247                        ops->endpoint_unregister(dev->endpoints[0]);
    250248                /* Release the EP0 bus reference */
    251249                endpoint_del_ref(dev->endpoints[0]);
     
    271269
    272270        /* First, tell the HC driver. */
    273         const bus_ops_t *ops = BUS_OPS_LOOKUP(dev->bus->ops, device_online);
    274         if (ops && (rc = ops->device_online(dev))) {
     271        const bus_ops_t *ops = dev->bus->ops;
     272        if (ops->device_online && (rc = ops->device_online(dev))) {
    275273                usb_log_warning("Host controller failed to make device '%s' online: %s",
    276274                    ddf_fun_get_name(dev->fun), str_error(rc));
     
    329327
    330328        /* Tell also the HC driver. */
    331         const bus_ops_t *ops = BUS_OPS_LOOKUP(dev->bus->ops, device_offline);
    332         if (ops)
     329        const bus_ops_t *ops = dev->bus->ops;
     330        if (ops->device_offline)
    333331                ops->device_offline(dev);
    334332
     
    365363        bus_t *bus = device->bus;
    366364
    367         const bus_ops_t *register_ops = BUS_OPS_LOOKUP(bus->ops, endpoint_register);
    368         if (!register_ops)
     365        if (!bus->ops->endpoint_register)
    369366                return ENOTSUP;
    370367
    371         const bus_ops_t *create_ops = BUS_OPS_LOOKUP(bus->ops, endpoint_create);
    372368        endpoint_t *ep;
    373         if (create_ops) {
    374                 ep = create_ops->endpoint_create(device, desc);
     369        if (bus->ops->endpoint_create) {
     370                ep = bus->ops->endpoint_create(device, desc);
    375371                if (!ep)
    376372                        return ENOMEM;
     
    410406                err = EEXIST;
    411407        } else {
    412                 err = register_ops->endpoint_register(ep);
     408                err = bus->ops->endpoint_register(ep);
    413409                if (!err)
    414410                        device->endpoints[idx] = ep;
     
    480476        bus_t *bus = device->bus;
    481477
    482         const bus_ops_t *ops = BUS_OPS_LOOKUP(bus->ops, endpoint_unregister);
    483         if (!ops)
     478        if (!bus->ops->endpoint_unregister)
    484479                return ENOTSUP;
    485480
     
    496491
    497492        fibril_mutex_lock(&device->guard);
    498         ops->endpoint_unregister(ep);
     493        bus->ops->endpoint_unregister(ep);
    499494        device->endpoints[idx] = NULL;
    500495        fibril_mutex_unlock(&device->guard);
  • uspace/lib/usbhost/src/endpoint.c

    rd369b3b r296d22fc  
    9797static inline void endpoint_destroy(endpoint_t *ep)
    9898{
    99         const bus_ops_t *ops = BUS_OPS_LOOKUP(get_bus_ops(ep), endpoint_destroy);
    100         if (ops) {
     99        const bus_ops_t *ops = get_bus_ops(ep);
     100        if (ops->endpoint_destroy) {
    101101                ops->endpoint_destroy(ep);
    102102        } else {
     
    237237        }
    238238
    239         const bus_ops_t *ops = BUS_OPS_LOOKUP(device->bus->ops, batch_schedule);
    240         if (!ops) {
     239        const bus_ops_t *ops = device->bus->ops;
     240        if (!ops->batch_schedule) {
    241241                usb_log_error("HCD does not implement scheduler.");
    242242                return ENOTSUP;
  • uspace/lib/usbhost/src/hcd.c

    rd369b3b r296d22fc  
    100100        hc_device_t *hcd = dev_to_hcd(dev);
    101101
    102         const bus_ops_t *ops = BUS_OPS_LOOKUP(hcd->bus->ops, interrupt);
    103         assert(ops);
    104 
    105102        const uint32_t status = IPC_GET_ARG1(*call);
    106         ops->interrupt(hcd->bus, status);
     103        hcd->bus->ops->interrupt(hcd->bus, status);
    107104}
    108105
     
    115112        assert(bus);
    116113
    117         const bus_ops_t *interrupt_ops = BUS_OPS_LOOKUP(bus->ops, interrupt);
    118         const bus_ops_t *status_ops = BUS_OPS_LOOKUP(bus->ops, status);
    119         if (!interrupt_ops || !status_ops)
     114        if (!bus->ops->interrupt || !bus->ops->status)
    120115                return ENOTSUP;
    121116
    122117        uint32_t status = 0;
    123         while (status_ops->status(bus, &status) == EOK) {
    124                 interrupt_ops->interrupt(bus, status);
     118        while (bus->ops->status(bus, &status) == EOK) {
     119                bus->ops->interrupt(bus, status);
    125120                status = 0;
    126121                /* We should wait 1 frame - 1ms here, but this polling is a
     
    265260        }
    266261
    267         const bus_ops_t *ops = BUS_OPS_LOOKUP(hcd->bus->ops, status);
     262        const bus_ops_t *ops = hcd->bus->ops;
    268263
    269264        /* Need working irq replacement to setup root hub */
    270         if (hcd->irq_cap < 0 && ops) {
     265        if (hcd->irq_cap < 0 && ops->status) {
    271266                hcd->polling_fibril = fibril_create(interrupt_polling, hcd->bus);
    272267                if (!hcd->polling_fibril) {
  • uspace/lib/usbhost/src/usb_transfer_batch.c

    rd369b3b r296d22fc  
    5454
    5555        bus_t *bus = endpoint_get_bus(ep);
    56         const bus_ops_t *ops = BUS_OPS_LOOKUP(bus->ops, batch_create);
    5756
    58         if (!ops) {
     57        if (!bus->ops->batch_create) {
    5958                usb_transfer_batch_t *batch = calloc(1, sizeof(usb_transfer_batch_t));
    6059                if (!batch)
     
    6463        }
    6564
    66         return ops->batch_create(ep);
     65        return bus->ops->batch_create(ep);
    6766}
    6867
     
    8786
    8887        bus_t *bus = endpoint_get_bus(batch->ep);
    89         const bus_ops_t *ops = BUS_OPS_LOOKUP(bus->ops, batch_destroy);
     88        endpoint_t *ep = batch->ep;
    9089
    91         /* Batch reference */
    92         endpoint_del_ref(batch->ep);
    93 
    94         if (ops) {
     90        if (bus->ops) {
    9591                usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " destroying.",
    9692                    batch, USB_TRANSFER_BATCH_ARGS(*batch));
    97                 ops->batch_destroy(batch);
     93                bus->ops->batch_destroy(batch);
    9894        }
    9995        else {
     
    10298                free(batch);
    10399        }
     100
     101        /* Batch reference */
     102        endpoint_del_ref(ep);
    104103}
    105104
Note: See TracChangeset for help on using the changeset viewer.