Changeset c0587d90 in mainline for uspace/drv/bus/usb/usbhub/port.c


Ignore:
Timestamp:
2011-09-23T13:44:12Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
442fa6b
Parents:
a590a23
Message:

usbhub: Add pipe and port number to port structure.

Use these fields in feature set/clear.

File:
1 edited

Legend:

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

    ra590a23 rc0587d90  
    7373 * @return Operation result
    7474 */
    75 int usb_hub_clear_port_feature(usb_pipe_t *pipe,
    76     int port_index, usb_hub_class_feature_t feature)
    77 {
     75int usb_hub_clear_port_feature(
     76    usb_hub_port_t *port, usb_hub_class_feature_t feature)
     77{
     78        assert(port);
    7879        usb_device_request_setup_packet_t clear_request = {
    7980                .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
    8081                .request = USB_DEVREQ_CLEAR_FEATURE,
    8182                .value = feature,
    82                 .index = port_index,
     83                .index = port->port_number,
    8384                .length = 0,
    8485        };
    85         return usb_pipe_control_write(pipe, &clear_request,
     86        return usb_pipe_control_write(port->control_pipe, &clear_request,
    8687            sizeof(clear_request), NULL, 0);
    8788}
     
    9697 * @return Operation result
    9798 */
    98 int usb_hub_set_port_feature(usb_pipe_t *pipe,
    99     int port_index, usb_hub_class_feature_t feature)
    100 {
    101 
     99int usb_hub_set_port_feature(
     100    usb_hub_port_t *port, usb_hub_class_feature_t feature)
     101{
     102        assert(port);
    102103        usb_device_request_setup_packet_t clear_request = {
    103104                .request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE,
    104105                .request = USB_DEVREQ_SET_FEATURE,
    105                 .index = port_index,
     106                .index = port->port_number,
    106107                .value = feature,
    107108                .length = 0,
    108109        };
    109         return usb_pipe_control_write(pipe, &clear_request,
     110        return usb_pipe_control_write(port->control_pipe, &clear_request,
    110111            sizeof(clear_request), NULL, 0);
    111112}
     
    139140                /* ACK the change */
    140141                const int opResult =
    141                     usb_hub_clear_port_feature(hub->control_pipe,
    142                     port, USB_HUB_FEATURE_C_PORT_CONNECTION);
     142                    usb_hub_clear_port_feature(&hub->ports[port],
     143                        USB_HUB_FEATURE_C_PORT_CONNECTION);
    143144                if (opResult != EOK) {
    144145                        usb_log_warning("Failed to clear "
     
    266267
    267268        /* Clear the port reset change. */
    268         int rc = usb_hub_clear_port_feature(hub->control_pipe,
    269             port, USB_HUB_FEATURE_C_PORT_RESET);
     269        int rc = usb_hub_clear_port_feature(&hub->ports[port],
     270            USB_HUB_FEATURE_C_PORT_RESET);
    270271        if (rc != EOK) {
    271272                usb_log_error("Failed to clear port %d reset feature: %s.\n",
     
    326327static int enable_port_callback(int port_no, void *arg)
    327328{
    328         usb_hub_info_t *hub = arg;
    329         assert(hub);
    330         usb_hub_port_t *my_port = hub->ports + port_no;
    331         const int rc = usb_hub_set_port_feature(hub->control_pipe,
    332                 port_no, USB_HUB_FEATURE_PORT_RESET);
     329        usb_hub_port_t *port = arg;
     330        const int rc =
     331            usb_hub_set_port_feature(port, USB_HUB_FEATURE_PORT_RESET);
    333332        if (rc != EOK) {
    334333                usb_log_warning("Port reset failed: %s.\n", str_error(rc));
     
    339338         * Wait until reset completes.
    340339         */
    341         fibril_mutex_lock(&my_port->reset_mutex);
    342         while (!my_port->reset_completed) {
    343                 fibril_condvar_wait(&my_port->reset_cv, &my_port->reset_mutex);
    344         }
    345         fibril_mutex_unlock(&my_port->reset_mutex);
    346 
    347         if (my_port->reset_okay) {
     340        fibril_mutex_lock(&port->reset_mutex);
     341        while (!port->reset_completed) {
     342                fibril_condvar_wait(&port->reset_cv, &port->reset_mutex);
     343        }
     344        fibril_mutex_unlock(&port->reset_mutex);
     345
     346        if (port->reset_okay) {
    348347                return EOK;
    349348        } else {
     
    370369        const int rc = usb_hc_new_device_wrapper(data->hub->usb_device->ddf_dev,
    371370            &data->hub->connection, data->speed,
    372             enable_port_callback, (int) data->port, data->hub,
     371            enable_port_callback, (int) data->port,
     372            &data->hub->ports[data->port],
    373373            &new_address, &child_handle,
    374374            NULL, NULL, NULL);
Note: See TracChangeset for help on using the changeset viewer.