Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhub/port.c

    r344a0ac re882e3a  
    3535
    3636#include <bool.h>
    37 #include <devman.h>
    3837#include <errno.h>
    3938#include <str_error.h>
     
    288287        port->attached_device.fun = NULL;
    289288
    290         ret = usb_hc_connection_open(&hub->connection);
    291         if (ret == EOK) {
    292                 ret = usb_hc_unregister_device(&hub->connection,
    293                     port->attached_device.address);
    294                 if (ret != EOK) {
    295                         usb_log_warning("Failed to unregister address of the "
    296                             "removed device: %s.\n", str_error(ret));
    297                 }
    298                 ret = usb_hc_connection_close(&hub->connection);
    299                 if (ret != EOK) {
    300                         usb_log_warning("Failed to close hc connection %s.\n",
    301                             str_error(ret));
    302                 }
    303 
    304         } else {
    305                 usb_log_warning("Failed to open hc connection %s.\n",
    306                     str_error(ret));
     289        ret = usb_hub_unregister_device(&hub->usb_device->hc_conn,
     290            &port->attached_device);
     291        if (ret != EOK) {
     292                usb_log_warning("Failed to unregister address of the "
     293                    "removed device: %s.\n", str_error(ret));
    307294        }
    308295
     
    401388{
    402389        usb_hub_port_t *port = arg;
     390        assert(port);
    403391        const int rc =
    404392            usb_hub_port_set_feature(port, USB_HUB_FEATURE_PORT_RESET);
     
    437425
    438426        const int rc = usb_hc_new_device_wrapper(data->hub->usb_device->ddf_dev,
    439             &data->hub->connection, data->speed, enable_port_callback,
     427            &data->hub->usb_device->hc_conn, data->speed, enable_port_callback,
    440428            data->port, &new_address, NULL, NULL, &child_fun);
    441429
    442         if (rc != EOK) {
     430        if (rc == EOK) {
     431                fibril_mutex_lock(&data->port->mutex);
     432                data->port->attached_device.fun = child_fun;
     433                data->port->attached_device.address = new_address;
     434                fibril_mutex_unlock(&data->port->mutex);
     435
     436                usb_log_info("Detected new device on `%s' (port %zu), "
     437                    "address %d (handle %" PRIun ").\n",
     438                    data->hub->usb_device->ddf_dev->name,
     439                    data->port->port_number, new_address, child_fun->handle);
     440        } else {
    443441                usb_log_error("Failed registering device on port %zu: %s.\n",
    444442                    data->port->port_number, str_error(rc));
    445                 goto leave;
    446         }
    447 
    448         fibril_mutex_lock(&data->port->mutex);
    449         data->port->attached_device.fun = child_fun;
    450         data->port->attached_device.address = new_address;
    451         fibril_mutex_unlock(&data->port->mutex);
    452 
    453         usb_log_info("Detected new device on `%s' (port %zu), "
    454             "address %d (handle %" PRIun ").\n",
    455             data->hub->usb_device->ddf_dev->name, data->port->port_number,
    456             new_address, child_fun->handle);
    457 
    458 leave:
     443        }
     444
     445
    459446        fibril_mutex_lock(&data->hub->pending_ops_mutex);
    460447        assert(data->hub->pending_ops_count > 0);
Note: See TracChangeset for help on using the changeset viewer.