Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 96e2d01 in mainline


Ignore:
Timestamp:
2011-08-31T15:31:42Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
b991d37
Parents:
af2b806
Message:

libusbhost: make batch call interface public

add pointer checks

Location:
uspace/lib/usbhost
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/batch.h

    raf2b806 r96e2d01  
    9191);
    9292
    93 void usb_transfer_batch_call_in_and_dispose(usb_transfer_batch_t *instance);
    94 void usb_transfer_batch_call_out_and_dispose(usb_transfer_batch_t *instance);
    9593void usb_transfer_batch_finish(usb_transfer_batch_t *instance);
     94void usb_transfer_batch_call_in(usb_transfer_batch_t *instance);
     95void usb_transfer_batch_call_out(usb_transfer_batch_t *instance);
    9696void usb_transfer_batch_dispose(usb_transfer_batch_t *instance);
    9797
     98/** Helper function, calls callback and correctly destroys batch structure.
     99 *
     100 * @param[in] instance Batch structure to use.
     101 */
     102static inline void usb_transfer_batch_call_in_and_dispose(
     103    usb_transfer_batch_t *instance)
     104{
     105        assert(instance);
     106        usb_transfer_batch_call_in(instance);
     107        usb_transfer_batch_dispose(instance);
     108}
     109/*----------------------------------------------------------------------------*/
     110/** Helper function calls callback and correctly destroys batch structure.
     111 *
     112 * @param[in] instance Batch structure to use.
     113 */
     114static inline void usb_transfer_batch_call_out_and_dispose(
     115    usb_transfer_batch_t *instance)
     116{
     117        assert(instance);
     118        usb_transfer_batch_call_out(instance);
     119        usb_transfer_batch_dispose(instance);
     120}
     121/*----------------------------------------------------------------------------*/
    98122static inline void usb_transfer_batch_finish_error(
    99123    usb_transfer_batch_t *instance, int error)
     
    103127        usb_transfer_batch_finish(instance);
    104128}
    105 
     129/*----------------------------------------------------------------------------*/
    106130static inline usb_transfer_batch_t *usb_transfer_batch_from_link(link_t *l)
    107131{
  • uspace/lib/usbhost/src/batch.c

    raf2b806 r96e2d01  
    4040#include <usb/host/hcd.h>
    4141
    42 void usb_transfer_batch_call_in(usb_transfer_batch_t *instance);
    43 void usb_transfer_batch_call_out(usb_transfer_batch_t *instance);
    44 
    4542void usb_transfer_batch_init(
    4643    usb_transfer_batch_t *instance,
     
    7673        instance->next_step = NULL;
    7774        instance->error = EOK;
    78         endpoint_use(instance->ep);
    79 }
    80 /*----------------------------------------------------------------------------*/
    81 /** Helper function, calls callback and correctly destroys batch structure.
    82  *
    83  * @param[in] instance Batch structure to use.
    84  */
    85 void usb_transfer_batch_call_in_and_dispose(usb_transfer_batch_t *instance)
    86 {
    87         assert(instance);
    88         usb_transfer_batch_call_in(instance);
    89         usb_transfer_batch_dispose(instance);
    90 }
    91 /*----------------------------------------------------------------------------*/
    92 /** Helper function calls callback and correctly destroys batch structure.
    93  *
    94  * @param[in] instance Batch structure to use.
    95  */
    96 void usb_transfer_batch_call_out_and_dispose(usb_transfer_batch_t *instance)
    97 {
    98         assert(instance);
    99         usb_transfer_batch_call_out(instance);
    100         usb_transfer_batch_dispose(instance);
     75        if (instance->ep)
     76                endpoint_use(instance->ep);
    10177}
    10278/*----------------------------------------------------------------------------*/
     
    10985{
    11086        assert(instance);
    111         assert(instance->ep);
    112         assert(instance->next_step);
    113         endpoint_release(instance->ep);
    114         instance->next_step(instance);
     87        if (instance->ep)
     88                endpoint_release(instance->ep);
     89        if (instance->next_step)
     90                instance->next_step(instance);
    11591}
    11692/*----------------------------------------------------------------------------*/
     
    125101        assert(instance);
    126102        assert(instance->callback_in);
    127         assert(instance->ep);
    128103
    129104        /* We are data in, we need data */
     
    171146void usb_transfer_batch_dispose(usb_transfer_batch_t *instance)
    172147{
    173         assert(instance);
     148        if (!instance)
     149                return;
    174150        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " disposing.\n",
    175151            instance, USB_TRANSFER_BATCH_ARGS(*instance));
Note: See TracChangeset for help on using the changeset viewer.