Changeset 327f147 in mainline
- 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
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/bus.c
re160bfe8 r327f147 33 33 */ 34 34 35 #include <adt/hash_table.h>36 #include <adt/hash.h>37 35 #include <usb/host/utils/malloc32.h> 38 36 #include <usb/host/ddf_helpers.h> … … 50 48 #include "endpoint.h" 51 49 #include "transfers.h" 52 53 /** Element of the hash table. */54 typedef struct {55 ht_link_t link;56 57 /** Device */58 xhci_device_t *device;59 } hashed_device_t;60 61 static int hashed_device_insert(xhci_bus_t *bus, hashed_device_t **hashed_dev, xhci_device_t *dev);62 static int hashed_device_remove(xhci_bus_t *bus, hashed_device_t *hashed_dev);63 static int hashed_device_find_by_address(xhci_bus_t *bus, usb_address_t address, hashed_device_t **dev);64 50 65 51 /** TODO: Still some copy-pasta left... … … 94 80 bus->devices_by_slot[xhci_dev->slot_id] = xhci_dev; 95 81 96 hashed_device_t *hashed_dev = NULL;97 if ((err = hashed_device_insert(bus, &hashed_dev, xhci_dev)))98 goto err_address;99 100 82 /* Read the device descriptor, derive the match ids */ 101 83 if ((err = hcd_ddf_device_explore(hc->hcd, dev))) { 102 84 usb_log_error("Device(%d): Failed to explore device: %s", dev->address, str_error(err)); 103 goto err_hash; 104 } 105 106 return EOK; 107 108 err_hash: 109 bus->devices_by_slot[xhci_dev->slot_id] = NULL; 110 hashed_device_remove(bus, hashed_dev); 85 goto err_address; 86 } 87 88 return EOK; 89 111 90 err_address: 112 91 bus_release_address(&bus->base, dev->address); … … 127 106 } 128 107 129 hashed_device_t *hashed_dev;130 int res = hashed_device_find_by_address(bus, dev->address, &hashed_dev);131 if (res)132 return res;133 134 res = hashed_device_remove(bus, hashed_dev);135 if (res != EOK)136 return res;137 138 108 // XXX: Ugly here. Move to device_destroy at endpoint.c? 139 109 free32(xhci_dev->dev_ctx); … … 193 163 xhci_endpoint_fini(xhci_ep); 194 164 free(xhci_ep); 195 }196 197 static int hashed_device_find_by_address(xhci_bus_t *bus, usb_address_t address, hashed_device_t **dev)198 {199 ht_link_t *link = hash_table_find(&bus->devices, &address);200 if (link == NULL)201 return ENOENT;202 203 *dev = hash_table_get_inst(link, hashed_device_t, link);204 return EOK;205 }206 207 static int xhci_endpoint_find_by_target(xhci_bus_t *bus, usb_target_t target, xhci_endpoint_t **ep)208 {209 hashed_device_t *dev;210 int res = hashed_device_find_by_address(bus, target.address, &dev);211 if (res != EOK)212 return res;213 214 xhci_endpoint_t *ret_ep = xhci_device_get_endpoint(dev->device, target.endpoint);215 if (!ret_ep)216 return ENOENT;217 218 *ep = ret_ep;219 return EOK;220 }221 222 static int hashed_device_insert(xhci_bus_t *bus, hashed_device_t **hashed_dev, xhci_device_t *dev)223 {224 hashed_device_t *ret_dev = (hashed_device_t *) calloc(1, sizeof(hashed_device_t));225 if (!ret_dev)226 return ENOMEM;227 228 ret_dev->device = dev;229 230 usb_log_info("Device(%d) registered to XHCI bus.", dev->base.address);231 232 hash_table_insert(&bus->devices, &ret_dev->link);233 *hashed_dev = ret_dev;234 return EOK;235 }236 237 static int hashed_device_remove(xhci_bus_t *bus, hashed_device_t *hashed_dev)238 {239 usb_log_info("Device(%d) released from XHCI bus.", hashed_dev->device->base.address);240 241 hash_table_remove(&bus->devices, &hashed_dev->device->base.address);242 free(hashed_dev);243 244 return EOK;245 165 } 246 166 … … 273 193 } 274 194 275 static endpoint_t* find_endpoint(bus_t *bus_base, usb_target_t target, usb_direction_t direction) 276 { 277 xhci_bus_t *bus = bus_to_xhci_bus(bus_base); 278 assert(bus); 279 280 xhci_endpoint_t *ep; 281 int res = xhci_endpoint_find_by_target(bus, target, &ep); 282 if (res != EOK) 195 static endpoint_t* find_endpoint(bus_t *bus_base, device_t *dev_base, usb_target_t target, usb_direction_t direction) 196 { 197 xhci_device_t *dev = xhci_device_get(dev_base); 198 199 xhci_endpoint_t *ep = xhci_device_get_endpoint(dev, target.endpoint); 200 if (!ep) 283 201 return NULL; 284 202 … … 345 263 }; 346 264 347 static size_t device_ht_hash(const ht_link_t *item)348 {349 hashed_device_t *dev = hash_table_get_inst(item, hashed_device_t, link);350 return (size_t) hash_mix(dev->device->base.address);351 }352 353 static size_t device_ht_key_hash(void *key)354 {355 return (size_t) hash_mix(*(usb_address_t *)key);356 }357 358 static bool device_ht_key_equal(void *key, const ht_link_t *item)359 {360 hashed_device_t *dev = hash_table_get_inst(item, hashed_device_t, link);361 return dev->device->base.address == *(usb_address_t *) key;362 }363 364 /** Operations for the device hash table. */365 static hash_table_ops_t device_ht_ops = {366 .hash = device_ht_hash,367 .key_hash = device_ht_key_hash,368 .key_equal = device_ht_key_equal,369 .equal = NULL,370 .remove_callback = NULL371 };372 373 265 int xhci_bus_init(xhci_bus_t *bus, xhci_hc_t *hc) 374 266 { … … 381 273 return ENOMEM; 382 274 383 if (!hash_table_create(&bus->devices, 0, 0, &device_ht_ops)) {384 free(bus->devices_by_slot);385 return ENOMEM;386 }387 388 275 bus->base.ops = xhci_bus_ops; 389 276 return EOK; … … 392 279 void xhci_bus_fini(xhci_bus_t *bus) 393 280 { 394 // FIXME: Make sure no devices are in the hash table. 395 396 hash_table_destroy(&bus->devices); 281 397 282 } 398 283 -
uspace/drv/bus/usb/xhci/bus.h
re160bfe8 r327f147 38 38 #define XHCI_BUS_H 39 39 40 #include <adt/hash_table.h>41 40 #include <usb/usb.h> 42 41 #include <usb/host/bus.h> … … 50 49 51 50 xhci_device_t **devices_by_slot; /**< Devices by Slot ID */ 52 53 /** TODO: Do we really need this? */54 hash_table_t devices; /**< Devices by address */55 51 } xhci_bus_t; 56 52 -
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 -
uspace/lib/usbhost/include/usb/host/bus.h
re160bfe8 r327f147 85 85 int (*register_endpoint)(bus_t *, endpoint_t *); 86 86 int (*unregister_endpoint)(bus_t *, endpoint_t *); 87 endpoint_t *(*find_endpoint)(bus_t *, usb_target_t, usb_direction_t);87 endpoint_t *(*find_endpoint)(bus_t *, device_t*, usb_target_t, usb_direction_t); 88 88 void (*destroy_endpoint)(endpoint_t *); /**< Optional */ 89 89 bool (*endpoint_get_toggle)(endpoint_t *); /**< Optional */ … … 120 120 usb_direction_t dir, usb_transfer_type_t type, size_t max_packet_size, 121 121 unsigned packets, size_t size); 122 extern int bus_remove_ep(bus_t * bus, usb_target_t target, usb_direction_t dir);122 extern int bus_remove_ep(bus_t *, device_t *, usb_target_t, usb_direction_t); 123 123 124 124 int device_set_default_name(device_t *); … … 130 130 int bus_register_endpoint(bus_t *, endpoint_t *); 131 131 int bus_unregister_endpoint(bus_t *, endpoint_t *); 132 endpoint_t *bus_find_endpoint(bus_t *, usb_target_t, usb_direction_t);132 endpoint_t *bus_find_endpoint(bus_t *, device_t *, usb_target_t, usb_direction_t); 133 133 134 134 size_t bus_count_bw(endpoint_t *, size_t); -
uspace/lib/usbhost/include/usb/host/hcd.h
re160bfe8 r327f147 108 108 extern int hcd_remove_ep(hcd_t *, usb_target_t, usb_direction_t); 109 109 110 extern int hcd_send_batch(hcd_t *, usb_target_t, usb_direction_t, void *,111 size_t, uint64_t, usbhc_iface_transfer_in_callback_t,112 usb hc_iface_transfer_out_callback_t, void *, const char *);110 extern int hcd_send_batch(hcd_t *, device_t *, usb_target_t, 111 usb_direction_t direction, char *, size_t, uint64_t, 112 usb_transfer_batch_callback_t, void *, const char *); 113 113 114 extern ssize_t hcd_send_batch_sync(hcd_t *, usb_target_t, usb_direction_t, 115 void *, size_t, uint64_t, const char *); 114 extern ssize_t hcd_send_batch_sync(hcd_t *, device_t *, usb_target_t, 115 usb_direction_t direction, char *, size_t, uint64_t, 116 const char *); 116 117 117 118 #endif -
uspace/lib/usbhost/include/usb/host/usb2_bus.h
re160bfe8 r327f147 56 56 usb_speed_t speed; /**< Device speed */ 57 57 bool occupied; /**< The address is in use. */ 58 // TODO: This can be stored in usb2_bus-specific device_t 58 59 list_t endpoint_list; /**< Store endpoint_t instances */ 59 60 } devices[USB_ADDRESS_COUNT]; -
uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h
re160bfe8 r327f147 108 108 void usb_transfer_batch_destroy(usb_transfer_batch_t *); 109 109 110 /** Provided to ease the transition. Wraps old-style handlers into a new one.111 */112 extern void usb_transfer_batch_set_old_handlers(usb_transfer_batch_t *,113 usbhc_iface_transfer_in_callback_t,114 usbhc_iface_transfer_out_callback_t, void *);115 116 110 #endif 117 111 -
uspace/lib/usbhost/src/bus.c
re160bfe8 r327f147 99 99 } 100 100 101 int bus_remove_ep(bus_t *bus, usb_target_t target, usb_direction_t dir)102 { 103 assert(bus); 104 endpoint_t *ep = bus_find_endpoint(bus, target, dir);101 int bus_remove_ep(bus_t *bus, device_t *dev, usb_target_t target, usb_direction_t dir) 102 { 103 assert(bus); 104 endpoint_t *ep = bus_find_endpoint(bus, dev, target, dir); 105 105 if (!ep) 106 106 return ENOENT; … … 200 200 /** Searches for an endpoint. Returns a reference. 201 201 */ 202 endpoint_t *bus_find_endpoint(bus_t *bus, usb_target_t target, usb_direction_t dir)203 { 204 assert(bus); 205 206 fibril_mutex_lock(&bus->guard); 207 endpoint_t *ep = bus->ops.find_endpoint(bus, target, dir);202 endpoint_t *bus_find_endpoint(bus_t *bus, device_t *device, usb_target_t endpoint, usb_direction_t dir) 203 { 204 assert(bus); 205 206 fibril_mutex_lock(&bus->guard); 207 endpoint_t *ep = bus->ops.find_endpoint(bus, device, endpoint, dir); 208 208 if (ep) { 209 209 /* Exporting reference */ -
uspace/lib/usbhost/src/ddf_helpers.c
re160bfe8 r327f147 135 135 dev->address, endpoint_desc->endpoint_no, 136 136 usb_str_direction(endpoint_desc->direction)); 137 return bus_remove_ep(hcd->bus, target, endpoint_desc->direction);137 return bus_remove_ep(hcd->bus, dev, target, endpoint_desc->direction); 138 138 } 139 139 … … 216 216 * @return Error code. 217 217 */ 218 static int dev_read(ddf_fun_t *fun, usb_ endpoint_t endpoint,219 uint64_t setup_data, uint8_t*data, size_t size,220 usb hc_iface_transfer_in_callback_t callback, void *arg)218 static int dev_read(ddf_fun_t *fun, usb_target_t target, 219 uint64_t setup_data, char *data, size_t size, 220 usb_iface_transfer_callback_t callback, void *arg) 221 221 { 222 222 assert(fun); 223 hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun)); 223 224 device_t *dev = ddf_fun_data_get(fun); 224 225 assert(dev); 225 const usb_target_t target = {{ 226 .address = dev->address, 227 .endpoint = endpoint, 228 }}; 229 return hcd_send_batch(dev_to_hcd(ddf_fun_get_dev(fun)), target, 230 USB_DIRECTION_IN, data, size, setup_data, callback, NULL, arg, 231 "READ"); 226 227 target.address = dev->address; 228 229 return hcd_send_batch(hcd, dev, target, USB_DIRECTION_IN, 230 data, size, setup_data, 231 callback, arg, "READ"); 232 232 } 233 233 … … 242 242 * @return Error code. 243 243 */ 244 static int dev_write(ddf_fun_t *fun, usb_ endpoint_t endpoint,245 uint64_t setup_data, const uint8_t*data, size_t size,246 usb hc_iface_transfer_out_callback_t callback, void *arg)244 static int dev_write(ddf_fun_t *fun, usb_target_t target, 245 uint64_t setup_data, const char *data, size_t size, 246 usb_iface_transfer_callback_t callback, void *arg) 247 247 { 248 248 assert(fun); 249 hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun)); 249 250 device_t *dev = ddf_fun_data_get(fun); 250 251 assert(dev); 251 const usb_target_t target = {{ 252 .address = dev->address, 253 .endpoint = endpoint, 254 }}; 255 return hcd_send_batch(dev_to_hcd(ddf_fun_get_dev(fun)), 256 target, USB_DIRECTION_OUT, (uint8_t*)data, size, setup_data, NULL, 252 253 target.address = dev->address; 254 255 return hcd_send_batch(hcd, dev, target, USB_DIRECTION_OUT, 256 (char *) data, size, setup_data, 257 257 callback, arg, "WRITE"); 258 258 } … … 411 411 init_match_ids(&mids); 412 412 413 usb_target_t control_ep = {{413 const usb_target_t control_ep = {{ 414 414 .address = device->address, 415 .endpoint = 0 415 .endpoint = 0, 416 416 }}; 417 417 … … 422 422 usb_log_debug("Device(%d): Requesting full device descriptor.", 423 423 device->address); 424 ssize_t got = hcd_send_batch_sync(hcd, control_ep, USB_DIRECTION_IN,425 &desc, sizeof(desc), *(uint64_t *)&get_device_desc,424 ssize_t got = hcd_send_batch_sync(hcd, device, control_ep, USB_DIRECTION_IN, 425 (char *) &desc, sizeof(desc), *(uint64_t *)&get_device_desc, 426 426 "read device descriptor"); 427 427 if (got < 0) { -
uspace/lib/usbhost/src/hcd.c
re160bfe8 r327f147 80 80 * @return Error code. 81 81 */ 82 int hcd_send_batch(hcd_t *hcd, usb_target_t target, usb_direction_t direction, 83 void *data, size_t size, uint64_t setup_data, 84 usbhc_iface_transfer_in_callback_t in, usbhc_iface_transfer_out_callback_t out, 85 void *arg, const char *name) 82 int hcd_send_batch(hcd_t *hcd, device_t *device, usb_target_t target, 83 usb_direction_t direction, char *data, size_t size, uint64_t setup_data, 84 usb_transfer_batch_callback_t on_complete, void *arg, const char *name) 86 85 { 87 86 assert(hcd); 87 assert(device->address == target.address); 88 88 89 endpoint_t *ep = bus_find_endpoint(hcd->bus, target, direction);89 endpoint_t *ep = bus_find_endpoint(hcd->bus, device, target, direction); 90 90 if (ep == NULL) { 91 91 usb_log_error("Endpoint(%d:%d) not registered for %s.\n", 92 target.address, target.endpoint, name);92 device->address, target.endpoint, name); 93 93 return ENOENT; 94 94 } … … 120 120 batch->setup.packed = setup_data; 121 121 batch->dir = direction; 122 batch->on_complete = on_complete; 123 batch->on_complete_data = arg; 122 124 123 125 /* Check for commands that reset toggle bit */ … … 125 127 batch->toggle_reset_mode 126 128 = usb_request_get_toggle_reset_mode(&batch->setup.packet); 127 128 usb_transfer_batch_set_old_handlers(batch, in, out, arg);129 129 130 130 const int ret = hcd->ops.schedule(hcd, batch); … … 144 144 fibril_condvar_t done_cv; 145 145 unsigned done; 146 int ret; 147 size_t size; 146 147 size_t transfered_size; 148 int error; 148 149 } sync_data_t; 149 150 150 static void transfer_in_cb(int ret, size_t size, void* data)151 static int sync_transfer_complete(usb_transfer_batch_t *batch) 151 152 { 152 sync_data_t *d = data;153 sync_data_t *d = batch->on_complete_data; 153 154 assert(d); 154 d-> ret = ret;155 d-> size = size;155 d->transfered_size = batch->transfered_size; 156 d->error = batch->error; 156 157 fibril_mutex_lock(&d->done_mtx); 157 158 d->done = 1; 158 159 fibril_condvar_broadcast(&d->done_cv); 159 160 fibril_mutex_unlock(&d->done_mtx); 161 return EOK; 160 162 } 161 163 162 static void transfer_out_cb(int ret, void* data) 163 { 164 sync_data_t *d = data; 165 assert(data); 166 d->ret = ret; 167 fibril_mutex_lock(&d->done_mtx); 168 d->done = 1; 169 fibril_condvar_broadcast(&d->done_cv); 170 fibril_mutex_unlock(&d->done_mtx); 171 } 172 173 /** this is really ugly version of sync usb communication */ 174 ssize_t hcd_send_batch_sync( 175 hcd_t *hcd, usb_target_t target, usb_direction_t dir, 176 void *data, size_t size, uint64_t setup_data, const char* name) 164 ssize_t hcd_send_batch_sync(hcd_t *hcd, device_t *device, usb_target_t target, 165 usb_direction_t direction, char *data, size_t size, uint64_t setup_data, 166 const char *name) 177 167 { 178 168 assert(hcd); 179 sync_data_t sd = { .done = 0 , .ret = EBUSY, .size = size};169 sync_data_t sd = { .done = 0 }; 180 170 fibril_mutex_initialize(&sd.done_mtx); 181 171 fibril_condvar_initialize(&sd.done_cv); 182 172 183 const int ret = hcd_send_batch(hcd, target, dir, data, size, setup_data,184 d ir == USB_DIRECTION_IN ? transfer_in_cb : NULL,185 dir == USB_DIRECTION_OUT ? transfer_out_cb : NULL, &sd, name);173 const int ret = hcd_send_batch(hcd, device, target, direction, 174 data, size, setup_data, 175 sync_transfer_complete, &sd, name); 186 176 if (ret != EOK) 187 177 return ret; … … 192 182 fibril_mutex_unlock(&sd.done_mtx); 193 183 194 if (sd.ret== EOK)195 return sd.size;196 return sd.ret;184 return (sd.error == EOK) 185 ? (ssize_t) sd.transfered_size 186 : (ssize_t) sd.error; 197 187 } 198 188 -
uspace/lib/usbhost/src/usb2_bus.c
re160bfe8 r327f147 126 126 usb_log_debug("Device(%d): Requesting first 8B of device descriptor.", 127 127 address); 128 ssize_t got = hcd_send_batch_sync(hcd, de fault_target, USB_DIRECTION_IN,129 &desc, CTRL_PIPE_MIN_PACKET_SIZE, *(uint64_t *)&get_device_desc_8,128 ssize_t got = hcd_send_batch_sync(hcd, dev, default_target, USB_DIRECTION_IN, 129 (char *) &desc, CTRL_PIPE_MIN_PACKET_SIZE, *(uint64_t *)&get_device_desc_8, 130 130 "read first 8 bytes of dev descriptor"); 131 131 … … 141 141 142 142 usb_log_debug("Device(%d): Setting USB address.", address); 143 err = hcd_send_batch_sync(hcd, de fault_target, USB_DIRECTION_OUT,143 err = hcd_send_batch_sync(hcd, dev, default_target, USB_DIRECTION_OUT, 144 144 NULL, 0, *(uint64_t *)&set_address, "set address"); 145 145 if (err != 0) { … … 163 163 } 164 164 165 bus_remove_ep(bus, de fault_target, USB_DIRECTION_BOTH);165 bus_remove_ep(bus, dev, default_target, USB_DIRECTION_BOTH); 166 166 return EOK; 167 167 168 168 err_default_target: 169 bus_remove_ep(bus, de fault_target, USB_DIRECTION_BOTH);169 bus_remove_ep(bus, dev, default_target, USB_DIRECTION_BOTH); 170 170 err_address: 171 171 bus_release_address(bus, address); … … 247 247 * @note Assumes that the internal mutex is locked. 248 248 */ 249 static endpoint_t *usb2_bus_find_ep(bus_t *bus_base, usb_target_t target, usb_direction_t direction)249 static endpoint_t *usb2_bus_find_ep(bus_t *bus_base, device_t *device, usb_target_t target, usb_direction_t direction) 250 250 { 251 251 usb2_bus_t *bus = bus_to_usb2_bus(bus_base); … … 293 293 294 294 /* Check for existence */ 295 if (usb2_bus_find_ep(bus_base, ep-> target, ep->direction))295 if (usb2_bus_find_ep(bus_base, ep->device, ep->target, ep->direction)) 296 296 return EEXIST; 297 297 -
uspace/lib/usbhost/src/usb_transfer_batch.c
re160bfe8 r327f147 133 133 } 134 134 135 136 struct old_handler_wrapper_data {137 usbhc_iface_transfer_in_callback_t in_callback;138 usbhc_iface_transfer_out_callback_t out_callback;139 void *arg;140 };141 142 static int old_handler_wrapper(usb_transfer_batch_t *batch)143 {144 struct old_handler_wrapper_data *data = batch->on_complete_data;145 146 assert(data);147 148 if (data->out_callback)149 data->out_callback(batch->error, data->arg);150 151 if (data->in_callback)152 data->in_callback(batch->error, batch->transfered_size, data->arg);153 154 free(data);155 return EOK;156 }157 158 void usb_transfer_batch_set_old_handlers(usb_transfer_batch_t *batch,159 usbhc_iface_transfer_in_callback_t in_callback,160 usbhc_iface_transfer_out_callback_t out_callback,161 void *arg)162 {163 struct old_handler_wrapper_data *data = malloc(sizeof(*data));164 165 assert((!in_callback) != (!out_callback));166 167 data->in_callback = in_callback;168 data->out_callback = out_callback;169 data->arg = arg;170 171 batch->on_complete = old_handler_wrapper;172 batch->on_complete_data = data;173 }174 135 /** 175 136 * @}
Note:
See TracChangeset
for help on using the changeset viewer.