Ignore:
File:
1 edited

Legend:

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

    rf527f58 rb7fd2a0  
    4949 * @return Error code.
    5050 */
    51 static int register_helper(endpoint_t *ep, void *arg)
     51static errno_t register_helper(endpoint_t *ep, void *arg)
    5252{
    5353        hcd_t *hcd = arg;
     
    102102}
    103103
    104 usb_address_t hcd_request_address(hcd_t *hcd, usb_speed_t speed)
    105 {
    106         assert(hcd);
    107         usb_address_t address = 0;
    108         const int ret = usb_bus_request_address(
    109             &hcd->bus, &address, false, speed);
    110         if (ret != EOK)
    111                 return ret;
    112         return address;
    113 }
    114 
    115 int hcd_release_address(hcd_t *hcd, usb_address_t address)
     104errno_t hcd_request_address(hcd_t *hcd, usb_speed_t speed, usb_address_t *address)
     105{
     106        assert(hcd);
     107        return usb_bus_request_address(&hcd->bus, address, false, speed);
     108}
     109
     110errno_t hcd_release_address(hcd_t *hcd, usb_address_t address)
    116111{
    117112        assert(hcd);
     
    120115}
    121116
    122 int hcd_reserve_default_address(hcd_t *hcd, usb_speed_t speed)
     117errno_t hcd_reserve_default_address(hcd_t *hcd, usb_speed_t speed)
    123118{
    124119        assert(hcd);
     
    127122}
    128123
    129 int hcd_add_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir,
     124errno_t hcd_add_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir,
    130125    usb_transfer_type_t type, size_t max_packet_size, unsigned packets,
    131126    size_t size, usb_address_t tt_address, unsigned tt_port)
     
    137132}
    138133
    139 int hcd_remove_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir)
     134errno_t hcd_remove_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir)
    140135{
    141136        assert(hcd);
     
    152147} toggle_t;
    153148
    154 static void toggle_reset_callback(int retval, void *arg)
     149static void toggle_reset_callback(errno_t retval, void *arg)
    155150{
    156151        assert(arg);
     
    177172 * @return Error code.
    178173 */
    179 int hcd_send_batch(
     174errno_t hcd_send_batch(
    180175    hcd_t *hcd, usb_target_t target, usb_direction_t direction,
    181176    void *data, size_t size, uint64_t setup_data,
     
    237232        }
    238233
    239         const int ret = hcd->ops.schedule(hcd, batch);
     234        const errno_t ret = hcd->ops.schedule(hcd, batch);
    240235        if (ret != EOK)
    241236                usb_transfer_batch_destroy(batch);
     
    249244typedef struct {
    250245        volatile unsigned done;
    251         int ret;
     246        errno_t ret;
    252247        size_t size;
    253248} sync_data_t;
    254249
    255 static void transfer_in_cb(int ret, size_t size, void* data)
     250static void transfer_in_cb(errno_t ret, size_t size, void* data)
    256251{
    257252        sync_data_t *d = data;
     
    262257}
    263258
    264 static void transfer_out_cb(int ret, void* data)
     259static void transfer_out_cb(errno_t ret, void* data)
    265260{
    266261        sync_data_t *d = data;
     
    271266
    272267/** this is really ugly version of sync usb communication */
    273 ssize_t hcd_send_batch_sync(
     268errno_t hcd_send_batch_sync(
    274269    hcd_t *hcd, usb_target_t target, usb_direction_t dir,
    275     void *data, size_t size, uint64_t setup_data, const char* name)
     270    void *data, size_t size, uint64_t setup_data, const char* name, size_t *out_size)
    276271{
    277272        assert(hcd);
    278273        sync_data_t sd = { .done = 0, .ret = EBUSY, .size = size };
    279274
    280         const int ret = hcd_send_batch(hcd, target, dir, data, size, setup_data,
     275        const errno_t ret = hcd_send_batch(hcd, target, dir, data, size, setup_data,
    281276            dir == USB_DIRECTION_IN ? transfer_in_cb : NULL,
    282277            dir == USB_DIRECTION_OUT ? transfer_out_cb : NULL, &sd, name);
     
    289284
    290285        if (sd.ret == EOK)
    291                 return sd.size;
     286                *out_size = sd.size;
    292287        return sd.ret;
    293288}
Note: See TracChangeset for help on using the changeset viewer.