Changeset 237df2f in mainline for uspace/lib/usbhost/src/hcd.c


Ignore:
Timestamp:
2013-01-04T16:49:53Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0e97b4b5
Parents:
daf199f
Message:

libusbhost: Add host side device initialization.

Add new roothub initialization functions (the old one is going away).
change usb device names created by host controller to be less awkward.

File:
1 edited

Legend:

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

    rdaf199f r237df2f  
    253253}
    254254
     255typedef struct {
     256        volatile unsigned done;
     257        int ret;       
     258        size_t size;
     259} sync_data_t;
     260
     261static void transfer_in_cb(int ret, size_t size, void* data)
     262{
     263        sync_data_t *d = data;
     264        assert(d);
     265        d->ret = ret;
     266        d->done = 1;
     267        d->size = size;
     268}
     269
     270static void transfer_out_cb(int ret, void* data)
     271{
     272        sync_data_t *d = data;
     273        assert(data);
     274        d->ret = ret;
     275        d->done = 1;
     276}
     277
     278/** this is really ugly version of sync usb communication */
     279ssize_t hcd_send_batch_sync(
     280    hcd_t *hcd, usb_target_t target, usb_direction_t dir,
     281    void *data, size_t size, uint64_t setup_data, const char* name)
     282{
     283        assert(hcd);
     284        sync_data_t sd = { .done = 0, .ret = EINPROGRESS, .size = size };
     285
     286        int ret = hcd_send_batch(hcd, target, dir, data, size, setup_data,
     287            dir == USB_DIRECTION_IN ? transfer_in_cb : NULL,
     288            dir == USB_DIRECTION_OUT ? transfer_out_cb : NULL, &sd, name);
     289        if (ret != EOK)
     290                return ret;
     291        do {
     292                async_usleep(1000);
     293        } while (!sd.done);
     294        if (sd.ret == EOK)
     295                return sd.size;
     296        return sd.ret;
     297}
     298
     299
    255300/**
    256301 * @}
Note: See TracChangeset for help on using the changeset viewer.