Changeset af6136d in mainline


Ignore:
Timestamp:
2011-05-28T14:54:20Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dd143621
Parents:
3fb5a3e
Message:

Guard hub ports with mutex

Location:
uspace/drv/usbhub
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/ports.c

    r3fb5a3e raf6136d  
    202202
    203203        //close address
    204         if(hub->ports[port].attached_device.address >= 0){
    205                 /*uncomment this code to use it when DDF allows device removal
    206                 opResult = usb_hc_unregister_device(
    207                         &hub->connection,
    208                         hub->attached_devs[port].address);
    209                 if(opResult != EOK) {
    210                         dprintf(USB_LOG_LEVEL_WARNING, "could not release "
    211                                 "address of "
    212                             "removed device: %d", opResult);
    213                 }
    214                 hub->attached_devs[port].address = 0;
    215                 hub->attached_devs[port].handle = 0;
    216                  */
     204
     205        usb_hub_port_t *the_port = hub->ports + port;
     206
     207        fibril_mutex_lock(&hub->port_mutex);
     208
     209        if (the_port->attached_device.address >= 0) {
     210                usb_log_warning("Device unplug on `%s' (port %zu): " \
     211                    "not implemented.\n", hub->usb_device->ddf_dev->name,
     212                    (size_t) port);
     213                the_port->attached_device.address = -1;
     214                the_port->attached_device.handle = 0;
    217215        } else {
    218216                usb_log_warning("Device removed before being registered.\n");
     
    223221                 * port reset callback from new device wrapper.
    224222                 */
    225                 usb_hub_port_t *the_port = hub->ports + port;
    226223                fibril_mutex_lock(&the_port->reset_mutex);
    227224                the_port->reset_completed = true;
     
    230227                fibril_mutex_unlock(&the_port->reset_mutex);
    231228        }
     229
     230        fibril_mutex_unlock(&hub->port_mutex);
    232231}
    233232
     
    396395        }
    397396
     397        fibril_mutex_lock(&data->hub->port_mutex);
    398398        data->hub->ports[data->port].attached_device.handle = child_handle;
    399399        data->hub->ports[data->port].attached_device.address = new_address;
     400        fibril_mutex_unlock(&data->hub->port_mutex);
    400401
    401402        usb_log_info("Detected new device on `%s' (port %zu), "
  • uspace/drv/usbhub/usbhub.c

    r3fb5a3e raf6136d  
    200200        result->control_pipe = &usb_dev->ctrl_pipe;
    201201        result->is_default_address_used = false;
     202
     203        result->ports = NULL;
     204        result->port_count = (size_t) -1;
     205        fibril_mutex_initialize(&result->port_mutex);
    202206
    203207        fibril_mutex_initialize(&result->pending_ops_mutex);
  • uspace/drv/usbhub/usbhub.h

    r3fb5a3e raf6136d  
    6161        usb_hub_port_t *ports;
    6262
     63        fibril_mutex_t port_mutex;
     64
    6365        /** connection to hcd */
    6466        usb_hc_connection_t connection;
Note: See TracChangeset for help on using the changeset viewer.