Changeset 327f147 in mainline for uspace/lib/usbhost/src/ddf_helpers.c


Ignore:
Timestamp:
2017-10-23T19:03:37Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b724494
Parents:
e160bfe8
Message:

usbhost: change parameters of methods

Pass (device_t, usb_target_t) to read and write, which finally allows to drop hash tables and access device right away. Then, all callbacks to complete transfer now uses usb_transfer_batch. This requires libdrv to include libusbhost, but it is not linked against it - it is there only to share definition of usb_transfer_batch_t.

File:
1 edited

Legend:

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

    re160bfe8 r327f147  
    135135                dev->address, endpoint_desc->endpoint_no,
    136136                usb_str_direction(endpoint_desc->direction));
    137         return bus_remove_ep(hcd->bus, target, endpoint_desc->direction);
     137        return bus_remove_ep(hcd->bus, dev, target, endpoint_desc->direction);
    138138}
    139139
     
    216216 * @return Error code.
    217217 */
    218 static int dev_read(ddf_fun_t *fun, usb_endpoint_t endpoint,
    219     uint64_t setup_data, uint8_t *data, size_t size,
    220     usbhc_iface_transfer_in_callback_t callback, void *arg)
     218static int dev_read(ddf_fun_t *fun, usb_target_t target,
     219    uint64_t setup_data, char *data, size_t size,
     220    usb_iface_transfer_callback_t callback, void *arg)
    221221{
    222222        assert(fun);
     223        hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
    223224        device_t *dev = ddf_fun_data_get(fun);
    224225        assert(dev);
    225         const usb_target_t target = {{
    226             .address  = dev->address,
    227             .endpoint = endpoint,
    228         }};
    229         return hcd_send_batch(dev_to_hcd(ddf_fun_get_dev(fun)), target,
    230             USB_DIRECTION_IN, data, size, setup_data, callback, NULL, arg,
    231             "READ");
     226
     227        target.address = dev->address;
     228
     229        return hcd_send_batch(hcd, dev, target, USB_DIRECTION_IN,
     230            data, size, setup_data,
     231            callback, arg, "READ");
    232232}
    233233
     
    242242 * @return Error code.
    243243 */
    244 static int dev_write(ddf_fun_t *fun, usb_endpoint_t endpoint,
    245     uint64_t setup_data, const uint8_t *data, size_t size,
    246     usbhc_iface_transfer_out_callback_t callback, void *arg)
     244static int dev_write(ddf_fun_t *fun, usb_target_t target,
     245    uint64_t setup_data, const char *data, size_t size,
     246    usb_iface_transfer_callback_t callback, void *arg)
    247247{
    248248        assert(fun);
     249        hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
    249250        device_t *dev = ddf_fun_data_get(fun);
    250251        assert(dev);
    251         const usb_target_t target = {{
    252             .address  = dev->address,
    253             .endpoint = endpoint,
    254         }};
    255         return hcd_send_batch(dev_to_hcd(ddf_fun_get_dev(fun)),
    256             target, USB_DIRECTION_OUT, (uint8_t*)data, size, setup_data, NULL,
     252
     253        target.address = dev->address;
     254
     255        return hcd_send_batch(hcd, dev, target, USB_DIRECTION_OUT,
     256            (char *) data, size, setup_data,
    257257            callback, arg, "WRITE");
    258258}
     
    411411        init_match_ids(&mids);
    412412
    413         usb_target_t control_ep = {{
     413        const usb_target_t control_ep = {{
    414414                .address = device->address,
    415                 .endpoint = 0
     415                .endpoint = 0,
    416416        }};
    417417
     
    422422        usb_log_debug("Device(%d): Requesting full device descriptor.",
    423423            device->address);
    424         ssize_t got = hcd_send_batch_sync(hcd, control_ep, USB_DIRECTION_IN,
    425             &desc, sizeof(desc), *(uint64_t *)&get_device_desc,
     424        ssize_t got = hcd_send_batch_sync(hcd, device, control_ep, USB_DIRECTION_IN,
     425            (char *) &desc, sizeof(desc), *(uint64_t *)&get_device_desc,
    426426            "read device descriptor");
    427427        if (got < 0) {
Note: See TracChangeset for help on using the changeset viewer.