Changes in uspace/lib/usb/src/ddfiface.c [357a302:bc1c6fb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/ddfiface.c
r357a302 rbc1c6fb 34 34 */ 35 35 #include <ipc/devman.h> 36 #include <devman.h> 37 #include <async.h> 36 38 #include <usb/ddfiface.h> 39 #include <usb/debug.h> 37 40 #include <errno.h> 41 #include <assert.h> 38 42 39 43 /** DDF interface for USB device, implementation for typical hub. */ … … 52 56 /** Get host controller handle, interface implementation for hub driver. 53 57 * 54 * @param[in] device Devicethe operation is running on.58 * @param[in] fun Device function the operation is running on. 55 59 * @param[out] handle Storage for the host controller handle. 56 60 * @return Error code. 57 61 */ 58 int usb_iface_get_hc_handle_hub_impl(d evice_t *device, devman_handle_t *handle)62 int usb_iface_get_hc_handle_hub_impl(ddf_fun_t *fun, devman_handle_t *handle) 59 63 { 60 assert( device);61 return usb_hc_find( device->handle, handle);64 assert(fun); 65 return usb_hc_find(fun->handle, handle); 62 66 } 63 67 … … 65 69 * a hub driver. 66 70 * 67 * @param[in] device Devicethe operation is running on.71 * @param[in] fun Device function the operation is running on. 68 72 * @param[out] handle Storage for the host controller handle. 69 73 * @return Error code. 70 74 */ 71 int usb_iface_get_hc_handle_hub_child_impl(d evice_t *device,75 int usb_iface_get_hc_handle_hub_child_impl(ddf_fun_t *fun, 72 76 devman_handle_t *handle) 73 77 { 74 assert(device); 75 device_t *parent = device->parent; 78 assert(fun != NULL); 76 79 77 /* Default error, device does not support this operation. */ 78 int rc = ENOTSUP; 79 80 if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) { 81 usb_iface_t *usb_iface 82 = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE]; 83 assert(usb_iface != NULL); 84 85 if (usb_iface->get_hc_handle) { 86 rc = usb_iface->get_hc_handle(parent, handle); 87 } 80 int parent_phone = devman_parent_device_connect(fun->handle, 81 IPC_FLAG_BLOCKING); 82 if (parent_phone < 0) { 83 return parent_phone; 88 84 } 89 85 90 return rc; 86 sysarg_t hc_handle; 87 int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE), 88 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &hc_handle); 89 90 async_hangup(parent_phone); 91 92 if (rc != EOK) { 93 return rc; 94 } 95 96 *handle = hc_handle; 97 98 return EOK; 91 99 } 92 100 93 101 /** Get host controller handle, interface implementation for HC driver. 94 102 * 95 * @param[in] device Devicethe operation is running on.103 * @param[in] fun Device function the operation is running on. 96 104 * @param[out] handle Storage for the host controller handle. 97 105 * @return Always EOK. 98 106 */ 99 int usb_iface_get_hc_handle_hc_impl(d evice_t *device, devman_handle_t *handle)107 int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *fun, devman_handle_t *handle) 100 108 { 101 assert( device);109 assert(fun); 102 110 103 111 if (handle != NULL) { 104 *handle = device->handle;112 *handle = fun->handle; 105 113 } 106 114 … … 110 118 /** Get USB device address, interface implementation for hub driver. 111 119 * 112 * @param[in] device Devicethe operation is running on.120 * @param[in] fun Device function the operation is running on. 113 121 * @param[in] handle Devman handle of USB device we want address of. 114 122 * @param[out] address Storage for USB address of device with handle @p handle. 115 123 * @return Error code. 116 124 */ 117 int usb_iface_get_address_hub_impl(d evice_t *device, devman_handle_t handle,125 int usb_iface_get_address_hub_impl(ddf_fun_t *fun, devman_handle_t handle, 118 126 usb_address_t *address) 119 127 { 120 assert( device);121 int parent_phone = devman_parent_device_connect( device->handle,128 assert(fun); 129 int parent_phone = devman_parent_device_connect(fun->handle, 122 130 IPC_FLAG_BLOCKING); 123 131 if (parent_phone < 0) { … … 145 153 * a hub driver. 146 154 * 147 * @param[in] device Devicethe operation is running on.155 * @param[in] fun Device function the operation is running on. 148 156 * @param[in] handle Devman handle of USB device we want address of. 149 157 * @param[out] address Storage for USB address of device with handle @p handle. 150 158 * @return Error code. 151 159 */ 152 int usb_iface_get_address_hub_child_impl(d evice_t *device,160 int usb_iface_get_address_hub_child_impl(ddf_fun_t *fun, 153 161 devman_handle_t handle, usb_address_t *address) 154 162 { 155 assert(device); 156 device_t *parent = device->parent; 157 158 /* Default error, device does not support this operation. */ 159 int rc = ENOTSUP; 160 161 if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) { 162 usb_iface_t *usb_iface 163 = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE]; 164 assert(usb_iface != NULL); 165 166 if (usb_iface->get_address) { 167 rc = usb_iface->get_address(parent, handle, address); 168 } 163 if (handle == 0) { 164 handle = fun->handle; 169 165 } 170 171 return rc; 166 return usb_iface_get_address_hub_impl(fun, handle, address); 172 167 } 173 168
Note:
See TracChangeset
for help on using the changeset viewer.