Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/usbdrv.c

    r71ed4849 rfe4dd14  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     
    495495}
    496496
     497/** Issue whole control write transfer. */
     498int usb_drv_async_control_write(int phone, usb_target_t target,
     499    void *setup_packet, size_t setup_packet_size,
     500    void *buffer, size_t buffer_size,
     501    usb_handle_t *handle)
     502{
     503        // FIXME - check input parameters instead of asserting them
     504        assert(phone > 0);
     505        assert(setup_packet != NULL);
     506        assert(setup_packet_size > 0);
     507        assert(buffer != NULL);
     508        assert(buffer_size > 0);
     509        assert(handle != NULL);
     510
     511        transfer_info_t *transfer
     512            = (transfer_info_t *) malloc(sizeof(transfer_info_t));
     513        if (transfer == NULL) {
     514                return ENOMEM;
     515        }
     516
     517        transfer->size_transferred = NULL;
     518        transfer->buffer = NULL;
     519        transfer->size = 0;
     520        transfer->phone = phone;
     521
     522        int rc;
     523
     524        transfer->request = async_send_3(phone,
     525            DEV_IFACE_ID(USBHC_DEV_IFACE),
     526            IPC_M_USBHC_CONTROL_WRITE,
     527            target.address, target.endpoint,
     528            &transfer->reply);
     529
     530        rc = async_data_write_start(phone, setup_packet, setup_packet_size);
     531        if (rc != EOK) {
     532                async_wait_for(transfer->request, NULL);
     533                return rc;
     534        }
     535
     536        rc = async_data_write_start(phone, buffer, buffer_size);
     537        if (rc != EOK) {
     538                async_wait_for(transfer->request, NULL);
     539                return rc;
     540        }
     541
     542        *handle = (usb_handle_t) transfer;
     543
     544        return EOK;
     545}
     546
    497547/** Start control read transfer. */
    498548int usb_drv_async_control_read_setup(int phone, usb_target_t target,
     
    530580}
    531581
     582/** Issue whole control read transfer. */
     583int usb_drv_async_control_read(int phone, usb_target_t target,
     584    void *setup_packet, size_t setup_packet_size,
     585    void *buffer, size_t buffer_size, size_t *actual_size,
     586    usb_handle_t *handle)
     587{
     588        // FIXME - check input parameters instead of asserting them
     589        assert(phone > 0);
     590        assert(setup_packet != NULL);
     591        assert(setup_packet_size > 0);
     592        assert(buffer != NULL);
     593        assert(buffer_size > 0);
     594        assert(handle != NULL);
     595
     596        transfer_info_t *transfer
     597            = (transfer_info_t *) malloc(sizeof(transfer_info_t));
     598        if (transfer == NULL) {
     599                return ENOMEM;
     600        }
     601
     602        transfer->size_transferred = actual_size;
     603        transfer->buffer = buffer;
     604        transfer->size = buffer_size;
     605        transfer->phone = phone;
     606
     607        int rc;
     608
     609        transfer->request = async_send_4(phone,
     610            DEV_IFACE_ID(USBHC_DEV_IFACE),
     611            IPC_M_USBHC_CONTROL_READ,
     612            target.address, target.endpoint,
     613            buffer_size,
     614            &transfer->reply);
     615
     616        rc = async_data_write_start(phone, setup_packet, setup_packet_size);
     617        if (rc != EOK) {
     618                async_wait_for(transfer->request, NULL);
     619                return rc;
     620        }
     621
     622        *handle = (usb_handle_t) transfer;
     623
     624        return EOK;
     625}
     626
    532627/**
    533628 * @}
Note: See TracChangeset for help on using the changeset viewer.