Ignore:
File:
1 edited

Legend:

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

    r361fcec r60b3bea  
    4545
    4646/**
    47  *      standart device descriptor for ohci root hub
     47 * standart device descriptor for ohci root hub
    4848 */
    4949static const usb_standard_device_descriptor_t ohci_rh_device_descriptor = {
     
    6969 */
    7070static const usb_standard_configuration_descriptor_t ohci_rh_conf_descriptor = {
    71         /// \TODO some values are default or guessed
    7271        .attributes = 1 << 7,
    7372        .configuration_number = 1,
     
    8786        .endpoint_count = 1,
    8887        .interface_class = USB_CLASS_HUB,
    89         /// \TODO is this correct?
    9088        .interface_number = 1,
    9189        .interface_protocol = 0,
     
    107105};
    108106
     107/**
     108 * bitmask of hub features that are valid to be cleared
     109 */
    109110static const uint32_t hub_clear_feature_valid_mask =
    110         (1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER) |
     111    (1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER) |
    111112(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
    112113
     114/**
     115 * bitmask of hub features that are cleared by writing 1 (and not 0)
     116 */
    113117static const uint32_t hub_clear_feature_by_writing_one_mask =
    114         1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER;
    115 
     118    1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER;
     119
     120/**
     121 * bitmask of hub features that are valid to be set
     122 */
    116123static const uint32_t hub_set_feature_valid_mask =
    117         (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) |
     124    (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) |
    118125(1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
    119126
    120 
     127/**
     128 * bitmask of hub features that are set by writing 1 and cleared by writing 0
     129 */
    121130static const uint32_t hub_set_feature_direct_mask =
    122         (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
    123 
     131    (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
     132
     133/**
     134 * bitmask of port features that are valid to be set
     135 */
    124136static const uint32_t port_set_feature_valid_mask =
    125         (1 << USB_HUB_FEATURE_PORT_ENABLE) |
     137    (1 << USB_HUB_FEATURE_PORT_ENABLE) |
    126138(1 << USB_HUB_FEATURE_PORT_SUSPEND) |
    127139(1 << USB_HUB_FEATURE_PORT_RESET) |
    128140(1 << USB_HUB_FEATURE_PORT_POWER);
    129141
     142/**
     143 * bitmask of port features that can be cleared
     144 */
    130145static const uint32_t port_clear_feature_valid_mask =
    131         (1 << USB_HUB_FEATURE_PORT_CONNECTION) |
     146    (1 << USB_HUB_FEATURE_PORT_CONNECTION) |
    132147(1 << USB_HUB_FEATURE_PORT_SUSPEND) |
    133148(1 << USB_HUB_FEATURE_PORT_OVER_CURRENT) |
     
    141156//USB_HUB_FEATURE_PORT_LOW_SPEED
    142157
     158/**
     159 * bitmask with port status changes
     160 */
    143161static const uint32_t port_status_change_mask =
    144 (1<< USB_HUB_FEATURE_C_PORT_CONNECTION) |
    145 (1<< USB_HUB_FEATURE_C_PORT_ENABLE) |
    146 (1<< USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
    147 (1<< USB_HUB_FEATURE_C_PORT_RESET) |
    148 (1<< USB_HUB_FEATURE_C_PORT_SUSPEND);
     162    (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |
     163(1 << USB_HUB_FEATURE_C_PORT_ENABLE) |
     164(1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
     165(1 << USB_HUB_FEATURE_C_PORT_RESET) |
     166(1 << USB_HUB_FEATURE_C_PORT_SUSPEND);
    149167
    150168
     
    154172
    155173static int process_get_port_status_request(rh_t *instance, uint16_t port,
    156         usb_transfer_batch_t * request);
     174    usb_transfer_batch_t * request);
    157175
    158176static int process_get_hub_status_request(rh_t *instance,
    159         usb_transfer_batch_t * request);
     177    usb_transfer_batch_t * request);
    160178
    161179static int process_get_status_request(rh_t *instance,
    162         usb_transfer_batch_t * request);
     180    usb_transfer_batch_t * request);
    163181
    164182static void create_interrupt_mask_in_instance(rh_t *instance);
    165183
    166184static int process_get_descriptor_request(rh_t *instance,
    167         usb_transfer_batch_t *request);
     185    usb_transfer_batch_t *request);
    168186
    169187static int process_get_configuration_request(rh_t *instance,
    170         usb_transfer_batch_t *request);
     188    usb_transfer_batch_t *request);
    171189
    172190static int process_hub_feature_set_request(rh_t *instance, uint16_t feature);
    173191
    174192static int process_hub_feature_clear_request(rh_t *instance,
    175         uint16_t feature);
     193    uint16_t feature);
    176194
    177195static int process_port_feature_set_request(rh_t *instance,
    178         uint16_t feature, uint16_t port);
     196    uint16_t feature, uint16_t port);
    179197
    180198static int process_port_feature_clear_request(rh_t *instance,
    181         uint16_t feature, uint16_t port);
     199    uint16_t feature, uint16_t port);
    182200
    183201static int process_address_set_request(rh_t *instance,
    184         uint16_t address);
     202    uint16_t address);
    185203
    186204static int process_request_with_output(rh_t *instance,
    187         usb_transfer_batch_t *request);
     205    usb_transfer_batch_t *request);
    188206
    189207static int process_request_with_input(rh_t *instance,
    190         usb_transfer_batch_t *request);
     208    usb_transfer_batch_t *request);
    191209
    192210static int process_request_without_data(rh_t *instance,
    193         usb_transfer_batch_t *request);
     211    usb_transfer_batch_t *request);
    194212
    195213static int process_ctrl_request(rh_t *instance, usb_transfer_batch_t *request);
     
    198216
    199217static bool is_zeros(void * buffer, size_t size);
    200 
    201 
    202218
    203219/** Root hub initialization
     
    210226            (instance->registers->rh_desc_a >> RHDA_NDS_SHIFT) & RHDA_NDS_MASK;
    211227        int opResult = rh_init_descriptors(instance);
    212         if(opResult != EOK){
     228        if (opResult != EOK) {
    213229                return opResult;
    214230        }
     
    216232        instance->registers->rh_desc_a |= RHDA_NPS_FLAG;
    217233        instance->unfinished_interrupt_transfer = NULL;
    218         instance->interrupt_mask_size = (instance->port_count + 8)/8;
     234        instance->interrupt_mask_size = (instance->port_count + 8) / 8;
    219235        instance->interrupt_buffer = malloc(instance->interrupt_mask_size);
    220         if(!instance->interrupt_buffer)
     236        if (!instance->interrupt_buffer)
    221237                return ENOMEM;
    222        
    223 
    224         usb_log_info("OHCI root hub with %d ports.\n", instance->port_count);
     238
     239        usb_log_info("OHCI root hub with %zu ports initialized.\n",
     240            instance->port_count);
     241
    225242        return EOK;
    226243}
     
    245262                usb_log_info("Root hub got INTERRUPT packet\n");
    246263                create_interrupt_mask_in_instance(instance);
    247                 if(is_zeros(instance->interrupt_buffer,
    248                     instance->interrupt_mask_size)){
     264                if (is_zeros(instance->interrupt_buffer,
     265                    instance->interrupt_mask_size)) {
    249266                        usb_log_debug("no changes..\n");
    250267                        instance->unfinished_interrupt_transfer = request;
    251268                        //will be finished later
    252                 }else{
     269                } else {
    253270                        usb_log_debug("processing changes..\n");
    254271                        process_interrupt_mask_in_instance(instance, request);
     
    256273                opResult = EOK;
    257274        } else {
     275
    258276                opResult = EINVAL;
    259277                usb_transfer_batch_finish_error(request, opResult);
     
    271289 */
    272290void rh_interrupt(rh_t *instance) {
    273         if(!instance->unfinished_interrupt_transfer){
     291        if (!instance->unfinished_interrupt_transfer) {
    274292                return;
    275293        }
     
    292310static int create_serialized_hub_descriptor(rh_t *instance) {
    293311        size_t size = 7 +
    294             ((instance->port_count +7 )/ 8) * 2;
    295         size_t var_size = (instance->port_count +7 )/ 8;
     312            ((instance->port_count + 7) / 8) * 2;
     313        size_t var_size = (instance->port_count + 7) / 8;
    296314        uint8_t * result = (uint8_t*) malloc(size);
    297         if(!result) return ENOMEM;
     315        if (!result) return ENOMEM;
    298316
    299317        bzero(result, size);
     
    305323        uint32_t hub_desc_reg = instance->registers->rh_desc_a;
    306324        result[3] =
    307                 ((hub_desc_reg >> 8) % 2) +
    308                 (((hub_desc_reg >> 9) % 2) << 1) +
    309                 (((hub_desc_reg >> 10) % 2) << 2) +
    310                 (((hub_desc_reg >> 11) % 2) << 3) +
    311                 (((hub_desc_reg >> 12) % 2) << 4);
     325            ((hub_desc_reg >> 8) % 2) +
     326            (((hub_desc_reg >> 9) % 2) << 1) +
     327            (((hub_desc_reg >> 10) % 2) << 2) +
     328            (((hub_desc_reg >> 11) % 2) << 3) +
     329            (((hub_desc_reg >> 12) % 2) << 4);
    312330        result[4] = 0;
    313331        result[5] = /*descriptor->pwr_on_2_good_time*/ 50;
    314332        result[6] = 50;
    315333
    316         int port;
     334        size_t port;
    317335        for (port = 1; port <= instance->port_count; ++port) {
    318336                uint8_t is_non_removable =
    319                         instance->registers->rh_desc_b >> port % 2;
     337                    instance->registers->rh_desc_b >> port % 2;
    320338                result[7 + port / 8] +=
    321                         is_non_removable << (port % 8);
     339                    is_non_removable << (port % 8);
    322340        }
    323341        size_t i;
     
    327345        instance->hub_descriptor = result;
    328346        instance->descriptor_size = size;
     347
    329348        return EOK;
    330349}
     
    340359static int rh_init_descriptors(rh_t *instance) {
    341360        memcpy(&instance->descriptors.device, &ohci_rh_device_descriptor,
    342                 sizeof (ohci_rh_device_descriptor)
    343                 );
     361            sizeof (ohci_rh_device_descriptor)
     362            );
    344363        usb_standard_configuration_descriptor_t descriptor;
    345364        memcpy(&descriptor, &ohci_rh_conf_descriptor,
    346                 sizeof (ohci_rh_conf_descriptor));
     365            sizeof (ohci_rh_conf_descriptor));
    347366
    348367        int opResult = create_serialized_hub_descriptor(instance);
    349         if(opResult != EOK){
     368        if (opResult != EOK) {
    350369                return opResult;
    351370        }
    352371        descriptor.total_length =
    353                 sizeof (usb_standard_configuration_descriptor_t) +
    354                 sizeof (usb_standard_endpoint_descriptor_t) +
    355                 sizeof (usb_standard_interface_descriptor_t) +
    356                 instance->descriptor_size;
     372            sizeof (usb_standard_configuration_descriptor_t) +
     373            sizeof (usb_standard_endpoint_descriptor_t) +
     374            sizeof (usb_standard_interface_descriptor_t) +
     375            instance->descriptor_size;
    357376
    358377        uint8_t * full_config_descriptor =
    359                 (uint8_t*) malloc(descriptor.total_length);
    360         if(!full_config_descriptor){
     378            (uint8_t*) malloc(descriptor.total_length);
     379        if (!full_config_descriptor) {
    361380                return ENOMEM;
    362381        }
    363382        memcpy(full_config_descriptor, &descriptor, sizeof (descriptor));
    364383        memcpy(full_config_descriptor + sizeof (descriptor),
    365                 &ohci_rh_iface_descriptor, sizeof (ohci_rh_iface_descriptor));
     384            &ohci_rh_iface_descriptor, sizeof (ohci_rh_iface_descriptor));
    366385        memcpy(full_config_descriptor + sizeof (descriptor) +
    367                 sizeof (ohci_rh_iface_descriptor),
    368                 &ohci_rh_ep_descriptor, sizeof (ohci_rh_ep_descriptor));
     386            sizeof (ohci_rh_iface_descriptor),
     387            &ohci_rh_ep_descriptor, sizeof (ohci_rh_ep_descriptor));
    369388        memcpy(full_config_descriptor + sizeof (descriptor) +
    370                 sizeof (ohci_rh_iface_descriptor) +
    371                 sizeof (ohci_rh_ep_descriptor),
    372                 instance->hub_descriptor, instance->descriptor_size);
    373        
     389            sizeof (ohci_rh_iface_descriptor) +
     390            sizeof (ohci_rh_ep_descriptor),
     391            instance->hub_descriptor, instance->descriptor_size);
     392
    374393        instance->descriptors.configuration = full_config_descriptor;
    375394        instance->descriptors.configuration_size = descriptor.total_length;
     395
    376396        return EOK;
    377397}
     
    389409 */
    390410static int process_get_port_status_request(rh_t *instance, uint16_t port,
    391         usb_transfer_batch_t * request) {
     411    usb_transfer_batch_t * request) {
    392412        if (port < 1 || port > instance->port_count)
    393413                return EINVAL;
     
    398418        int i;
    399419        for (i = 0; i < instance->port_count; ++i) {
     420
    400421                usb_log_debug("port status %d,x%x\n",
    401                         instance->registers->rh_port_status[i],
    402                         instance->registers->rh_port_status[i]);
     422                    instance->registers->rh_port_status[i],
     423                    instance->registers->rh_port_status[i]);
    403424        }
    404425#endif
     
    417438 */
    418439static int process_get_hub_status_request(rh_t *instance,
    419         usb_transfer_batch_t * request) {
     440    usb_transfer_batch_t * request) {
    420441        uint32_t * uint32_buffer = (uint32_t*) request->data_buffer;
    421442        request->transfered_size = 4;
     
    423444        uint32_t mask = 1 | (1 << 1) | (1 << 16) | (1 << 17);
    424445        uint32_buffer[0] = mask & instance->registers->rh_status;
     446
    425447        return EOK;
    426448}
     
    437459 */
    438460static int process_get_status_request(rh_t *instance,
    439         usb_transfer_batch_t * request) {
     461    usb_transfer_batch_t * request) {
    440462        size_t buffer_size = request->buffer_size;
    441463        usb_device_request_setup_packet_t * request_packet =
    442                 (usb_device_request_setup_packet_t*)
    443                 request->setup_buffer;
     464            (usb_device_request_setup_packet_t*)
     465            request->setup_buffer;
    444466
    445467        usb_hub_bm_request_type_t request_type = request_packet->request_type;
     
    453475        if (request_type == USB_HUB_REQ_TYPE_GET_PORT_STATUS)
    454476                return process_get_port_status_request(instance,
    455                 request_packet->index,
    456                 request);
     477            request_packet->index,
     478            request);
     479
    457480        return ENOTSUP;
    458481}
     
    472495        uint8_t * bitmap = (uint8_t*) (instance->interrupt_buffer);
    473496        uint32_t mask = (1 << (USB_HUB_FEATURE_C_HUB_LOCAL_POWER + 16))
    474                 | (1 << (USB_HUB_FEATURE_C_HUB_OVER_CURRENT + 16));
     497            | (1 << (USB_HUB_FEATURE_C_HUB_OVER_CURRENT + 16));
    475498        bzero(bitmap, instance->interrupt_mask_size);
    476499        if (instance->registers->rh_status & mask) {
    477500                bitmap[0] = 1;
    478501        }
    479         int port;
     502        size_t port;
    480503        mask = port_status_change_mask;
    481504        for (port = 1; port <= instance->port_count; ++port) {
    482505                if (mask & instance->registers->rh_port_status[port - 1]) {
     506
    483507                        bitmap[(port) / 8] += 1 << (port % 8);
    484508                }
     
    497521 */
    498522static int process_get_descriptor_request(rh_t *instance,
    499         usb_transfer_batch_t *request) {
     523    usb_transfer_batch_t *request) {
    500524        usb_device_request_setup_packet_t * setup_request =
    501                 (usb_device_request_setup_packet_t*) request->setup_buffer;
     525            (usb_device_request_setup_packet_t*) request->setup_buffer;
    502526        size_t size;
    503527        const void * result_descriptor = NULL;
     
    543567                {
    544568                        usb_log_debug("USB_DESCTYPE_EINVAL %d \n",
    545                                 setup_request->value);
     569                            setup_request->value);
    546570                        usb_log_debug("\ttype %d\n\trequest %d\n\tvalue "
    547                                 "%d\n\tindex %d\n\tlen %d\n ",
    548                                 setup_request->request_type,
    549                                 setup_request->request,
    550                                 setup_request_value,
    551                                 setup_request->index,
    552                                 setup_request->length
    553                                 );
     571                            "%d\n\tindex %d\n\tlen %d\n ",
     572                            setup_request->request_type,
     573                            setup_request->request,
     574                            setup_request_value,
     575                            setup_request->index,
     576                            setup_request->length
     577                            );
    554578                        return EINVAL;
    555579                }
     
    560584        request->transfered_size = size;
    561585        memcpy(request->data_buffer, result_descriptor, size);
     586
    562587        return EOK;
    563588}
     
    573598 */
    574599static int process_get_configuration_request(rh_t *instance,
    575         usb_transfer_batch_t *request) {
     600    usb_transfer_batch_t *request) {
    576601        //set and get configuration requests do not have any meaning, only dummy
    577602        //values are returned
     
    580605        request->data_buffer[0] = 1;
    581606        request->transfered_size = 1;
     607
    582608        return EOK;
    583609}
     
    592618 */
    593619static int process_hub_feature_set_request(rh_t *instance,
    594         uint16_t feature) {
     620    uint16_t feature) {
    595621        if (!((1 << feature) & hub_set_feature_valid_mask))
    596622                return EINVAL;
    597         if(feature == USB_HUB_FEATURE_C_HUB_LOCAL_POWER)
     623        if (feature == USB_HUB_FEATURE_C_HUB_LOCAL_POWER)
    598624                feature = USB_HUB_FEATURE_C_HUB_LOCAL_POWER << 16;
    599625        instance->registers->rh_status =
    600                 (instance->registers->rh_status | (1 << feature))
    601                 & (~hub_clear_feature_by_writing_one_mask);
     626            (instance->registers->rh_status | (1 << feature))
     627            & (~hub_clear_feature_by_writing_one_mask);
     628
    602629        return EOK;
    603630}
     
    612639 */
    613640static int process_hub_feature_clear_request(rh_t *instance,
    614         uint16_t feature) {
     641    uint16_t feature) {
    615642        if (!((1 << feature) & hub_clear_feature_valid_mask))
    616643                return EINVAL;
     
    618645        if ((1 << feature) & hub_set_feature_direct_mask) {
    619646                instance->registers->rh_status =
    620                         (instance->registers->rh_status & (~(1 << feature)))
    621                         & (~hub_clear_feature_by_writing_one_mask);
     647                    (instance->registers->rh_status & (~(1 << feature)))
     648                    & (~hub_clear_feature_by_writing_one_mask);
    622649        } else {//the feature is cleared by writing '1'
     650
    623651                instance->registers->rh_status =
    624                         (instance->registers->rh_status
    625                         & (~hub_clear_feature_by_writing_one_mask))
    626                         | (1 << feature);
     652                    (instance->registers->rh_status
     653                    & (~hub_clear_feature_by_writing_one_mask))
     654                    | (1 << feature);
    627655        }
    628656        return EOK;
     
    640668 */
    641669static int process_port_feature_set_request(rh_t *instance,
    642         uint16_t feature, uint16_t port) {
     670    uint16_t feature, uint16_t port) {
    643671        if (!((1 << feature) & port_set_feature_valid_mask))
    644672                return EINVAL;
     
    646674                return EINVAL;
    647675        instance->registers->rh_port_status[port - 1] =
    648                 (instance->registers->rh_port_status[port - 1] | (1 << feature))
    649                 & (~port_clear_feature_valid_mask);
     676            (instance->registers->rh_port_status[port - 1] | (1 << feature))
     677            & (~port_clear_feature_valid_mask);
    650678        /// \TODO any error?
     679
    651680        return EOK;
    652681}
     
    663692 */
    664693static int process_port_feature_clear_request(rh_t *instance,
    665         uint16_t feature, uint16_t port) {
     694    uint16_t feature, uint16_t port) {
    666695        if (!((1 << feature) & port_clear_feature_valid_mask))
    667696                return EINVAL;
     
    673702                feature = USB_HUB_FEATURE_PORT_OVER_CURRENT;
    674703        instance->registers->rh_port_status[port - 1] =
    675                 (instance->registers->rh_port_status[port - 1]
    676                 & (~port_clear_feature_valid_mask))
    677                 | (1 << feature);
     704            (instance->registers->rh_port_status[port - 1]
     705            & (~port_clear_feature_valid_mask))
     706            | (1 << feature);
    678707        /// \TODO any error?
     708
    679709        return EOK;
    680710}
     
    689719 */
    690720static int process_address_set_request(rh_t *instance,
    691         uint16_t address) {
     721    uint16_t address) {
    692722        instance->address = address;
     723
    693724        return EOK;
    694725}
     
    705736 */
    706737static int process_request_with_output(rh_t *instance,
    707         usb_transfer_batch_t *request) {
     738    usb_transfer_batch_t *request) {
    708739        usb_device_request_setup_packet_t * setup_request =
    709                 (usb_device_request_setup_packet_t*) request->setup_buffer;
     740            (usb_device_request_setup_packet_t*) request->setup_buffer;
    710741        if (setup_request->request == USB_DEVREQ_GET_STATUS) {
    711742                usb_log_debug("USB_DEVREQ_GET_STATUS\n");
     
    718749        if (setup_request->request == USB_DEVREQ_GET_CONFIGURATION) {
    719750                usb_log_debug("USB_DEVREQ_GET_CONFIGURATION\n");
     751
    720752                return process_get_configuration_request(instance, request);
    721753        }
     
    734766 */
    735767static int process_request_with_input(rh_t *instance,
    736         usb_transfer_batch_t *request) {
     768    usb_transfer_batch_t *request) {
    737769        usb_device_request_setup_packet_t * setup_request =
    738                 (usb_device_request_setup_packet_t*) request->setup_buffer;
     770            (usb_device_request_setup_packet_t*) request->setup_buffer;
    739771        request->transfered_size = 0;
    740772        if (setup_request->request == USB_DEVREQ_SET_DESCRIPTOR) {
     
    744776                //set and get configuration requests do not have any meaning,
    745777                //only dummy values are returned
     778
    746779                return EOK;
    747780        }
     
    760793 */
    761794static int process_request_without_data(rh_t *instance,
    762         usb_transfer_batch_t *request) {
     795    usb_transfer_batch_t *request) {
    763796        usb_device_request_setup_packet_t * setup_request =
    764                 (usb_device_request_setup_packet_t*) request->setup_buffer;
     797            (usb_device_request_setup_packet_t*) request->setup_buffer;
    765798        request->transfered_size = 0;
    766799        if (setup_request->request == USB_DEVREQ_CLEAR_FEATURE) {
     
    768801                        usb_log_debug("USB_HUB_REQ_TYPE_SET_HUB_FEATURE\n");
    769802                        return process_hub_feature_clear_request(instance,
    770                                 setup_request->value);
     803                            setup_request->value);
    771804                }
    772805                if (setup_request->request_type == USB_HUB_REQ_TYPE_SET_PORT_FEATURE) {
    773806                        usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
    774807                        return process_port_feature_clear_request(instance,
    775                                 setup_request->value,
    776                                 setup_request->index);
     808                            setup_request->value,
     809                            setup_request->index);
    777810                }
    778811                usb_log_debug("USB_HUB_REQ_TYPE_INVALID %d\n",
    779                         setup_request->request_type);
     812                    setup_request->request_type);
    780813                return EINVAL;
    781814        }
     
    784817                        usb_log_debug("USB_HUB_REQ_TYPE_SET_HUB_FEATURE\n");
    785818                        return process_hub_feature_set_request(instance,
    786                                 setup_request->value);
     819                            setup_request->value);
    787820                }
    788821                if (setup_request->request_type == USB_HUB_REQ_TYPE_SET_PORT_FEATURE) {
    789822                        usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
    790823                        return process_port_feature_set_request(instance,
    791                                 setup_request->value,
    792                                 setup_request->index);
     824                            setup_request->value,
     825                            setup_request->index);
    793826                }
    794827                usb_log_debug("USB_HUB_REQ_TYPE_INVALID %d\n",
    795                         setup_request->request_type);
     828                    setup_request->request_type);
    796829                return EINVAL;
    797830        }
     
    799832                usb_log_debug("USB_DEVREQ_SET_ADDRESS\n");
    800833                return process_address_set_request(instance,
    801                         setup_request->value);
     834                    setup_request->value);
    802835        }
    803836        usb_log_debug("USB_DEVREQ_SET_ENOTSUP %d\n",
    804                 setup_request->request_type);
     837            setup_request->request_type);
     838
    805839        return ENOTSUP;
    806840}
     
    836870        }
    837871        usb_log_info("CTRL packet: %s.\n",
    838                 usb_debug_str_buffer(
    839                 (const uint8_t *) request->setup_buffer, 8, 8));
     872            usb_debug_str_buffer(
     873            (const uint8_t *) request->setup_buffer, 8, 8));
    840874        usb_device_request_setup_packet_t * setup_request =
    841                 (usb_device_request_setup_packet_t*)
    842                 request->setup_buffer;
     875            (usb_device_request_setup_packet_t*)
     876            request->setup_buffer;
    843877        switch (setup_request->request) {
    844878                case USB_DEVREQ_GET_STATUS:
     
    847881                        usb_log_debug("processing request with output\n");
    848882                        opResult = process_request_with_output(
    849                                 instance, request);
     883                            instance, request);
    850884                        break;
    851885                case USB_DEVREQ_CLEAR_FEATURE:
     
    853887                case USB_DEVREQ_SET_ADDRESS:
    854888                        usb_log_debug("processing request without "
    855                                 "additional data\n");
     889                            "additional data\n");
    856890                        opResult = process_request_without_data(
    857                                 instance, request);
     891                            instance, request);
    858892                        break;
    859893                case USB_DEVREQ_SET_DESCRIPTOR:
    860894                case USB_DEVREQ_SET_CONFIGURATION:
    861895                        usb_log_debug("processing request with "
    862                                 "input\n");
     896                            "input\n");
    863897                        opResult = process_request_with_input(
    864                                 instance, request);
     898                            instance, request);
     899
    865900                        break;
    866901                default:
    867902                        usb_log_warning("received unsuported request: "
    868                                 "%d\n",
    869                                 setup_request->request
    870                                 );
     903                            "%d\n",
     904                            setup_request->request
     905                            );
    871906                        opResult = ENOTSUP;
    872907        }
     
    888923 * @return
    889924 */
    890 static int process_interrupt_mask_in_instance(rh_t *instance, usb_transfer_batch_t * request){
     925static int process_interrupt_mask_in_instance(rh_t *instance, usb_transfer_batch_t * request) {
    891926        memcpy(request->data_buffer, instance->interrupt_buffer,
    892927            instance->interrupt_mask_size);
     
    894929        instance->unfinished_interrupt_transfer = NULL;
    895930        usb_transfer_batch_finish_error(request, EOK);
     931
    896932        return EOK;
    897933}
     
    907943 * @return
    908944 */
    909 static bool is_zeros(void * buffer, size_t size){
    910         if(!buffer) return true;
    911         if(!size) return true;
     945static bool is_zeros(void * buffer, size_t size) {
     946        if (!buffer) return true;
     947        if (!size) return true;
    912948        size_t i;
    913         for(i=0;i<size;++i){
    914                 if(((char*)buffer)[i])
     949        for (i = 0; i < size; ++i) {
     950                if (((char*) buffer)[i])
    915951                        return false;
    916952        }
Note: See TracChangeset for help on using the changeset viewer.