Changeset 2cc6e97 in mainline for uspace/lib/usb/src/host/batch.c


Ignore:
Timestamp:
2011-04-12T14:07:02Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3d932af6
Parents:
910ca3f
Message:

Move more functionality to libUSB usb_transfer_batch_t

UHCI uses one device accessible buffer for both structures and data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/host/batch.c

    r910ca3f r2cc6e97  
    3939#include <usb/host/batch.h>
    4040
     41void usb_transfer_batch_call_in(usb_transfer_batch_t *instance);
     42void usb_transfer_batch_call_out(usb_transfer_batch_t *instance);
     43
    4144void usb_transfer_batch_init(
    4245    usb_transfer_batch_t *instance,
    43                 endpoint_t *ep,
     46    endpoint_t *ep,
    4447    char *buffer,
    4548    char *data_buffer,
     
    5154    void *arg,
    5255    ddf_fun_t *fun,
    53     void *private_data
     56    void *private_data,
     57    void (*private_data_dtor)(void *p_data)
    5458    )
    5559{
     
    6771        instance->fun = fun;
    6872        instance->private_data = private_data;
     73        instance->private_data_dtor = private_data_dtor;
    6974        instance->transfered_size = 0;
    7075        instance->next_step = NULL;
    7176        instance->error = EOK;
    7277        endpoint_use(instance->ep);
     78}
     79/*----------------------------------------------------------------------------*/
     80/** Helper function, calls callback and correctly destroys batch structure.
     81 *
     82 * @param[in] instance Batch structure to use.
     83 */
     84void usb_transfer_batch_call_in_and_dispose(usb_transfer_batch_t *instance)
     85{
     86        assert(instance);
     87        usb_transfer_batch_call_in(instance);
     88        usb_transfer_batch_dispose(instance);
     89}
     90/*----------------------------------------------------------------------------*/
     91/** Helper function calls callback and correctly destroys batch structure.
     92 *
     93 * @param[in] instance Batch structure to use.
     94 */
     95void usb_transfer_batch_call_out_and_dispose(usb_transfer_batch_t *instance)
     96{
     97        assert(instance);
     98        usb_transfer_batch_call_out(instance);
     99        usb_transfer_batch_dispose(instance);
    73100}
    74101/*----------------------------------------------------------------------------*/
     
    129156            instance->error, instance->arg);
    130157}
     158/*----------------------------------------------------------------------------*/
     159/** Correctly dispose all used data structures.
     160 *
     161 * @param[in] instance Batch structure to use.
     162 */
     163void usb_transfer_batch_dispose(usb_transfer_batch_t *instance)
     164{
     165        assert(instance);
     166        usb_log_debug("Batch(%p) disposing.\n", instance);
     167        if (instance->private_data) {
     168                assert(instance->private_data_dtor);
     169                instance->private_data_dtor(instance->private_data);
     170        }
     171        free(instance);
     172}
    131173/**
    132174 * @}
Note: See TracChangeset for help on using the changeset viewer.