Changeset c24c157d in mainline
- Timestamp:
- 2011-12-12T11:59:35Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1a38701
- Parents:
- 899f1a9
- Location:
- uspace/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/dev.h
r899f1a9 rc24c157d 66 66 } 67 67 68 usb_address_t usb_get_address_by_handle(devman_handle_t); 68 int usb_get_info_by_handle(devman_handle_t, 69 devman_handle_t *, usb_address_t *, int *); 69 70 70 int usb_get_hc_by_handle(devman_handle_t, devman_handle_t *); 71 static inline int usb_get_hc_by_handle(devman_handle_t dev, devman_handle_t *hc) 72 { 73 return usb_get_info_by_handle(dev, hc, NULL, NULL); 74 } 75 76 static inline int usb_get_address_by_handle( 77 devman_handle_t dev, usb_address_t *address) 78 { 79 return usb_get_info_by_handle(dev, NULL, address, NULL); 80 } 81 82 static inline int usb_get_iface_by_handle(devman_handle_t dev, int *iface) 83 { 84 return usb_get_info_by_handle(dev, NULL, NULL, iface); 85 } 71 86 72 87 int usb_resolve_device_handle(const char *, devman_handle_t *, usb_address_t *, -
uspace/lib/usb/src/dev.c
r899f1a9 rc24c157d 31 31 #include <usb_iface.h> 32 32 33 /** Tell USB address assigned to device with given handle.33 /** Find host controller handle, address and iface number for the device. 34 34 * 35 * @param dev_handle Devman handle of the USB device in question. 36 * @return USB address or negative error code. 35 * @param[in] device_handle Device devman handle. 36 * @param[out] hc_handle Where to store handle of host controller 37 * controlling device with @p device_handle handle. 38 * @param[out] address Place to store the device's address 39 * @param[out] iface Place to stoer the assigned USB interface number. 40 * @return Error code. 37 41 */ 38 usb_address_t usb_get_address_by_handle(devman_handle_t dev_handle) 42 int usb_get_info_by_handle(devman_handle_t device_handle, 43 devman_handle_t *hc_handle, usb_address_t *address, int *iface) 39 44 { 40 45 async_sess_t *parent_sess = 41 devman_parent_device_connect(EXCHANGE_ATOMIC, dev _handle,42 IPC_FLAG_BLOCKING);46 devman_parent_device_connect(EXCHANGE_ATOMIC, device_handle, 47 IPC_FLAG_BLOCKING); 43 48 if (!parent_sess) 44 49 return ENOMEM; … … 49 54 return ENOMEM; 50 55 } 51 usb_address_t address; 52 const int ret = usb_get_my_address(exch, &address); 56 57 usb_address_t tmp_address; 58 devman_handle_t tmp_handle; 59 int tmp_iface; 60 61 if (address) { 62 const int ret = usb_get_my_address(exch, &tmp_address); 63 if (ret != EOK) { 64 async_exchange_end(exch); 65 async_hangup(parent_sess); 66 return ret; 67 } 68 } 69 70 if (hc_handle) { 71 const int ret = usb_get_hc_handle(exch, &tmp_handle); 72 if (ret != EOK) { 73 async_exchange_end(exch); 74 async_hangup(parent_sess); 75 return ret; 76 } 77 } 78 79 if (iface) { 80 const int ret = usb_get_my_interface(exch, &tmp_iface); 81 switch (ret) { 82 case ENOTSUP: 83 /* Implementing GET_MY_INTERFACE is voluntary. */ 84 tmp_iface = -1; 85 case EOK: 86 break; 87 default: 88 async_exchange_end(exch); 89 async_hangup(parent_sess); 90 return ret; 91 } 92 } 93 94 if (hc_handle) 95 *hc_handle = tmp_handle; 96 97 if (address) 98 *address = tmp_address; 99 100 if (iface) 101 *iface = tmp_iface; 53 102 54 103 async_exchange_end(exch); 55 104 async_hangup(parent_sess); 56 105 57 if (ret != EOK) 58 return ret; 59 60 return address; 61 } 62 /*----------------------------------------------------------------------------*/ 63 /** Find host controller handle for the device. 64 * 65 * @param[in] device_handle Device devman handle. 66 * @param[out] hc_handle Where to store handle of host controller 67 * controlling device with @p device_handle handle. 68 * @return Error code. 69 */ 70 int usb_get_hc_by_handle(devman_handle_t device_handle, 71 devman_handle_t *hc_handle) 72 { 73 async_sess_t *parent_sess = 74 devman_parent_device_connect(EXCHANGE_ATOMIC, device_handle, 75 IPC_FLAG_BLOCKING); 76 if (!parent_sess) 77 return ENOMEM; 78 79 async_exch_t *exch = async_exchange_begin(parent_sess); 80 if (!exch) { 81 async_hangup(parent_sess); 82 return ENOMEM; 83 } 84 const int ret = usb_get_hc_handle(exch, hc_handle); 85 86 async_exchange_end(exch); 87 async_hangup(parent_sess); 88 89 return ret; 106 return EOK; 90 107 } 91 108 /*----------------------------------------------------------------------------*/ -
uspace/lib/usb/src/resolve.c
r899f1a9 rc24c157d 193 193 /* Try to get its address. */ 194 194 if (!found_addr) { 195 dev_addr = usb_get_address_by_handle(tmp_handle);196 if ( dev_addr >= 0) {195 rc = usb_get_address_by_handle(tmp_handle, &dev_addr); 196 if (rc == 0) { 197 197 found_addr = true; 198 198 } -
uspace/lib/usbdev/src/devdrv.c
r899f1a9 rc24c157d 484 484 usb_dev->pipes = NULL; 485 485 486 /* Get assigned params */ 487 devman_handle_t hc_handle; 488 usb_address_t address; 489 490 int rc = usb_get_info_by_handle(ddf_dev->handle, 491 &hc_handle, &address, &usb_dev->interface_no); 492 if (rc != EOK) { 493 *errstr_ptr = "device parameters retrieval"; 494 return rc; 495 } 496 486 497 /* Initialize hc connection. */ 487 usb_hc_connection_initialize_from_device(&usb_dev->hc_conn, ddf_dev); 488 const usb_address_t address = 489 usb_get_address_by_handle(ddf_dev->handle); 498 usb_hc_connection_initialize(&usb_dev->hc_conn, hc_handle); 490 499 491 500 /* Initialize backing wire and control pipe. */ 492 intrc = usb_device_connection_initialize(501 rc = usb_device_connection_initialize( 493 502 &usb_dev->wire, &usb_dev->hc_conn, address); 494 503 if (rc != EOK) { … … 512 521 } 513 522 514 /* Get our interface. */515 usb_dev->interface_no = usb_device_get_assigned_interface(ddf_dev);516 523 /* Retrieve standard descriptors. */ 517 524 rc = usb_device_retrieve_descriptors(
Note:
See TracChangeset
for help on using the changeset viewer.