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

Changeset 70fb822 in mainline


Ignore:
Timestamp:
2011-08-31T18:21:48Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
f18d82f0
Parents:
ff6dd73
Message:

libusbhost: change usb_transfer_batch_T handling to get/dispose pair

libusbhost: release endpoint on batch dispose, to be consistent with acquire on get (and avoid deadlock on error path)
uhci: usb_transfer_batch_finish is no longer necessary

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhci/uhci_batch.c

    rff6dd73 r70fb822  
    7676        if (uhci_batch->usb_batch->callback_in)
    7777                usb_transfer_batch_call_in(uhci_batch->usb_batch);
    78         usb_transfer_batch_finish(uhci_batch->usb_batch);
    7978        uhci_transfer_batch_dispose(uhci_batch);
    8079}
  • uspace/lib/usbhost/include/usb/host/batch.h

    rff6dd73 r70fb822  
    7575
    7676
    77 void usb_transfer_batch_init(
    78     usb_transfer_batch_t *instance,
     77usb_transfer_batch_t * usb_transfer_batch_get(
    7978    endpoint_t *ep,
    8079    char *buffer,
  • uspace/lib/usbhost/src/batch.c

    rff6dd73 r70fb822  
    4040#include <usb/host/hcd.h>
    4141
    42 void usb_transfer_batch_init(
    43     usb_transfer_batch_t *instance,
     42usb_transfer_batch_t * usb_transfer_batch_get(
    4443    endpoint_t *ep,
    4544    char *buffer,
     
    5352    ddf_fun_t *fun,
    5453    void *private_data,
    55     void (*private_data_dtor)(void *p_data)
     54    void (*private_data_dtor)(void *)
    5655    )
    5756{
    58         assert(instance);
    59         link_initialize(&instance->link);
    60         instance->ep = ep;
    61         instance->callback_in = func_in;
    62         instance->callback_out = func_out;
    63         instance->arg = arg;
    64         instance->buffer = buffer;
    65         instance->data_buffer = data_buffer;
    66         instance->buffer_size = buffer_size;
    67         instance->setup_buffer = setup_buffer;
    68         instance->setup_size = setup_size;
    69         instance->fun = fun;
    70         instance->private_data = private_data;
    71         instance->private_data_dtor = private_data_dtor;
    72         instance->transfered_size = 0;
    73         instance->next_step = NULL;
    74         instance->error = EOK;
    75         if (instance->ep)
    76                 endpoint_use(instance->ep);
     57        usb_transfer_batch_t *instance = malloc(sizeof(usb_transfer_batch_t));
     58        if (instance) {
     59                link_initialize(&instance->link);
     60                instance->ep = ep;
     61                instance->callback_in = func_in;
     62                instance->callback_out = func_out;
     63                instance->arg = arg;
     64                instance->buffer = buffer;
     65                instance->data_buffer = data_buffer;
     66                instance->buffer_size = buffer_size;
     67                instance->setup_buffer = setup_buffer;
     68                instance->setup_size = setup_size;
     69                instance->fun = fun;
     70                instance->private_data = private_data;
     71                instance->private_data_dtor = private_data_dtor;
     72                instance->transfered_size = 0;
     73                instance->next_step = NULL;
     74                instance->error = EOK;
     75                if (instance->ep)
     76                        endpoint_use(instance->ep);
     77        }
     78        return instance;
    7779}
    7880/*----------------------------------------------------------------------------*/
     
    8587{
    8688        assert(instance);
    87         if (instance->ep)
    88                 endpoint_release(instance->ep);
    8989        if (instance->next_step)
    9090                instance->next_step(instance);
     
    150150        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " disposing.\n",
    151151            instance, USB_TRANSFER_BATCH_ARGS(*instance));
     152        if (instance->ep) {
     153                endpoint_release(instance->ep);
     154        }
    152155        if (instance->private_data) {
    153156                assert(instance->private_data_dtor);
  • uspace/lib/usbhost/src/iface.c

    rff6dd73 r70fb822  
    7171                return ENOSPC;
    7272        }
    73         usb_transfer_batch_t *batch = malloc(sizeof(usb_transfer_batch_t));
     73        if (!hcd->schedule) {
     74                usb_log_error("HCD does not implement scheduler.\n");
     75                return ENOTSUP;
     76        }
     77
     78        /* No private data and no private data dtor */
     79        usb_transfer_batch_t *batch =
     80            usb_transfer_batch_get(ep, data, NULL, size, setup_data,
     81                setup_size, in, out, arg, fun, NULL, NULL);
    7482        if (!batch) {
    75                 ret = ENOMEM;
    76                 goto out;
    77 
    78         }
    79 
    80         /* No private data and no private data dtor, these will be set later */
    81         usb_transfer_batch_init(batch, ep, data, NULL, size, setup_data,
    82             setup_size, in, out, arg, fun, NULL, NULL);
    83 
    84         if (hcd->schedule) {
    85                 ret = hcd->schedule(hcd, batch);
    86         } else {
    87                 usb_log_error("HCD does not implement scheduler.\n");
    88                 ret = ENOTSUP;
    89         }
    90 out:
     83                return ENOMEM;
     84        }
     85
     86        ret = hcd->schedule(hcd, batch);
    9187        if (ret != EOK)
    9288                usb_transfer_batch_dispose(batch);
Note: See TracChangeset for help on using the changeset viewer.