Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset e65cd3c4 in mainline


Ignore:
Timestamp:
2011-12-06T15:15:26Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
9babc17
Parents:
2f80b86
Message:

ohci, root hub: Only check buffer size for hub specific GET_STATUS.

TODO Implement standard USB GET_STATUS requests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/root_hub.c

    r2f80b86 re65cd3c4  
    393393        assert(request);
    394394
    395         if (request->buffer_size < 4) {
    396                 usb_log_error("Buffer too small for get status request.\n");
    397                 TRANSFER_END(request, EOVERFLOW);
    398         }
    399395
    400396        const usb_device_request_setup_packet_t *request_packet =
    401397            (usb_device_request_setup_packet_t*)request->setup_buffer;
    402398
     399        switch (request_packet->request_type)
     400        {
     401        case USB_HUB_REQ_TYPE_GET_HUB_STATUS:
    403402        /* Hub status: just filter relevant info from rh_status reg */
    404         if (request_packet->request_type == USB_HUB_REQ_TYPE_GET_HUB_STATUS) {
    405                 const uint32_t data = instance->registers->rh_status &
    406                     (RHS_LPS_FLAG | RHS_LPSC_FLAG | RHS_OCI_FLAG | RHS_OCIC_FLAG);
    407                 TRANSFER_END_DATA(request, &data, sizeof(data));
    408         }
     403                if (request->buffer_size < 4) {
     404                        usb_log_error("Buffer(%zu) too small for hub get "
     405                            "status request.\n", request->buffer_size);
     406                        TRANSFER_END(request, EOVERFLOW);
     407                } else {
     408                        const uint32_t data = instance->registers->rh_status &
     409                            (RHS_LPS_FLAG | RHS_LPSC_FLAG
     410                                | RHS_OCI_FLAG | RHS_OCIC_FLAG);
     411                        TRANSFER_END_DATA(request, &data, sizeof(data));
     412                }
    409413
    410414        /* Copy appropriate rh_port_status register, OHCI designers were
    411415         * kind enough to make those bit values match USB specification */
    412         if (request_packet->request_type == USB_HUB_REQ_TYPE_GET_PORT_STATUS) {
    413                 const unsigned port = request_packet->index;
    414                 if (port < 1 || port > instance->port_count)
    415                         TRANSFER_END(request, EINVAL);
    416 
    417                 const uint32_t data =
    418                     instance->registers->rh_port_status[port - 1];
    419                 TRANSFER_END_DATA(request, &data, sizeof(data));
    420         }
    421 
    422         TRANSFER_END(request, ENOTSUP);
     416        case USB_HUB_REQ_TYPE_GET_PORT_STATUS:
     417                if (request->buffer_size < 4) {
     418                        usb_log_error("Buffer(%zu) too small for hub get "
     419                            "status request.\n", request->buffer_size);
     420                        TRANSFER_END(request, EOVERFLOW);
     421                } else {
     422                        const unsigned port = request_packet->index;
     423                        if (port < 1 || port > instance->port_count)
     424                                TRANSFER_END(request, EINVAL);
     425
     426                        const uint32_t data =
     427                            instance->registers->rh_port_status[port - 1];
     428                        TRANSFER_END_DATA(request, &data, sizeof(data));
     429                }
     430        default:
     431                usb_log_error("Unsupported GET_STATUS request.\n");
     432                TRANSFER_END(request, ENOTSUP);
     433        }
     434
    423435}
    424436/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.