Ignore:
Timestamp:
2011-07-13T22:39:18Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6910c8
Parents:
5974661 (diff), 8ecef91 (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.
Message:

Merge libposix.

File:
1 edited

Legend:

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

    r5974661 re4f8c77  
    8888 * @retval NULL If some error occurs
    8989 */
    90 usb_hid_report_path_t *usb_hid_report_path_try_insert(
    91                 usb_hid_report_t *report, usb_hid_report_path_t *cmp_path) {
    92        
    93         link_t *path_it = report->collection_paths.prev->next;
     90usb_hid_report_path_t *usb_hid_report_path_try_insert(usb_hid_report_t *report,
     91    usb_hid_report_path_t *cmp_path)
     92{
     93        link_t *path_it = report->collection_paths.head.next;
    9494        usb_hid_report_path_t *path = NULL;
    9595       
     
    9898        }
    9999       
    100         while(path_it != &report->collection_paths) {
     100        while(path_it != &report->collection_paths.head) {
    101101                path = list_get_instance(path_it, usb_hid_report_path_t,
    102                                 link);
     102                                cpath_link);
    103103               
    104104                if(usb_hid_report_compare_usage_path(path, cmp_path,
    105105                                        USB_HID_PATH_COMPARE_STRICT) == EOK){
    106106                        break;
    107                 }                       
     107                }
    108108                path_it = path_it->next;
    109109        }
    110         if(path_it == &report->collection_paths) {
     110        if(path_it == &report->collection_paths.head) {
    111111                path = usb_hid_report_path_clone(cmp_path);
    112112                if(path == NULL) {
    113113                        return NULL;
    114114                }
    115                 list_append(&path->link, &report->collection_paths);                                   
     115                list_append(&path->cpath_link, &report->collection_paths);
    116116                report->collection_paths_count++;
    117117
     
    120120        else {
    121121                return list_get_instance(path_it, usb_hid_report_path_t,
    122                                 link);
     122                                cpath_link);
    123123        }
    124124}
     
    192192
    193193                memset(field, 0, sizeof(usb_hid_report_field_t));
    194                 list_initialize(&field->link);
     194                link_initialize(&field->ritems_link);
    195195
    196196                /* fill the attributes */               
     
    291291                        }
    292292
    293                         list_initialize (&report_des->link);
     293                        link_initialize (&report_des->reports_link);
    294294                        list_initialize (&report_des->report_items);
    295295
    296                         list_append(&report_des->link, &report->reports);
     296                        list_append(&report_des->reports_link, &report->reports);
    297297                        report->report_count++;
    298298                }
    299299
    300300                /* append this field to the end of founded report list */
    301                 list_append (&field->link, &report_des->report_items);
     301                list_append(&field->ritems_link, &report_des->report_items);
    302302               
    303303                /* update the sizes */
     
    333333        }
    334334
    335         link_t *report_it = report->reports.next;
    336335        usb_hid_report_description_t *report_des = NULL;
    337336       
    338         while(report_it != &report->reports) {
     337        list_foreach(report->reports, report_it) {
    339338                report_des = list_get_instance(report_it,
    340                                 usb_hid_report_description_t, link);
     339                                usb_hid_report_description_t, reports_link);
    341340
    342341                // if report id not set, return the first of the type
     
    345344                        return report_des;
    346345                }
    347                
    348                 report_it = report_it->next;
    349346        }
    350347
     
    377374        size_t offset_output=0;
    378375        size_t offset_feature=0;
    379 
    380         link_t stack;
    381         list_initialize(&stack);       
     376       
     377        link_t *item_link;
     378
     379        list_t stack;
     380        list_initialize(&stack);
    382381
    383382        /* parser structure initialization*/
     
    391390        }
    392391        memset(report_item, 0, sizeof(usb_hid_report_item_t));
    393         list_initialize(&(report_item->link)); 
     392        link_initialize(&(report_item->link));
    394393
    395394        /* usage path context initialization */
     
    493492                        case USB_HID_REPORT_TAG_POP:
    494493                                // restore current state from stack
    495                                 if(list_empty (&stack)) {
     494                                item_link = list_first(&stack);
     495                                if (item_link == NULL) {
    496496                                        return EINVAL;
    497497                                }
    498498                                free(report_item);
    499                                                
    500                                 report_item = list_get_instance(stack.next,
     499                               
     500                                report_item = list_get_instance(item_link,
    501501                                    usb_hid_report_item_t, link);
    502                                        
     502                               
    503503                                usb_hid_report_usage_path_t *tmp_usage_path;
    504504                                tmp_usage_path = list_get_instance(
    505                                     report_item->usage_path->link.prev,
    506                                     usb_hid_report_usage_path_t, link);
    507                                        
     505                                    report_item->usage_path->cpath_link.prev,
     506                                    usb_hid_report_usage_path_t, rpath_items_link);
     507                               
    508508                                usb_hid_report_set_last_item(usage_path,
    509509                                    USB_HID_TAG_CLASS_GLOBAL, tmp_usage_path->usage_page);
     
    513513
    514514                                usb_hid_report_path_free(report_item->usage_path);
    515                                 list_initialize(&report_item->usage_path->link);
    516                                 list_remove (stack.next);
     515                                list_remove (item_link);
    517516                                       
    518517                                break;
     
    610609
    611610                /* store collection atributes */
    612                 path_item = list_get_instance(usage_path->head.prev,
    613                         usb_hid_report_usage_path_t, link);
    614                 path_item->flags = *data;       
     611                path_item = list_get_instance(list_first(&usage_path->items),
     612                        usb_hid_report_usage_path_t, rpath_items_link);
     613                path_item->flags = *data;
    615614                       
    616615                /* set last item */
     
    901900 * @return void
    902901 */
    903 void usb_hid_descriptor_print_list(link_t *head)
     902void usb_hid_descriptor_print_list(list_t *list)
    904903{
    905904        usb_hid_report_field_t *report_item;
    906         link_t *item;
    907 
    908 
    909         if(head == NULL || list_empty(head)) {
     905
     906        if(list == NULL || list_empty(list)) {
    910907            usb_log_debug("\tempty\n");
    911908            return;
    912909        }
    913        
    914         for(item = head->next; item != head; item = item->next) {
    915                
    916                 report_item = list_get_instance(item, usb_hid_report_field_t,
    917                                 link);
     910
     911        list_foreach(*list, item) {
     912                report_item = list_get_instance(item, usb_hid_report_field_t,
     913                                ritems_link);
    918914
    919915                usb_log_debug("\t\tOFFSET: %X\n", report_item->offset);
    920916                usb_log_debug("\t\tSIZE: %zu\n", report_item->size);
    921                 usb_log_debug("\t\tLOGMIN: %d\n", 
     917                usb_log_debug("\t\tLOGMIN: %d\n",
    922918                        report_item->logical_minimum);
    923                 usb_log_debug("\t\tLOGMAX: %d\n", 
    924                         report_item->logical_maximum);         
    925                 usb_log_debug("\t\tPHYMIN: %d\n", 
    926                         report_item->physical_minimum);         
    927                 usb_log_debug("\t\tPHYMAX: %d\n", 
    928                         report_item->physical_maximum);                         
    929                 usb_log_debug("\t\ttUSAGEMIN: %X\n", 
     919                usb_log_debug("\t\tLOGMAX: %d\n",
     920                        report_item->logical_maximum);
     921                usb_log_debug("\t\tPHYMIN: %d\n",
     922                        report_item->physical_minimum);
     923                usb_log_debug("\t\tPHYMAX: %d\n",
     924                        report_item->physical_maximum);
     925                usb_log_debug("\t\ttUSAGEMIN: %X\n",
    930926                        report_item->usage_minimum);
    931927                usb_log_debug("\t\tUSAGEMAX: %X\n",
    932928                               report_item->usage_maximum);
    933                 usb_log_debug("\t\tUSAGES COUNT: %zu\n", 
     929                usb_log_debug("\t\tUSAGES COUNT: %zu\n",
    934930                        report_item->usages_count);
    935931
     
    937933                usb_log_debug("\t\ttUSAGE: %X\n", report_item->usage);
    938934                usb_log_debug("\t\tUSAGE PAGE: %X\n", report_item->usage_page);
    939                
     935
    940936                usb_hid_print_usage_path(report_item->collection_path);
    941937
    942                 usb_log_debug("\n");           
     938                usb_log_debug("\n");
    943939
    944940        }
     
    959955        }
    960956
    961         link_t *report_it = report->reports.next;
    962957        usb_hid_report_description_t *report_des;
    963958
    964         while(report_it != &report->reports) {
    965                 report_des = list_get_instance(report_it, 
    966                         usb_hid_report_description_t, link);
     959        list_foreach(report->reports, report_it) {
     960                report_des = list_get_instance(report_it,
     961                        usb_hid_report_description_t, reports_link);
    967962                usb_log_debug("Report ID: %d\n", report_des->report_id);
    968963                usb_log_debug("\tType: %d\n", report_des->type);
    969                 usb_log_debug("\tLength: %zu\n", report_des->bit_length);               
     964                usb_log_debug("\tLength: %zu\n", report_des->bit_length);
    970965                usb_log_debug("\tB Size: %zu\n",
    971                         usb_hid_report_byte_size(report, 
    972                                 report_des->report_id, 
     966                        usb_hid_report_byte_size(report,
     967                                report_des->report_id,
    973968                                report_des->type));
    974                 usb_log_debug("\tItems: %zu\n", report_des->item_length);               
     969                usb_log_debug("\tItems: %zu\n", report_des->item_length);
    975970
    976971                usb_hid_descriptor_print_list(&report_des->report_items);
    977 
    978                 report_it = report_it->next;
    979972        }
    980973}
     
    984977 * Releases whole linked list of report items
    985978 *
    986  * @param head Head of list of report descriptor items (usb_hid_report_item_t)
     979 * @param list List of report descriptor items (usb_hid_report_item_t)
    987980 * @return void
    988981 */
    989 void usb_hid_free_report_list(link_t *head)
     982void usb_hid_free_report_list(list_t *list)
    990983{
    991         return;
    992        
    993         usb_hid_report_item_t *report_item;
     984        return; /* XXX What's this? */
     985       
     986/*      usb_hid_report_item_t *report_item;
    994987        link_t *next;
    995988       
    996         if(head == NULL || list_empty(head)) {         
     989        if(list == NULL || list_empty(list)) {
    997990            return;
    998991        }
    999992       
    1000         next = head->next;
    1001         while(next != head) {
    1002        
    1003             report_item = list_get_instance(next, usb_hid_report_item_t, link);
     993        next = list->head.next;
     994        while (next != &list->head) {
     995                report_item = list_get_instance(next, usb_hid_report_item_t,
     996                    rpath_items_link);
    1004997
    1005998                while(!list_empty(&report_item->usage_path->link)) {
    1006                     usb_hid_report_remove_last_item(report_item->usage_path);
     999                        usb_hid_report_remove_last_item(report_item->usage_path);
    10071000                }
    10081001
     
    10141007       
    10151008        return;
    1016        
     1009        */
    10171010}
    10181011/*---------------------------------------------------------------------------*/
     
    10301023
    10311024        // free collection paths
     1025        link_t *path_link;
    10321026        usb_hid_report_path_t *path;
    10331027        while(!list_empty(&report->collection_paths)) {
    1034                 path = list_get_instance(report->collection_paths.next,
    1035                                 usb_hid_report_path_t, link);
    1036 
    1037                 usb_hid_report_path_free(path);         
     1028                path_link = list_first(&report->collection_paths);
     1029                path = list_get_instance(path_link,
     1030                    usb_hid_report_path_t, cpath_link);
     1031
     1032                list_remove(path_link);
     1033                usb_hid_report_path_free(path);
    10381034        }
    10391035       
     
    10421038        usb_hid_report_field_t *field;
    10431039        while(!list_empty(&report->reports)) {
    1044                 report_des = list_get_instance(report->reports.next,
    1045                                 usb_hid_report_description_t, link);
    1046 
    1047                 list_remove(&report_des->link);
     1040                report_des = list_get_instance(list_first(&report->reports),
     1041                                usb_hid_report_description_t, reports_link);
     1042
     1043                list_remove(&report_des->reports_link);
    10481044               
    10491045                while(!list_empty(&report_des->report_items)) {
    10501046                        field = list_get_instance(
    1051                                 report_des->report_items.next,
    1052                                 usb_hid_report_field_t, link);
    1053 
    1054                         list_remove(&field->link);
     1047                            list_first(&report_des->report_items),
     1048                            usb_hid_report_field_t, ritems_link);
     1049
     1050                        list_remove(&field->ritems_link);
    10551051
    10561052                        free(field);
Note: See TracChangeset for help on using the changeset viewer.