Changes in uspace/lib/usbdev/src/hub.c [79ae36dd:fb422312] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/hub.c
r79ae36dd rfb422312 37 37 #include <usb/dev/request.h> 38 38 #include <usb/dev/recognise.h> 39 #include <usb/debug.h> 39 40 #include <usbhc_iface.h> 40 41 #include <errno.h> … … 57 58 assert((conn)); \ 58 59 if (!usb_hc_connection_is_opened((conn))) { \ 59 return ENOENT; \ 60 usb_log_error("Connection not open.\n"); \ 61 return ENOTCONN; \ 60 62 } \ 61 63 } while (false) … … 95 97 */ 96 98 int usb_hc_register_device(usb_hc_connection_t * connection, 97 const usb_h c_attached_device_t *attached_device)99 const usb_hub_attached_device_t *attached_device) 98 100 { 99 101 CHECK_CONNECTION(connection); … … 105 107 int rc = async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 106 108 IPC_M_USBHC_BIND_ADDRESS, 107 attached_device->address, attached_device-> handle);109 attached_device->address, attached_device->fun->handle); 108 110 async_exchange_end(exch); 109 111 … … 155 157 * The @p enable_port function is expected to enable signaling on given 156 158 * port. 157 * The two arguments to it can have arbitrary meaning 158 * (the @p port_no is only a suggestion) 159 * and are not touched at all by this function 160 * (they are passed as is to the @p enable_port function). 159 * The argument can have arbitrary meaning and it is not touched at all 160 * by this function (it is passed as is to the @p enable_port function). 161 161 * 162 162 * If the @p enable_port fails (i.e. does not return EOK), the device … … 175 175 * @param[in] enable_port Function for enabling signaling through the port the 176 176 * device is attached to. 177 * @param[in] port_no Port number (passed through to @p enable_port).178 177 * @param[in] arg Any data argument to @p enable_port. 179 178 * @param[out] assigned_address USB address of the device. 180 * @param[out] assigned_handle Devman handle of the new device.181 179 * @param[in] dev_ops Child device ops. 182 180 * @param[in] new_dev_data Arbitrary pointer to be stored in the child … … 194 192 int usb_hc_new_device_wrapper(ddf_dev_t *parent, usb_hc_connection_t *connection, 195 193 usb_speed_t dev_speed, 196 int (*enable_port)(int port_no, void *arg), int port_no, void *arg, 197 usb_address_t *assigned_address, devman_handle_t *assigned_handle, 194 int (*enable_port)(void *arg), void *arg, usb_address_t *assigned_address, 198 195 ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun) 199 196 { … … 224 221 usb_address_t dev_addr = usb_hc_request_address(&hc_conn, dev_speed); 225 222 if (dev_addr < 0) { 226 usb_hc_connection_close(&hc_conn);227 return EADDRNOTAVAIL;223 rc = EADDRNOTAVAIL; 224 goto close_connection; 228 225 } 229 226 … … 279 276 * device address. 280 277 */ 281 rc = enable_port( port_no,arg);278 rc = enable_port(arg); 282 279 if (rc != EOK) { 283 280 goto leave_release_default_address; … … 320 317 */ 321 318 /* FIXME: create device_register that will get opened ctrl pipe. */ 322 d evman_handle_t child_handle;319 ddf_fun_t *child_fun; 323 320 rc = usb_device_register_child_in_devman(dev_addr, dev_conn.hc_handle, 324 parent, &child_handle, 325 dev_ops, new_dev_data, new_fun); 321 parent, dev_ops, new_dev_data, &child_fun); 326 322 if (rc != EOK) { 327 323 rc = ESTALL; … … 332 328 * And now inform the host controller about the handle. 333 329 */ 334 usb_h c_attached_device_t new_device = {330 usb_hub_attached_device_t new_device = { 335 331 .address = dev_addr, 336 . handle = child_handle332 .fun = child_fun, 337 333 }; 338 334 rc = usb_hc_register_device(&hc_conn, &new_device); … … 341 337 goto leave_release_free_address; 342 338 } 343 344 usb_hc_connection_close(&hc_conn); 339 345 340 346 341 /* … … 350 345 *assigned_address = dev_addr; 351 346 } 352 if (assigned_handle != NULL) { 353 *assigned_handle = child_handle; 354 } 355 356 return EOK; 357 358 347 if (new_fun != NULL) { 348 *new_fun = child_fun; 349 } 350 351 rc = EOK; 352 goto close_connection; 359 353 360 354 /* … … 368 362 usb_hc_unregister_device(&hc_conn, dev_addr); 369 363 370 usb_hc_connection_close(&hc_conn); 364 close_connection: 365 if (usb_hc_connection_close(&hc_conn) != EOK) 366 usb_log_warning("usb_hc_new_device_wrapper(): Failed to close " 367 "connection.\n"); 371 368 372 369 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.