Changeset 4a7a8d4 in mainline for uspace/lib/usb/src/driver.c
- Timestamp:
- 2011-05-13T10:31:54Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- aca3489
- Parents:
- 05e21ffc (diff), c372e03 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/driver.c
r05e21ffc r4a7a8d4 1 1 /* 2 * Copyright (c) 201 0Vojtech Horky2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #include <stdio.h> 30 #include <stdlib.h> 31 #include <usb/addrkeep.h> 29 /** @addtogroup libusb 30 * @{ 31 */ 32 /** @file 33 * 34 */ 35 #include <devman.h> 36 #include <dev_iface.h> 37 #include <usb_iface.h> 38 #include <usb/driver.h> 32 39 #include <errno.h> 33 #include "../tester.h"34 35 #define MAX_ADDRESS 536 40 37 41 38 const char *test_usbaddrkeep(void) 42 /** Find host controller handle that is ancestor of given device. 43 * 44 * @param[in] device_handle Device devman handle. 45 * @param[out] hc_handle Where to store handle of host controller 46 * controlling device with @p device_handle handle. 47 * @return Error code. 48 */ 49 int usb_hc_find(devman_handle_t device_handle, devman_handle_t *hc_handle) 39 50 { 40 int rc; 41 usb_address_keeping_t addresses; 42 43 TPRINTF("Initializing addresses keeping structure...\n"); 44 usb_address_keeping_init(&addresses, MAX_ADDRESS); 45 46 TPRINTF("Requesting address...\n"); 47 usb_address_t addr = usb_address_keeping_request(&addresses); 48 TPRINTF("Address assigned: %d\n", (int) addr); 49 if (addr != 1) { 50 return "have not received expected address 1"; 51 int parent_phone = devman_parent_device_connect(device_handle, 52 IPC_FLAG_BLOCKING); 53 if (parent_phone < 0) { 54 return parent_phone; 51 55 } 52 56 53 TPRINTF("Releasing not assigned address...\n"); 54 rc = usb_address_keeping_release(&addresses, 2); 55 if (rc != ENOENT) { 56 return "have not received expected ENOENT"; 57 devman_handle_t h; 58 int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE), 59 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h); 60 61 async_hangup(parent_phone); 62 63 if (rc != EOK) { 64 return rc; 57 65 } 58 66 59 TPRINTF("Releasing acquired address...\n"); 60 rc = usb_address_keeping_release(&addresses, addr); 61 if (rc != EOK) { 62 return "have not received expected EOK"; 67 if (hc_handle != NULL) { 68 *hc_handle = h; 63 69 } 64 70 65 return NULL;71 return EOK; 66 72 } 73 74 /** 75 * @} 76 */
Note:
See TracChangeset
for help on using the changeset viewer.