Ignore:
Timestamp:
2017-12-14T23:01:57Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
837d53d
Parents:
bd05140
git-author:
Ondřej Hlavatý <aearsis@…> (2017-12-14 23:01:54)
git-committer:
Ondřej Hlavatý <aearsis@…> (2017-12-14 23:01:57)
Message:

usbhost bus: refactor the bus ops

This way, method names better represent the entity it is working with.
Their semantics was shifted a bit.

Regarding the tree of structures:

bus ← device ← endpoint ← batch

Previously, devices were kept in DDF function nodes, and endpoints had
pointer to the bus and device. Now, devices have pointer to bus,
endpoints don't.

Pointer to hcd_t in bus is WIP, and will be removed.

File:
1 edited

Legend:

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

    rbd05140 r6832245  
    4949{
    5050        assert(ep);
    51         assert(ep->bus);
    5251
    53         usb_transfer_batch_t *batch;
    54         if (ep->bus->ops.create_batch)
    55                 batch = ep->bus->ops.create_batch(ep->bus, ep);
    56         else
    57                 batch = calloc(1, sizeof(usb_transfer_batch_t));
     52        bus_t *bus = endpoint_get_bus(ep);
     53        const bus_ops_t *ops = BUS_OPS_LOOKUP(bus->ops, batch_create);
    5854
    59         return batch;
     55        if (!ops) {
     56                usb_transfer_batch_t *batch = calloc(1, sizeof(usb_transfer_batch_t));
     57                usb_transfer_batch_init(batch, ep);
     58                return batch;
     59        }
     60
     61        return ops->batch_create(ep);
    6062}
    6163
     
    6466void usb_transfer_batch_init(usb_transfer_batch_t *batch, endpoint_t *ep)
    6567{
     68        assert(ep);
     69        endpoint_add_ref(ep);
    6670        batch->ep = ep;
    6771}
     
    8286            batch->toggle_reset_mode == RESET_ALL ? "all EPs toggle" : "EP toggle");
    8387
    84         return bus_reset_toggle(batch->ep->bus, batch->target, batch->toggle_reset_mode);
     88        return bus_reset_toggle(endpoint_get_bus(batch->ep), batch->target, batch->toggle_reset_mode);
    8589}
    8690
     
    9397        assert(batch);
    9498        assert(batch->ep);
    95         assert(batch->ep->bus);
    9699
    97         bus_t *bus = batch->ep->bus;
    98         if (bus->ops.destroy_batch) {
     100        bus_t *bus = endpoint_get_bus(batch->ep);
     101        const bus_ops_t *ops = BUS_OPS_LOOKUP(bus->ops, batch_destroy);
     102
     103        endpoint_del_ref(batch->ep);
     104
     105        if (ops) {
    99106                usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " destroying.\n",
    100107                    batch, USB_TRANSFER_BATCH_ARGS(*batch));
    101                 bus->ops.destroy_batch(batch);
     108                ops->batch_destroy(batch);
    102109        }
    103110        else {
Note: See TracChangeset for help on using the changeset viewer.