Changeset 327f147 in mainline for uspace/lib/drv
- Timestamp:
- 2017-10-23T19:03:37Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b724494
- Parents:
- e160bfe8
- Location:
- uspace/lib/drv
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/Makefile
re160bfe8 r327f147 33 33 -Igeneric/private \ 34 34 -I$(LIBUSB_PREFIX)/include \ 35 -I$(LIBUSBHOST_PREFIX)/include \ 35 36 -I$(LIBPCM_PREFIX)/include 36 37 LIBRARY = libdrv -
uspace/lib/drv/generic/remote_usb.c
re160bfe8 r327f147 38 38 #include <errno.h> 39 39 #include <devman.h> 40 #include <usb/host/usb_transfer_batch.h> 40 41 41 42 #include "usb_iface.h" … … 539 540 } 540 541 541 static void callback_out(int outcome, void *arg)542 { 543 async_transaction_t *trans = arg;544 545 async_answer_0(trans->caller, outcome);542 static 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); 546 547 547 548 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 553 static 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 { 557 562 async_answer_0(trans->data_caller, EINTR); 558 563 } 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); 570 567 async_transaction_destroy(trans); 568 return err; 571 569 } 572 570 … … 611 609 } 612 610 611 const usb_target_t target = {{ 612 /* .address is initialized by read itself */ 613 .endpoint = ep, 614 }}; 615 613 616 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); 615 618 616 619 if (rc != EOK) { … … 659 662 } 660 663 664 const usb_target_t target = {{ 665 /* .address is initialized by write itself */ 666 .endpoint = ep, 667 }}; 668 661 669 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); 663 671 664 672 if (rc != EOK) { -
uspace/lib/drv/include/usb_iface.h
re160bfe8 r327f147 64 64 size_t); 65 65 66 /** Callback for outgoing transfer.*/67 typedef void (*usb_iface_transfer_out_callback_t)(int, void *);66 /** Defined in usb/host/usb_transfer_batch.h */ 67 typedef struct usb_transfer_batch usb_transfer_batch_t; 68 68 69 /** Callback for incoming transfer.*/70 typedef void (*usb_iface_transfer_in_callback_t)(int, size_t, void*);69 /** Callback for outgoing transfer - clone of usb_transfer_batch_callback_t */ 70 typedef int (*usb_iface_transfer_callback_t)(usb_transfer_batch_t *); 71 71 72 72 /** USB device communication interface. */ … … 84 84 int (*unregister_endpoint)(ddf_fun_t *, usb_endpoint_desc_t *); 85 85 86 int (*read)(ddf_fun_t *, usb_endpoint_t, uint64_t, uint8_t *, size_t, 87 usb_iface_transfer_in_callback_t, void *); 88 int (*write)(ddf_fun_t *, usb_endpoint_t, uint64_t, const uint8_t *, 89 size_t, usb_iface_transfer_out_callback_t, void *); 86 int (*read)(ddf_fun_t *, usb_target_t, 87 uint64_t, char *, size_t, 88 usb_iface_transfer_callback_t, void *); 89 int (*write)(ddf_fun_t *, usb_target_t, 90 uint64_t, const char *, size_t, 91 usb_iface_transfer_callback_t, void *); 90 92 } usb_iface_t; 91 93
Note:
See TracChangeset
for help on using the changeset viewer.