Changes in uspace/lib/usb/src/ddfiface.c [79ae36dd:e882e3a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/ddfiface.c
r79ae36dd re882e3a 33 33 * Implementations of DDF interfaces functions (actual implementation). 34 34 */ 35 #include <ipc/devman.h>36 35 #include <devman.h> 37 36 #include <async.h> 37 #include <usb_iface.h> 38 38 #include <usb/ddfiface.h> 39 39 #include <usb/hc.h> 40 40 #include <usb/debug.h> 41 #include <usb/dev/hub.h> 41 42 #include <errno.h> 42 43 #include <assert.h> 43 44 45 #include <usb/dev.h> 46 44 47 /** DDF interface for USB device, implementation for typical hub. */ 45 usb_iface_t 46 .get_hc_handle = usb_iface_get_hc_handle_ hub_impl,47 .get_ address = usb_iface_get_address_hub_impl48 usb_iface_t usb_iface_hub_impl = { 49 .get_hc_handle = usb_iface_get_hc_handle_device_impl, 50 .get_my_address = usb_iface_get_my_address_forward_impl, 48 51 }; 49 52 50 53 /** DDF interface for USB device, implementation for child of a typical hub. */ 51 usb_iface_t 52 .get_hc_handle = usb_iface_get_hc_handle_ hub_child_impl,53 .get_ address = usb_iface_get_address_hub_child_impl54 usb_iface_t usb_iface_hub_child_impl = { 55 .get_hc_handle = usb_iface_get_hc_handle_device_impl, 56 .get_my_address = usb_iface_get_my_address_from_device_data, 54 57 }; 55 58 … … 61 64 * @return Error code. 62 65 */ 63 int usb_iface_get_hc_handle_ hub_impl(ddf_fun_t *fun, devman_handle_t *handle)66 int usb_iface_get_hc_handle_device_impl(ddf_fun_t *fun, devman_handle_t *handle) 64 67 { 65 68 assert(fun); 66 return usb_hc_find(fun->handle, handle); 67 } 68 69 /** Get host controller handle, interface implementation for child of 70 * a hub driver. 71 * 72 * @param[in] fun Device function the operation is running on. 73 * @param[out] handle Storage for the host controller handle. 74 * @return Error code. 75 */ 76 int usb_iface_get_hc_handle_hub_child_impl(ddf_fun_t *fun, 77 devman_handle_t *handle) 78 { 79 assert(fun != NULL); 80 81 async_sess_t *parent_sess = 82 devman_parent_device_connect(EXCHANGE_SERIALIZE, fun->handle, 83 IPC_FLAG_BLOCKING); 84 if (!parent_sess) 85 return ENOMEM; 86 87 async_exch_t *exch = async_exchange_begin(parent_sess); 88 89 sysarg_t hc_handle; 90 int rc = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), 91 IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &hc_handle); 92 93 async_exchange_end(exch); 94 async_hangup(parent_sess); 95 96 if (rc != EOK) 97 return rc; 98 99 *handle = hc_handle; 100 return EOK; 69 return usb_get_hc_by_handle(fun->handle, handle); 101 70 } 102 71 … … 125 94 * @return Error code. 126 95 */ 127 int usb_iface_get_ address_hub_impl(ddf_fun_t *fun, devman_handle_t handle,96 int usb_iface_get_my_address_forward_impl(ddf_fun_t *fun, 128 97 usb_address_t *address) 129 98 { 130 99 assert(fun); 131 132 async_sess_t *parent_sess = 133 devman_parent_device_connect(EXCHANGE_SERIALIZE, fun->handle, 134 IPC_FLAG_BLOCKING); 135 if (!parent_sess) 136 return ENOMEM; 137 138 async_exch_t *exch = async_exchange_begin(parent_sess); 139 140 sysarg_t addr; 141 int rc = async_req_2_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), 142 IPC_M_USB_GET_ADDRESS, handle, &addr); 143 144 async_exchange_end(exch); 145 async_hangup(parent_sess); 146 147 if (rc != EOK) 148 return rc; 149 150 if (address != NULL) 151 *address = (usb_address_t) addr; 152 153 return EOK; 100 return usb_get_address_by_handle(fun->handle, address); 154 101 } 155 102 156 103 /** Get USB device address, interface implementation for child of 157 104 * a hub driver. 105 * 106 * This implementation eccepts 0 as valid handle and replaces it with fun's 107 * handle. 158 108 * 159 109 * @param[in] fun Device function the operation is running on. … … 162 112 * @return Error code. 163 113 */ 164 int usb_iface_get_ address_hub_child_impl(ddf_fun_t *fun,165 devman_handle_t handle,usb_address_t *address)114 int usb_iface_get_my_address_from_device_data(ddf_fun_t *fun, 115 usb_address_t *address) 166 116 { 167 if (handle == 0) { 168 handle = fun->handle; 169 } 170 return usb_iface_get_address_hub_impl(fun, handle, address); 117 assert(fun); 118 assert(fun->driver_data); 119 const usb_hub_attached_device_t *device = fun->driver_data; 120 assert(device->fun == fun); 121 if (address) 122 *address = device->address; 123 return EOK; 171 124 } 172 125
Note:
See TracChangeset
for help on using the changeset viewer.