Changes in uspace/lib/usbhost/src/iface.c [549ff23:02fc5c4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/iface.c
r549ff23 r02fc5c4 89 89 } 90 90 /*----------------------------------------------------------------------------*/ 91 /** Request address interface function92 *93 * @param[in] fun DDF function that was called.94 * @param[in] speed Speed to associate with the new default address.95 * @param[out] address Place to write a new address.96 * @return Error code.97 */98 static int request_address(99 ddf_fun_t *fun, usb_speed_t speed, usb_address_t *address)100 {101 assert(fun);102 hcd_t *hcd = fun_to_hcd(fun);103 assert(hcd);104 assert(address);105 106 usb_log_debug("Address request speed: %s.\n", usb_str_speed(speed));107 *address =108 usb_device_manager_get_free_address(&hcd->dev_manager, speed);109 usb_log_debug("Address request with result: %d.\n", *address);110 if (*address <= 0)111 return *address;112 return EOK;113 }114 /*----------------------------------------------------------------------------*/115 /** Bind address interface function116 *117 * @param[in] fun DDF function that was called.118 * @param[in] address Address of the device119 * @param[in] handle Devman handle of the device driver.120 * @return Error code.121 */122 static int bind_address(123 ddf_fun_t *fun, usb_address_t address, devman_handle_t handle)124 {125 assert(fun);126 hcd_t *hcd = fun_to_hcd(fun);127 assert(hcd);128 129 usb_log_debug("Address bind %d-%" PRIun ".\n", address, handle);130 return usb_device_manager_bind(&hcd->dev_manager, address, handle);131 }132 /*----------------------------------------------------------------------------*/133 /** Find device handle by address interface function.134 *135 * @param[in] fun DDF function that was called.136 * @param[in] address Address in question.137 * @param[out] handle Where to store device handle if found.138 * @return Error code.139 */140 static int find_by_address(ddf_fun_t *fun, usb_address_t address,141 devman_handle_t *handle)142 {143 assert(fun);144 hcd_t *hcd = fun_to_hcd(fun);145 assert(hcd);146 return usb_device_manager_get_info_by_address(147 &hcd->dev_manager, address, handle, NULL);148 }149 /*----------------------------------------------------------------------------*/150 /** Release address interface function151 *152 * @param[in] fun DDF function that was called.153 * @param[in] address USB address to be released.154 * @return Error code.155 */156 static int release_address(ddf_fun_t *fun, usb_address_t address)157 {158 assert(fun);159 hcd_t *hcd = fun_to_hcd(fun);160 assert(hcd);161 usb_log_debug("Address release %d.\n", address);162 usb_device_manager_release(&hcd->dev_manager, address);163 return EOK;164 }165 /*----------------------------------------------------------------------------*/166 91 static int register_helper(endpoint_t *ep, void *arg) 167 92 { … … 183 108 } 184 109 /*----------------------------------------------------------------------------*/ 110 static void unregister_helper_warn(endpoint_t *ep, void *arg) 111 { 112 hcd_t *hcd = arg; 113 assert(ep); 114 assert(hcd); 115 usb_log_warning("Endpoint %d:%d %s was left behind, removing.\n", 116 ep->address, ep->endpoint, usb_str_direction(ep->direction)); 117 if (hcd->ep_remove_hook) 118 hcd->ep_remove_hook(hcd, ep); 119 } 120 /*----------------------------------------------------------------------------*/ 121 /** Request address interface function 122 * 123 * @param[in] fun DDF function that was called. 124 * @param[in] speed Speed to associate with the new default address. 125 * @param[out] address Place to write a new address. 126 * @return Error code. 127 */ 128 static int request_address( 129 ddf_fun_t *fun, usb_address_t *address, bool strict, usb_speed_t speed) 130 { 131 assert(fun); 132 hcd_t *hcd = fun_to_hcd(fun); 133 assert(hcd); 134 assert(address); 135 136 usb_log_debug("Address request: speed: %s, address: %d, strict: %s.\n", 137 usb_str_speed(speed), *address, strict ? "YES" : "NO"); 138 return usb_device_manager_request_address( 139 &hcd->dev_manager, address, strict, speed); 140 } 141 /*----------------------------------------------------------------------------*/ 142 /** Bind address interface function 143 * 144 * @param[in] fun DDF function that was called. 145 * @param[in] address Address of the device 146 * @param[in] handle Devman handle of the device driver. 147 * @return Error code. 148 */ 149 static int bind_address( 150 ddf_fun_t *fun, usb_address_t address, devman_handle_t handle) 151 { 152 assert(fun); 153 hcd_t *hcd = fun_to_hcd(fun); 154 assert(hcd); 155 156 usb_log_debug("Address bind %d-%" PRIun ".\n", address, handle); 157 return usb_device_manager_bind_address( 158 &hcd->dev_manager, address, handle); 159 } 160 /*----------------------------------------------------------------------------*/ 161 /** Find device handle by address interface function. 162 * 163 * @param[in] fun DDF function that was called. 164 * @param[in] address Address in question. 165 * @param[out] handle Where to store device handle if found. 166 * @return Error code. 167 */ 168 static int find_by_address(ddf_fun_t *fun, usb_address_t address, 169 devman_handle_t *handle) 170 { 171 assert(fun); 172 hcd_t *hcd = fun_to_hcd(fun); 173 assert(hcd); 174 return usb_device_manager_get_info_by_address( 175 &hcd->dev_manager, address, handle, NULL); 176 } 177 /*----------------------------------------------------------------------------*/ 178 /** Release address interface function 179 * 180 * @param[in] fun DDF function that was called. 181 * @param[in] address USB address to be released. 182 * @return Error code. 183 */ 184 static int release_address(ddf_fun_t *fun, usb_address_t address) 185 { 186 assert(fun); 187 hcd_t *hcd = fun_to_hcd(fun); 188 assert(hcd); 189 usb_log_debug("Address release %d.\n", address); 190 usb_device_manager_release_address(&hcd->dev_manager, address); 191 usb_endpoint_manager_remove_address(&hcd->ep_manager, address, 192 unregister_helper_warn, hcd); 193 return EOK; 194 } 195 /*----------------------------------------------------------------------------*/ 185 196 static int register_endpoint( 186 ddf_fun_t *fun, usb_address_t address, usb_speed_t ep_speed, 187 usb_endpoint_t endpoint, 197 ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint, 188 198 usb_transfer_type_t transfer_type, usb_direction_t direction, 189 199 size_t max_packet_size, unsigned int interval) … … 193 203 assert(hcd); 194 204 const size_t size = max_packet_size; 195 /* Default address is not bound or registered, 196 * thus it does not provide speed info. */ 197 usb_speed_t speed = ep_speed; 198 /* NOTE The function will return EINVAL and won't 199 * touch speed variable for default address */ 200 usb_device_manager_get_info_by_address( 205 usb_speed_t speed = USB_SPEED_MAX; 206 const int ret = usb_device_manager_get_info_by_address( 201 207 &hcd->dev_manager, address, NULL, &speed); 208 if (ret != EOK) { 209 return ret; 210 } 202 211 203 212 usb_log_debug("Register endpoint %d:%d %s-%s %s %zuB %ums.\n", … … 243 252 .request_address = request_address, 244 253 .bind_address = bind_address, 245 . find_by_address= find_by_address,254 .get_handle = find_by_address, 246 255 .release_address = release_address, 247 256
Note:
See TracChangeset
for help on using the changeset viewer.