Changeset aefa0d5 in mainline


Ignore:
Timestamp:
2011-09-23T19:16:31Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a61c683
Parents:
0212751
Message:

usbhub: Convert add device mechanism to use usb_hub_port_t instead of index.

File:
1 edited

Legend:

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

    r0212751 raefa0d5  
    5050struct add_device_phase1 {
    5151        usb_hub_info_t *hub;
    52         size_t port;
     52        usb_hub_port_t *port;
    5353        usb_speed_t speed;
    5454};
     
    6060static int enable_port_callback(int port_no, void *arg);
    6161static int add_device_phase1_worker_fibril(void *arg);
    62 static int create_add_device_fibril(usb_hub_info_t *hub, size_t port,
     62static int create_add_device_fibril(usb_hub_port_t *port, usb_hub_info_t *hub,
    6363    usb_speed_t speed);
    6464
     
    157157
    158158                if (connected) {
    159                         const int opResult = create_add_device_fibril(hub,
    160                             port->port_number, usb_port_speed(status));
     159                        const int opResult = create_add_device_fibril(port, hub,
     160                            usb_port_speed(status));
    161161                        if (opResult != EOK) {
    162162                                usb_log_error(
     
    398398        const int rc = usb_hc_new_device_wrapper(data->hub->usb_device->ddf_dev,
    399399            &data->hub->connection, data->speed,
    400             enable_port_callback, (int) data->port,
    401             &data->hub->ports[data->port],
    402             &new_address, &child_handle,
     400            enable_port_callback, (int) data->port->port_number,
     401            data->port, &new_address, &child_handle,
    403402            NULL, NULL, NULL);
    404403
    405404        if (rc != EOK) {
    406405                usb_log_error("Failed registering device on port %zu: %s.\n",
    407                     data->port, str_error(rc));
     406                    data->port->port_number, str_error(rc));
    408407                goto leave;
    409408        }
    410409
    411         fibril_mutex_lock(&data->hub->ports[data->port].mutex);
    412         data->hub->ports[data->port].attached_device.handle = child_handle;
    413         data->hub->ports[data->port].attached_device.address = new_address;
    414         fibril_mutex_unlock(&data->hub->ports[data->port].mutex);
     410        fibril_mutex_lock(&data->port->mutex);
     411        data->port->attached_device.handle = child_handle;
     412        data->port->attached_device.address = new_address;
     413        fibril_mutex_unlock(&data->port->mutex);
    415414
    416415        usb_log_info("Detected new device on `%s' (port %zu), "
    417416            "address %d (handle %" PRIun ").\n",
    418             data->hub->usb_device->ddf_dev->name, data->port,
     417            data->hub->usb_device->ddf_dev->name, data->port->port_number,
    419418            new_address, child_handle);
    420419
    421420leave:
    422         free(arg);
    423 
    424421        fibril_mutex_lock(&data->hub->pending_ops_mutex);
    425422        assert(data->hub->pending_ops_count > 0);
    426         data->hub->pending_ops_count--;
     423        --data->hub->pending_ops_count;
    427424        fibril_condvar_signal(&data->hub->pending_ops_cv);
    428425        fibril_mutex_unlock(&data->hub->pending_ops_mutex);
    429426
     427        free(arg);
    430428
    431429        return EOK;
     
    441439 * @return Error code.
    442440 */
    443 static int create_add_device_fibril(usb_hub_info_t *hub, size_t port,
     441static int create_add_device_fibril(usb_hub_port_t *port, usb_hub_info_t *hub,
    444442    usb_speed_t speed)
    445443{
     444        assert(hub);
     445        assert(port);
    446446        struct add_device_phase1 *data
    447447            = malloc(sizeof (struct add_device_phase1));
     
    453453        data->speed = speed;
    454454
    455         usb_hub_port_t *the_port = hub->ports + port;
    456 
    457         fibril_mutex_lock(&the_port->mutex);
    458         the_port->reset_completed = false;
    459         fibril_mutex_unlock(&the_port->mutex);
     455        fibril_mutex_lock(&port->mutex);
     456        port->reset_completed = false;
     457        fibril_mutex_unlock(&port->mutex);
    460458
    461459        fid_t fibril = fibril_create(add_device_phase1_worker_fibril, data);
     
    465463        }
    466464        fibril_mutex_lock(&hub->pending_ops_mutex);
    467         hub->pending_ops_count++;
     465        ++hub->pending_ops_count;
    468466        fibril_mutex_unlock(&hub->pending_ops_mutex);
    469467        fibril_add_ready(fibril);
Note: See TracChangeset for help on using the changeset viewer.