Changeset 816f5f4 in mainline for uspace/lib/usbhost/src/ddf_helpers.c


Ignore:
Timestamp:
2017-10-15T16:55:48Z (8 years ago)
Author:
Michal Staruch <salmelu@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9b2f69e
Parents:
2770b66
Message:

Remote USB (async) sending structures

remote_usb_register_endpoint is now sending a whole new structure, instead of 5 numeric arguments pulled out of structure.
This allows future extensibility for the structure as well as a working code to be used for other remote async calls.

File:
1 edited

Legend:

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

    r2770b66 r816f5f4  
    8686/** Register endpoint interface function.
    8787 * @param fun DDF function.
    88  * @param address USB address of the device.
    89  * @param endpoint USB endpoint number to be registered.
    90  * @param transfer_type Endpoint's transfer type.
    91  * @param direction USB communication direction the endpoint is capable of.
    92  * @param max_packet_size Maximu size of packets the endpoint accepts.
    93  * @param interval Preferred timeout between communication.
     88 * @param endpoint_desc Endpoint description.
    9489 * @return Error code.
    9590 */
    9691static int register_endpoint(
    97     ddf_fun_t *fun, usb_endpoint_t endpoint,
    98     usb_transfer_type_t transfer_type, usb_direction_t direction,
    99     size_t max_packet_size, unsigned packets, unsigned interval)
     92        ddf_fun_t *fun, usb_endpoint_desc_t *endpoint_desc)
    10093{
    10194        assert(fun);
     
    10598        assert(hcd->bus);
    10699        assert(dev);
    107         const size_t size = max_packet_size;
     100
     101        const size_t size = endpoint_desc->max_packet_size;
    108102
    109103        usb_log_debug("Register endpoint %d:%d %s-%s %zuB %ums.\n",
    110             dev->address, endpoint, usb_str_transfer_type(transfer_type),
    111             usb_str_direction(direction), max_packet_size, interval);
    112 
    113         return bus_add_ep(hcd->bus, dev, endpoint, direction, transfer_type,
    114             max_packet_size, packets, size);
    115 }
    116 
    117 /** Unregister endpoint interface function.
    118  * @param fun DDF function.
    119  * @param address USB address of the endpoint.
    120  * @param endpoint USB endpoint number.
    121  * @param direction Communication direction of the enpdoint to unregister.
    122  * @return Error code.
    123  */
     104                dev->address, endpoint_desc->endpoint_no,
     105                usb_str_transfer_type(endpoint_desc->transfer_type),
     106                usb_str_direction(endpoint_desc->direction),
     107                endpoint_desc->max_packet_size, endpoint_desc->usb2.polling_interval);
     108
     109        return bus_add_ep(hcd->bus, dev, endpoint_desc->endpoint_no,
     110                endpoint_desc->direction, endpoint_desc->transfer_type,
     111                endpoint_desc->max_packet_size, endpoint_desc->packets,
     112                size);
     113}
     114
     115 /** Unregister endpoint interface function.
     116  * @param fun DDF function.
     117  * @param endpoint_desc Endpoint description.
     118  * @return Error code.
     119  */
    124120static int unregister_endpoint(
    125     ddf_fun_t *fun, usb_endpoint_t endpoint, usb_direction_t direction)
     121        ddf_fun_t *fun, usb_endpoint_desc_t *endpoint_desc)
    126122{
    127123        assert(fun);
     
    131127        assert(hcd->bus);
    132128        assert(dev);
     129
    133130        const usb_target_t target = {{
    134131                .address = dev->address,
    135                 .endpoint = endpoint
     132                .endpoint = endpoint_desc->endpoint_no
    136133        }};
     134
    137135        usb_log_debug("Unregister endpoint %d:%d %s.\n",
    138             dev->address, endpoint, usb_str_direction(direction));
    139         return bus_remove_ep(hcd->bus, target, direction);
     136                dev->address, endpoint_desc->endpoint_no,
     137                usb_str_direction(endpoint_desc->direction));
     138        return bus_remove_ep(hcd->bus, target, endpoint_desc->direction);
    140139}
    141140
Note: See TracChangeset for help on using the changeset viewer.