Changeset 327f147 in mainline for uspace/lib/drv/generic/remote_usb.c


Ignore:
Timestamp:
2017-10-23T19:03:37Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b724494
Parents:
e160bfe8
Message:

usbhost: change parameters of methods

Pass (device_t, usb_target_t) to read and write, which finally allows to drop hash tables and access device right away. Then, all callbacks to complete transfer now uses usb_transfer_batch. This requires libdrv to include libusbhost, but it is not linked against it - it is there only to share definition of usb_transfer_batch_t.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_usb.c

    re160bfe8 r327f147  
    3838#include <errno.h>
    3939#include <devman.h>
     40#include <usb/host/usb_transfer_batch.h>
    4041
    4142#include "usb_iface.h"
     
    539540}
    540541
    541 static void callback_out(int outcome, void *arg)
    542 {
    543         async_transaction_t *trans = arg;
    544 
    545         async_answer_0(trans->caller, outcome);
     542static int callback_out(usb_transfer_batch_t *batch)
     543{
     544        async_transaction_t *trans = batch->on_complete_data;
     545
     546        const int err = async_answer_0(trans->caller, batch->error);
    546547
    547548        async_transaction_destroy(trans);
    548 }
    549 
    550 static void callback_in(int outcome, size_t actual_size, void *arg)
    551 {
    552         async_transaction_t *trans = (async_transaction_t *)arg;
    553 
    554         if (outcome != EOK) {
    555                 async_answer_0(trans->caller, outcome);
    556                 if (trans->data_caller) {
     549
     550        return err;
     551}
     552
     553static int callback_in(usb_transfer_batch_t *batch)
     554{
     555        async_transaction_t *trans = batch->on_complete_data;
     556
     557        if (trans->data_caller) {
     558                if (batch->error == EOK) {
     559                        batch->error = async_data_read_finalize(trans->data_caller,
     560                            trans->buffer, batch->transfered_size);
     561                } else {
    557562                        async_answer_0(trans->data_caller, EINTR);
    558563                }
    559                 async_transaction_destroy(trans);
    560                 return;
    561         }
    562 
    563         if (trans->data_caller) {
    564                 async_data_read_finalize(trans->data_caller,
    565                     trans->buffer, actual_size);
    566         }
    567 
    568         async_answer_0(trans->caller, EOK);
    569 
     564        }
     565
     566        const int err = async_answer_0(trans->caller, batch->error);
    570567        async_transaction_destroy(trans);
     568        return err;
    571569}
    572570
     
    611609        }
    612610
     611        const usb_target_t target = {{
     612                /* .address is initialized by read itself */
     613                .endpoint = ep,
     614        }};
     615
    613616        const int rc = usb_iface->read(
    614             fun, ep, setup, trans->buffer, size, callback_in, trans);
     617            fun, target, setup, trans->buffer, size, callback_in, trans);
    615618
    616619        if (rc != EOK) {
     
    659662        }
    660663
     664        const usb_target_t target = {{
     665                /* .address is initialized by write itself */
     666                .endpoint = ep,
     667        }};
     668
    661669        const int rc = usb_iface->write(
    662             fun, ep, setup, trans->buffer, size, callback_out, trans);
     670            fun, target, setup, trans->buffer, size, callback_out, trans);
    663671
    664672        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.