Changeset 56257ba in mainline for uspace/lib/usbhost/src/endpoint.c


Ignore:
Timestamp:
2018-01-07T01:01:42Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63431db
Parents:
9efad54
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-07 01:01:41)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-07 01:01:42)
Message:

usbhost: manage endpoints by library + get/set_toggle → reset_toggle

That simplifies things A LOT. Now you can find endpoints for device in
an array inside device. This array is managed automatically in
register/unregister endpoint. HC drivers still needs to write to it when
setting up/tearing down the device.

Sorry for these two changes being in one commit, but splitting them
would be simply more work for no benefit.

File:
1 edited

Legend:

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

    r9efad54 r56257ba  
    108108}
    109109
     110static void endpoint_toggle_reset(endpoint_t *ep, toggle_reset_mode_t mode);
     111
    110112/** Mark the endpoint as active and block access for further fibrils.
    111113 * @param ep endpoint_t structure.
     
    132134
    133135        if (ep->active_batch && ep->active_batch->error == EOK)
    134                 usb_transfer_batch_reset_toggle(ep->active_batch);
     136                endpoint_toggle_reset(ep, ep->active_batch->toggle_reset_mode);
    135137
    136138        ep->active_batch = NULL;
     
    155157}
    156158
    157 /** Get the value of toggle bit. Either uses the toggle_get op, or just returns
    158  * the value of the toggle.
    159  * @param ep endpoint_t structure.
    160  */
    161 int endpoint_toggle_get(endpoint_t *ep)
    162 {
    163         assert(ep);
    164 
    165         const bus_ops_t *ops = BUS_OPS_LOOKUP(get_bus_ops(ep), endpoint_get_toggle);
    166         return ops
    167             ? ops->endpoint_get_toggle(ep)
    168             : ep->toggle;
    169 }
    170 
    171 /** Set the value of toggle bit. Either uses the toggle_set op, or just sets
    172  * the toggle inside.
    173  * @param ep endpoint_t structure.
    174  */
    175 void endpoint_toggle_set(endpoint_t *ep, bool toggle)
    176 {
    177         assert(ep);
    178 
    179         const bus_ops_t *ops = BUS_OPS_LOOKUP(get_bus_ops(ep), endpoint_set_toggle);
    180         if (ops) {
    181                 ops->endpoint_set_toggle(ep, toggle);
    182         }
    183         else {
    184                 ep->toggle = toggle;
     159static void endpoint_toggle_reset(endpoint_t *ep, toggle_reset_mode_t mode)
     160{
     161        assert(ep);
     162
     163        if (mode == RESET_NONE)
     164                return;
     165
     166        const bus_ops_t *ops = BUS_OPS_LOOKUP(get_bus_ops(ep), endpoint_toggle_reset);
     167        if (!ops)
     168                return;
     169
     170        device_t *dev = ep->device;
     171
     172        if (mode == RESET_ALL) {
     173                for (usb_endpoint_t i = 0; i < USB_ENDPOINT_MAX; ++i) {
     174                        if (dev->endpoints[i])
     175                                ops->endpoint_toggle_reset(dev->endpoints[i]);
     176                }
     177        } else {
     178                ops->endpoint_toggle_reset(ep);
    185179        }
    186180}
Note: See TracChangeset for help on using the changeset viewer.