Changeset 7e1b130 in mainline for uspace/lib/usbdev/src/devpoll.c


Ignore:
Timestamp:
2011-12-23T18:13:33Z (12 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/usbdev/src/devpoll.c

    r2f0dd2a r7e1b130  
    4646/** Data needed for polling. */
    4747typedef struct {
     48        /** Parameters for automated polling. */
    4849        usb_device_auto_polling_t auto_polling;
    4950
     51        /** USB device to poll. */
    5052        usb_device_t *dev;
     53        /** Device pipe to use for polling. */
    5154        size_t pipe_index;
     55        /** Size of the recieved data. */
    5256        size_t request_size;
     57        /** Data buffer. */
    5358        uint8_t *buffer;
    54         void *custom_arg;
    5559} polling_data_t;
    5660
     
    119123                        ++failed_attempts;
    120124                        const bool cont = (params->on_error == NULL) ? true :
    121                             params->on_error(data->dev, rc, data->custom_arg);
     125                            params->on_error(data->dev, rc, params->arg);
    122126                        if (!cont) {
    123127                                failed_attempts = params->max_failures;
     
    129133                assert(params->on_data);
    130134                const bool carry_on = params->on_data(
    131                     data->dev, data->buffer, actual_size, data->custom_arg);
     135                    data->dev, data->buffer, actual_size, params->arg);
    132136
    133137                if (!carry_on) {
     
    149153
    150154        if (params->on_polling_end != NULL) {
    151                 params->on_polling_end(data->dev, failed, data->custom_arg);
     155                params->on_polling_end(data->dev, failed, params->arg);
    152156        }
    153157
     
    199203                .on_polling_end = terminated_callback,
    200204                .on_error = NULL,
     205                .arg = arg,
    201206        };
    202207
    203208        return usb_device_auto_polling(dev, pipe_index, &auto_polling,
    204            request_size, arg);
     209           request_size);
    205210}
    206211
     
    224229int usb_device_auto_polling(usb_device_t *dev, size_t pipe_index,
    225230    const usb_device_auto_polling_t *polling,
    226     size_t request_size, void *arg)
     231    size_t request_size)
    227232{
    228233        if ((dev == NULL) || (polling == NULL) || (polling->on_data == NULL)) {
     
    252257        polling_data->dev = dev;
    253258        polling_data->pipe_index = pipe_index;
    254         polling_data->custom_arg = arg;
    255259
    256260        /* Copy provided settings. */
Note: See TracChangeset for help on using the changeset viewer.