Changeset 987dda8 in mainline


Ignore:
Timestamp:
2011-01-28T12:20:09Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
45c4f5a
Parents:
eb03e92
Message:

Added calback_get() and callback_dispose() convenience functions

Location:
uspace/drv/uhci
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci/callback.c

    reb03e92 r987dda8  
    33
    44#include "callback.h"
    5 
    6 
    75int callback_init(callback_t *instance, device_t *dev,
    86  void *buffer, size_t size, usbhc_iface_transfer_in_callback_t func_in,
  • uspace/drv/uhci/callback.h

    reb03e92 r987dda8  
    6464        callback_init(instance, dev, buffer, size, func, NULL, arg)
    6565
     66static inline callback_t *callback_get(device_t *dev,
     67  void *buffer, size_t size, usbhc_iface_transfer_in_callback_t func_in,
     68  usbhc_iface_transfer_out_callback_t func_out, void *arg)
     69{
     70        callback_t *instance = malloc(sizeof(callback_t));
     71        if (callback_init(instance, dev, buffer, size, func_in, func_out, arg)) {
     72                free(instance);
     73                instance = NULL;
     74        }
     75        return instance;
     76}
     77
    6678static inline void callback_fini(callback_t *instance)
    6779{
     
    6981        if (instance->new_buffer)
    7082                trans_free(instance->new_buffer);
     83}
     84
     85static inline void callback_dispose(callback_t *instance)
     86{
     87        callback_fini(instance);
     88        free(instance);
    7189}
    7290
Note: See TracChangeset for help on using the changeset viewer.