Changeset c0587d90 in mainline


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.

Location:
uspace/drv/bus/usb/usbhub
Files:
3 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);
  • uspace/drv/bus/usb/usbhub/port.h

    ra590a23 rc0587d90  
    4444/** Information about single port on a hub. */
    4545typedef struct {
     46        size_t port_number;
     47        usb_pipe_t *control_pipe;
    4648        /** Mutex needed by CV for checking port reset. */
    4749        fibril_mutex_t reset_mutex;
     
    6365 * @param port Port to be initialized.
    6466 */
    65 static inline void usb_hub_port_init(usb_hub_port_t *port)
     67static inline void usb_hub_port_init(usb_hub_port_t *port, size_t port_number,
     68    usb_pipe_t *control_pipe)
    6669{
    6770        assert(port);
    6871        port->attached_device.address = -1;
    6972        port->attached_device.handle = 0;
     73        port->port_number = port_number;
     74        port->control_pipe = control_pipe;
    7075        fibril_mutex_initialize(&port->reset_mutex);
    7176        fibril_condvar_initialize(&port->reset_cv);
     
    7479
    7580void usb_hub_process_port_interrupt(usb_hub_info_t *hub, size_t port);
    76 int usb_hub_clear_port_feature(usb_pipe_t *pipe,
    77     int port_index, usb_hub_class_feature_t feature);
    78 int usb_hub_set_port_feature(usb_pipe_t *pipe,
    79     int port_index, usb_hub_class_feature_t feature);
     81int usb_hub_clear_port_feature(
     82    usb_hub_port_t *port, usb_hub_class_feature_t feature);
     83int usb_hub_set_port_feature(
     84    usb_hub_port_t *port, usb_hub_class_feature_t feature);
    8085
    8186
  • uspace/drv/bus/usb/usbhub/usbhub.c

    ra590a23 rc0587d90  
    277277        size_t port;
    278278        for (port = 0; port < hub_info->port_count + 1; ++port) {
    279                 usb_hub_port_init(&hub_info->ports[port]);
     279                usb_hub_port_init(&hub_info->ports[port], port, control_pipe);
    280280        }
    281281
     
    290290                        usb_log_debug("Powering port %zu.\n", port);
    291291                        opResult = usb_hub_set_port_feature(
    292                             control_pipe, port, USB_HUB_FEATURE_PORT_POWER);
     292                            &hub_info->ports[port], USB_HUB_FEATURE_PORT_POWER);
    293293                        if (opResult != EOK) {
    294294                                usb_log_error("Cannot power on port %zu: %s.\n",
     
    361361    usb_hub_status_t status)
    362362{
    363         usb_pipe_t *control_pipe = &hub_info->usb_device->ctrl_pipe;
    364363        if (status & USB_HUB_STATUS_OVER_CURRENT) {
    365364                /* Over-current detected on one or all ports,
     
    369368                for (port = 1; port <= hub_info->port_count; ++port) {
    370369                        const int opResult = usb_hub_clear_port_feature(
    371                             control_pipe, port, USB_HUB_FEATURE_PORT_POWER);
     370                            &hub_info->ports[port], USB_HUB_FEATURE_PORT_POWER);
    372371                        if (opResult != EOK) {
    373372                                usb_log_warning(
     
    383382                for (port = 1; port <= hub_info->port_count; ++port) {
    384383                        const int opResult = usb_hub_set_port_feature(
    385                             control_pipe, port, USB_HUB_FEATURE_PORT_POWER);
     384                            &hub_info->ports[port], USB_HUB_FEATURE_PORT_POWER);
    386385                        if (opResult != EOK) {
    387386                                usb_log_warning(
Note: See TracChangeset for help on using the changeset viewer.