Changeset 56c6b88 in mainline


Ignore:
Timestamp:
2011-07-11T15:39:59Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c3bc8a8
Parents:
bb58dc0b
Message:

OHCI: Root hub: Fix and use TRANSFER_OK macro, more function removal.

File:
1 edited

Legend:

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

    rbb58dc0b r56c6b88  
    174174    rh_t *instance, uint16_t feature, uint16_t port);
    175175
    176 static int request_with_input(
    177     rh_t *instance, usb_transfer_batch_t *request);
    178 
    179176static int request_with_output(
    180177    rh_t *instance, usb_transfer_batch_t *request);
     
    195192        request->transfered_size = bytes; \
    196193        return EOK; \
    197 while (0);
     194} while (0)
    198195
    199196/** Root hub initialization
     
    391388        const uint32_t data = instance->registers->rh_port_status[port - 1];
    392389        memcpy(request->data_buffer, &data, 4);
    393         request->transfered_size = 4;
    394         return EOK;
     390        TRANSFER_OK(4);
    395391}
    396392/*----------------------------------------------------------------------------*/
     
    415411            (RHS_LPS_FLAG | RHS_LPSC_FLAG | RHS_OCI_FLAG | RHS_OCIC_FLAG);
    416412        memcpy(request->data_buffer, &data, 4);
    417         request->transfered_size = 4;
    418         return EOK;
     413        TRANSFER_OK(4);
    419414}
    420415/*----------------------------------------------------------------------------*/
     
    550545                size = request->buffer_size;
    551546        }
     547
    552548        memcpy(request->data_buffer, result_descriptor, size);
    553         request->transfered_size = size;
    554 
    555         return EOK;
     549        TRANSFER_OK(size);
    556550}
    557551/*----------------------------------------------------------------------------*/
     
    565559 * @return error code
    566560 */
    567 int port_feature_set_request(
    568     rh_t *instance, uint16_t feature, uint16_t port)
     561int port_feature_set_request(rh_t *instance, uint16_t feature, uint16_t port)
    569562{
    570563        assert(instance);
     
    610603            & (~port_clear_feature_valid_mask))
    611604            | (1 << feature);
    612 
    613605        return EOK;
    614606}
    615607/*----------------------------------------------------------------------------*/
    616608/**
    617  * process one of requests that requere output data
     609 * Process a request that requires output data.
    618610 *
    619611 * Request can be one of USB_DEVREQ_GET_STATUS, USB_DEVREQ_GET_DESCRIPTOR or
     
    643635                        return EINVAL;
    644636                request->data_buffer[0] = 1;
    645                 request->transfered_size = 1;
    646                 return EOK;
    647         }
    648         return ENOTSUP;
    649 }
    650 /*----------------------------------------------------------------------------*/
    651 /**
    652  * process one of requests that carry input data
    653  *
    654  * Request can be one of USB_DEVREQ_SET_DESCRIPTOR or
    655  * USB_DEVREQ_SET_CONFIGURATION.
    656  * @param instance root hub instance
    657  * @param request structure containing both request and response information
    658  * @return error code
    659  */
    660 int request_with_input(rh_t *instance, usb_transfer_batch_t *request)
    661 {
    662         assert(instance);
    663         assert(request);
    664 
    665         const usb_device_request_setup_packet_t *setup_request =
    666             (usb_device_request_setup_packet_t *) request->setup_buffer;
    667         request->transfered_size = 0;
    668         if (setup_request->request == USB_DEVREQ_SET_CONFIGURATION) {
    669                 //set and get configuration requests do not have any meaning,
    670                 //only dummy values are returned
    671                 return EOK;
    672         }
    673         /* USB_DEVREQ_SET_DESCRIPTOR is also not supported */
     637                TRANSFER_OK(1);
     638        }
    674639        return ENOTSUP;
    675640}
     
    703668                if (request_type == USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE) {
    704669                        usb_log_debug("USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE\n");
    705 /*
    706  * Chapter 11.16.2 specifies that only C_HUB_LOCAL_POWER and
    707  * C_HUB_OVER_CURRENT are supported. C_HUB_OVER_CURRENT is represented
    708  * by OHCI RHS_OCIC_FLAG. C_HUB_LOCAL_POWER is not supported
    709  * as root hubs do not support local power status feature. (OHCI pg. 127)
    710  */
     670        /*
     671        * Chapter 11.16.2 specifies that only C_HUB_LOCAL_POWER and
     672        * C_HUB_OVER_CURRENT are supported. C_HUB_OVER_CURRENT is represented
     673        * by OHCI RHS_OCIC_FLAG. C_HUB_LOCAL_POWER is not supported
     674         * as root hubs do not support local power status feature.
     675         * (OHCI pg. 127) */
    711676        if (setup_request->value == USB_HUB_FEATURE_C_HUB_OVER_CURRENT) {
    712677                instance->registers->rh_status = RHS_OCIC_FLAG;
     
    797762                    "additional data\n");
    798763                return request_without_data(instance, request);
    799         case USB_DEVREQ_SET_DESCRIPTOR:
    800764        case USB_DEVREQ_SET_CONFIGURATION:
    801765                usb_log_debug2("Processing request with input\n");
    802                 return request_with_input(instance, request);
     766                /* We don't need to do anything */
     767                TRANSFER_OK(0);
     768        case USB_DEVREQ_SET_DESCRIPTOR: /* Not supported by OHCI RH */
    803769        default:
    804770                usb_log_error("Received unsupported request: %d.\n",
Note: See TracChangeset for help on using the changeset viewer.