Changeset 8565a42 in mainline for uspace/lib/usbhid/src


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
uspace/lib/usbhid/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhid/src/hiddescriptor.c

    r3061bc1 r8565a42  
    6363
    6464
    65        
     65
    6666/** The new report item flag. Used to determine when the item is completly
    6767 * configured and should be added to the report structure
     
    9595        link_t *path_it = report->collection_paths.head.next;
    9696        usb_hid_report_path_t *path = NULL;
    97        
     97
    9898        if((report == NULL) || (cmp_path == NULL)) {
    9999                return NULL;
    100100        }
    101        
     101
    102102        while(path_it != &report->collection_paths.head) {
    103103                path = list_get_instance(path_it, usb_hid_report_path_t,
    104104                                cpath_link);
    105                
     105
    106106                if(usb_hid_report_compare_usage_path(path, cmp_path,
    107107                                        USB_HID_PATH_COMPARE_STRICT) == 0){
     
    184184                usages = NULL;
    185185        }
    186        
     186
    187187        usb_hid_report_path_t *path = report_item->usage_path;
    188188        for(i=0; i<report_item->count; i++){
     
    237237                        }
    238238                }
    239                
     239
    240240                usb_hid_report_set_last_item(path, USB_HID_TAG_CLASS_GLOBAL,
    241241                                field->usage_page);
     
    261261                report_des = usb_hid_report_find_description(report,
    262262                        report_item->id, report_item->type);
    263                
     263
    264264                if(report_des == NULL){
    265265                        report_des = malloc(
     
    288288                /* append this field to the end of founded report list */
    289289                list_append(&field->ritems_link, &report_des->report_items);
    290                
     290
    291291                /* update the sizes */
    292292                report_des->bit_length += field->size;
     
    358358        size_t offset_output=0;
    359359        size_t offset_feature=0;
    360        
     360
    361361        link_t *item_link;
    362362
     
    368368                return EINVAL;
    369369        }
    370        
     370
    371371        /*report item initialization*/
    372372        if(!(report_item=malloc(sizeof(usb_hid_report_item_t)))){
     
    381381        }
    382382        usb_hid_report_path_append_item(usage_path, 0, 0);
    383        
     383
    384384        while(i<size){
    385385                if(!USB_HID_ITEM_IS_LONG(data[i])){
     
    388388                                return EINVAL;
    389389                        }
    390                        
     390
    391391                        tag = USB_HID_ITEM_TAG(data[i]);
    392392                        item_size = USB_HID_ITEM_SIZE(data[i]);
    393393                        class = USB_HID_ITEM_TAG_CLASS(data[i]);
    394                        
     394
    395395                        ret = usb_hid_report_parse_tag(tag,class,data+i+1,
    396396                                item_size,report_item, usage_path);
     
    402402                                 */
    403403                                report_item->usage_path = usage_path;
    404                                        
     404
    405405                                usb_hid_report_path_set_report_id(
    406406                                     report_item->usage_path, report_item->id);
    407                                
     407
    408408                                if(report_item->id != 0){
    409409                                        report->use_report_ids = 1;
    410410                                }
    411                                        
     411
    412412                                switch(tag) {
    413413                                case USB_HID_REPORT_TAG_INPUT:
     
    419419                                            report_item->size;
    420420                                        break;
    421        
     421
    422422                                case USB_HID_REPORT_TAG_OUTPUT:
    423423                                        report_item->type =
    424424                                            USB_HID_REPORT_TYPE_OUTPUT;
    425                                        
     425
    426426                                        report_item->offset = offset_output;
    427427                                        offset_output += report_item->count *
    428428                                            report_item->size;
    429429                                        break;
    430        
     430
    431431                                case USB_HID_REPORT_TAG_FEATURE:
    432432                                        report_item->type =
     
    437437                                                report_item->size;
    438438                                        break;
    439        
     439
    440440                                default:
    441441                                        usb_log_debug2(
     
    443443                                        break;
    444444                                }
    445                                        
     445
    446446                                /*
    447447                                 * append new fields to the report structure
     
    466466                                new_report_item = usb_hid_report_item_clone(
    467467                                    report_item);
    468                                
     468
    469469                                usb_hid_report_path_t *tmp_path =
    470470                                    usb_hid_report_path_clone(usage_path);
     
    481481                                }
    482482                                free(report_item);
    483                                
     483
    484484                                report_item = list_get_instance(item_link,
    485485                                    usb_hid_report_item_t, link);
    486                                
     486
    487487                                usb_hid_report_usage_path_t *tmp_usage_path;
    488488                                tmp_usage_path = list_get_instance(
    489489                                    report_item->usage_path->cpath_link.prev,
    490490                                    usb_hid_report_usage_path_t, rpath_items_link);
    491                                
     491
    492492                                usb_hid_report_set_last_item(usage_path,
    493493                                    USB_HID_TAG_CLASS_GLOBAL, tmp_usage_path->usage_page);
    494                                
     494
    495495                                usb_hid_report_set_last_item(usage_path,
    496496                                    USB_HID_TAG_CLASS_LOCAL, tmp_usage_path->usage);
     
    498498                                usb_hid_report_path_free(report_item->usage_path);
    499499                                list_remove (item_link);
    500                                        
     500
    501501                                break;
    502                                        
     502
    503503                        default:
    504504                                // nothing special to do
     
    513513                        i += 3 + USB_HID_ITEM_SIZE(data[i+1]);
    514514                }
    515                
    516 
    517         }
    518        
     515
     516
     517        }
     518
    519519        return EOK;
    520520}
     
    534534        size_t item_size, usb_hid_report_item_t *report_item,
    535535        usb_hid_report_path_t *usage_path) {
    536        
     536
    537537        int ret;
    538        
     538
    539539        switch(class){
    540540        case USB_HID_TAG_CLASS_MAIN:
     
    559559                        report_item, usage_path);
    560560                break;
    561        
     561
    562562        default:
    563563                return USB_HID_NO_ACTION;
     
    580580{
    581581        usb_hid_report_usage_path_t *path_item;
    582        
     582
    583583        switch(tag)
    584584        {
     
    589589                return 0;
    590590                break;
    591                        
     591
    592592        case USB_HID_REPORT_TAG_COLLECTION:
    593593
     
    596596                        usb_hid_report_usage_path_t, rpath_items_link);
    597597                path_item->flags = *data;
    598                        
     598
    599599                /* set last item */
    600600                usb_hid_report_set_last_item(usage_path,
     
    607607                        USB_HID_EXTENDED_USAGE(report_item->usages[
    608608                                report_item->usages_count-1]));
    609                        
     609
    610610                /* append the new one which will be set by common usage/usage
    611611                 * page */
     
    617617                return USB_HID_NO_ACTION;
    618618                break;
    619                        
     619
    620620        case USB_HID_REPORT_TAG_END_COLLECTION:
    621621                usb_hid_report_remove_last_item(usage_path);
     
    642642        size_t item_size, usb_hid_report_item_t *report_item,
    643643        usb_hid_report_path_t *usage_path) {
    644        
     644
    645645        switch(tag)
    646646        {
     
    699699                return USB_HID_RESET_OFFSET;
    700700                break;
    701        
     701
    702702        case USB_HID_REPORT_TAG_PUSH:
    703703        case USB_HID_REPORT_TAG_POP:
     
    708708                return tag;
    709709                break;
    710                        
     710
    711711        default:
    712712                return USB_HID_NO_ACTION;
     
    730730{
    731731        int32_t extended_usage;
    732        
     732
    733733        switch (tag) {
    734734        case USB_HID_REPORT_TAG_USAGE:
     
    740740                         */
    741741                        break;
    742                        
     742
    743743                case START_DELIMITER_SET:
    744744                        report_item->in_delimiter = INSIDE_DELIMITER_SET;
     
    748748                        extended_usage +=
    749749                            usb_hid_report_tag_data_uint32(data, item_size);
    750                        
     750
    751751                        report_item->usages[report_item->usages_count] =
    752752                            extended_usage;
    753                        
     753
    754754                        report_item->usages_count++;
    755755                        break;
    756756                }
    757757                break;
    758                
     758
    759759        case USB_HID_REPORT_TAG_USAGE_MINIMUM:
    760760                if (item_size == 3) {
     
    763763                            USB_HID_EXTENDED_USAGE_PAGE(
    764764                            usb_hid_report_tag_data_uint32(data, item_size));
    765                        
    766                        
     765
     766
    767767                        report_item->usage_minimum =
    768768                            USB_HID_EXTENDED_USAGE(
     
    773773                }
    774774                break;
    775                
     775
    776776        case USB_HID_REPORT_TAG_USAGE_MAXIMUM:
    777777                if (item_size == 3) {
     
    781781                                return USB_HID_INVALID;
    782782                        }
    783                        
     783
    784784                        /* Usage extended usages */
    785785                        report_item->extended_usage_page =
    786786                            USB_HID_EXTENDED_USAGE_PAGE(
    787787                            usb_hid_report_tag_data_uint32(data,item_size));
    788                        
     788
    789789                        report_item->usage_maximum =
    790790                            USB_HID_EXTENDED_USAGE(
     
    794794                            usb_hid_report_tag_data_uint32(data,item_size);
    795795                }
    796                
     796
    797797                /* Put the records into the usages array */
    798798                for (int32_t i = report_item->usage_minimum;
    799799                    i <= report_item->usage_maximum; i++) {
    800                        
     800
    801801                        if (report_item->extended_usage_page) {
    802802                                report_item->usages[report_item->usages_count++] =
     
    808808                }
    809809                report_item->extended_usage_page = 0;
    810                
    811                 break;
    812                
     810
     811                break;
     812
    813813        case USB_HID_REPORT_TAG_DESIGNATOR_INDEX:
    814814                report_item->designator_index =
    815815                    usb_hid_report_tag_data_uint32(data, item_size);
    816816                break;
    817        
     817
    818818        case USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM:
    819819                report_item->designator_minimum =
    820820                    usb_hid_report_tag_data_uint32(data, item_size);
    821821                break;
    822        
     822
    823823        case USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM:
    824824                report_item->designator_maximum =
    825825                    usb_hid_report_tag_data_uint32(data, item_size);
    826826                break;
    827        
     827
    828828        case USB_HID_REPORT_TAG_STRING_INDEX:
    829829                report_item->string_index =
    830830                    usb_hid_report_tag_data_uint32(data, item_size);
    831831                break;
    832        
     832
    833833        case USB_HID_REPORT_TAG_STRING_MINIMUM:
    834834                report_item->string_minimum =
    835835                    usb_hid_report_tag_data_uint32(data, item_size);
    836836                break;
    837        
     837
    838838        case USB_HID_REPORT_TAG_STRING_MAXIMUM:
    839839                report_item->string_maximum =
    840840                    usb_hid_report_tag_data_uint32(data, item_size);
    841841                break;
    842        
     842
    843843        case USB_HID_REPORT_TAG_DELIMITER:
    844844                report_item->in_delimiter =
    845845                    usb_hid_report_tag_data_uint32(data, item_size);
    846846                break;
    847        
     847
    848848        default:
    849849                return USB_HID_NO_ACTION;
    850850        }
    851        
     851
    852852        return 0;
    853853}
     
    965965                usb_hid_report_path_free(path);
    966966        }
    967        
     967
    968968        // free report items
    969969        usb_hid_report_description_t *report_des;
     
    974974
    975975                list_remove(&report_des->reports_link);
    976                
     976
    977977                while(!list_empty(&report_des->report_items)) {
    978978                        field = list_get_instance(
     
    984984                        free(field);
    985985                }
    986                
     986
    987987                free(report_des);
    988988        }
    989        
     989
    990990        return;
    991991}
  • uspace/lib/usbhid/src/hidreport.c

    r3061bc1 r8565a42  
    5555        assert(report_desc != NULL);
    5656        assert(size != NULL);
    57        
     57
    5858        usb_dp_parser_t parser =  {
    5959                .nesting = usb_dp_standard_descriptor_nesting
    6060        };
    61        
     61
    6262        usb_dp_parser_data_t parser_data = {
    6363                .data = usb_device_descriptors(dev)->full_config,
     
    6565                .arg = NULL
    6666        };
    67        
     67
    6868        /*
    6969         * First nested descriptor of the configuration descriptor.
     
    7272            usb_dp_get_nested_descriptor(&parser, &parser_data,
    7373            usb_device_descriptors(dev)->full_config);
    74        
     74
    7575        /*
    7676         * Find the interface descriptor corresponding to our interface number.
     
    8282                ++i;
    8383        }
    84        
     84
    8585        if (d == NULL) {
    8686                usb_log_error("The %d. interface descriptor not found!",
     
    8888                return ENOENT;
    8989        }
    90        
     90
    9191        /*
    9292         * First nested descriptor of the interface descriptor.
     
    9494        const uint8_t *iface_desc = d;
    9595        d = usb_dp_get_nested_descriptor(&parser, &parser_data, iface_desc);
    96        
     96
    9797        /*
    9898         * Search through siblings until the HID descriptor is found.
     
    102102                    iface_desc, d);
    103103        }
    104        
     104
    105105        if (d == NULL) {
    106106                usb_log_fatal("No HID descriptor found!");
    107107                return ENOENT;
    108108        }
    109        
     109
    110110        if (*d != sizeof(usb_standard_hid_descriptor_t)) {
    111111                usb_log_error("HID descriptor has wrong size (%u, expected %zu"
     
    113113                return EINVAL;
    114114        }
    115        
     115
    116116        usb_standard_hid_descriptor_t *hid_desc =
    117117            (usb_standard_hid_descriptor_t *)d;
    118        
     118
    119119        uint16_t length = uint16_usb2host(hid_desc->report_desc_info.length);
    120120        size_t actual_size = 0;
     
    129129                return ENOMEM;
    130130        }
    131        
     131
    132132        usb_log_debug("Getting Report descriptor, expected size: %u", length);
    133        
     133
    134134        /*
    135135         * Get the descriptor from the device.
     
    153153                return EINVAL;
    154154        }
    155        
     155
    156156        *size = length;
    157        
     157
    158158        usb_log_debug("Done.");
    159        
     159
    160160        return EOK;
    161161}
     
    171171                return EINVAL;
    172172        }
    173        
     173
    174174//      uint8_t *report_desc = NULL;
    175175//      size_t report_size;
    176        
     176
    177177        errno_t rc = usb_hid_get_report_descriptor(dev, report_desc, report_size);
    178        
     178
    179179        if (rc != EOK) {
    180180                usb_log_error("Problem with getting Report descriptor: %s.",
     
    186186                return rc;
    187187        }
    188        
     188
    189189        assert(*report_desc != NULL);
    190        
     190
    191191        rc = usb_hid_parse_report_descriptor(report, *report_desc, *report_size);
    192192        if (rc != EOK) {
     
    197197                return rc;
    198198        }
    199        
     199
    200200        usb_hid_descriptor_print(report);
    201        
     201
    202202        return EOK;
    203203}
Note: See TracChangeset for help on using the changeset viewer.