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