Ignore:
Timestamp:
2011-12-23T18:13:33Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3819ce5, b39eb79, f0b74b2
Parents:
2f0dd2a (diff), 153cc76a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

USB branch changes.

+ USB device drivers use single async session to host controller, this session (represented by usb_hc_connection_t) is used for both HC requests and to back usb device connection.
+ Pipe locking was removed. Reference counting was moved to usb_hc_connection_t. Every read/write operation uses separate parallel exchange thus any contention is resolved on hc side.

  • async_sess_t setup using EXCHANGE_PARALLEL uses one extra phone (session phone, each exch creates its own), thus the number of phones used by usb dvice driver might increase. Possible solutions are: make read/write calls atomic (all other calls are atomic) and use EXCHANGE_ATOMIC, any other solution provided by changes to async_sess_t.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/usb_transfer_batch.c

    r2f0dd2a r7e1b130  
    3333 */
    3434#include <errno.h>
    35 #include <str_error.h>
     35#include <macros.h>
    3636
    3737#include <usb/usb.h>
     
    4848 * @param func_in callback on IN transfer completion.
    4949 * @param func_out callback on OUT transfer completion.
     50 * @param fun DDF function (passed to callback function).
    5051 * @param arg Argument to pass to the callback function.
    5152 * @param private_data driver specific per batch data.
     
    121122 * @param[in] data Data to copy to the output buffer.
    122123 * @param[in] size Size of @p data.
     124 * @param[in] error Error value to use.
    123125 */
    124 void usb_transfer_batch_finish(
    125     const usb_transfer_batch_t *instance, const void *data, size_t size)
     126void usb_transfer_batch_finish_error(const usb_transfer_batch_t *instance,
     127    const void *data, size_t size, int error)
    126128{
    127129        assert(instance);
     
    133135                /* Check for commands that reset toggle bit */
    134136                if (instance->ep->transfer_type == USB_TRANSFER_CONTROL
    135                     && instance->error == EOK) {
     137                    && error == EOK) {
    136138                        const usb_target_t target =
    137139                            {{ instance->ep->address, instance->ep->endpoint }};
     
    139141                            instance->setup_buffer);
    140142                }
    141                 instance->callback_out(instance->fun,
    142                     instance->error, instance->arg);
     143                instance->callback_out(instance->fun, error, instance->arg);
    143144        }
    144145
    145146        if (instance->callback_in) {
    146147                /* We care about the data and there are some to copy */
     148                const size_t safe_size = min(size, instance->buffer_size);
    147149                if (data) {
    148                         const size_t min_size = size < instance->buffer_size
    149                             ? size : instance->buffer_size;
    150                         memcpy(instance->buffer, data, min_size);
     150                        memcpy(instance->buffer, data, safe_size);
    151151                }
    152                 instance->callback_in(instance->fun, instance->error,
    153                     instance->transfered_size, instance->arg);
     152                instance->callback_in(instance->fun, error,
     153                    safe_size, instance->arg);
    154154        }
    155155}
Note: See TracChangeset for help on using the changeset viewer.