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