Changes in uspace/lib/usbhid/src/hiddescriptor.c [b72efe8:0dd3e49] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hiddescriptor.c
rb72efe8 r0dd3e49 88 88 * @retval NULL If some error occurs 89 89 */ 90 usb_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;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; 94 94 usb_hid_report_path_t *path = NULL; 95 95 … … 98 98 } 99 99 100 while(path_it != &report->collection_paths .head) {100 while(path_it != &report->collection_paths) { 101 101 path = list_get_instance(path_it, usb_hid_report_path_t, 102 cpath_link);102 link); 103 103 104 104 if(usb_hid_report_compare_usage_path(path, cmp_path, 105 105 USB_HID_PATH_COMPARE_STRICT) == EOK){ 106 106 break; 107 } 107 } 108 108 path_it = path_it->next; 109 109 } 110 if(path_it == &report->collection_paths .head) {110 if(path_it == &report->collection_paths) { 111 111 path = usb_hid_report_path_clone(cmp_path); 112 112 if(path == NULL) { 113 113 return NULL; 114 114 } 115 list_append(&path-> cpath_link, &report->collection_paths);115 list_append(&path->link, &report->collection_paths); 116 116 report->collection_paths_count++; 117 117 … … 120 120 else { 121 121 return list_get_instance(path_it, usb_hid_report_path_t, 122 cpath_link);122 link); 123 123 } 124 124 } … … 192 192 193 193 memset(field, 0, sizeof(usb_hid_report_field_t)); 194 li nk_initialize(&field->ritems_link);194 list_initialize(&field->link); 195 195 196 196 /* fill the attributes */ … … 291 291 } 292 292 293 li nk_initialize (&report_des->reports_link);293 list_initialize (&report_des->link); 294 294 list_initialize (&report_des->report_items); 295 295 296 list_append(&report_des-> reports_link, &report->reports);296 list_append(&report_des->link, &report->reports); 297 297 report->report_count++; 298 298 } 299 299 300 300 /* append this field to the end of founded report list */ 301 list_append (&field->ritems_link, &report_des->report_items);301 list_append (&field->link, &report_des->report_items); 302 302 303 303 /* update the sizes */ … … 333 333 } 334 334 335 link_t *report_it = report->reports.next; 335 336 usb_hid_report_description_t *report_des = NULL; 336 337 337 list_foreach(report->reports, report_it) {338 while(report_it != &report->reports) { 338 339 report_des = list_get_instance(report_it, 339 usb_hid_report_description_t, reports_link);340 usb_hid_report_description_t, link); 340 341 341 342 // if report id not set, return the first of the type … … 344 345 return report_des; 345 346 } 347 348 report_it = report_it->next; 346 349 } 347 350 … … 374 377 size_t offset_output=0; 375 378 size_t offset_feature=0; 376 377 link_t *item_link; 378 379 list_t stack; 380 list_initialize(&stack); 379 380 link_t stack; 381 list_initialize(&stack); 381 382 382 383 /* parser structure initialization*/ … … 390 391 } 391 392 memset(report_item, 0, sizeof(usb_hid_report_item_t)); 392 li nk_initialize(&(report_item->link));393 list_initialize(&(report_item->link)); 393 394 394 395 /* usage path context initialization */ … … 492 493 case USB_HID_REPORT_TAG_POP: 493 494 // restore current state from stack 494 item_link = list_first(&stack); 495 if (item_link == NULL) { 495 if(list_empty (&stack)) { 496 496 return EINVAL; 497 497 } 498 498 free(report_item); 499 500 report_item = list_get_instance( item_link,499 500 report_item = list_get_instance(stack.next, 501 501 usb_hid_report_item_t, link); 502 502 503 503 usb_hid_report_usage_path_t *tmp_usage_path; 504 504 tmp_usage_path = list_get_instance( 505 report_item->usage_path-> cpath_link.prev,506 usb_hid_report_usage_path_t, rpath_items_link);507 505 report_item->usage_path->link.prev, 506 usb_hid_report_usage_path_t, link); 507 508 508 usb_hid_report_set_last_item(usage_path, 509 509 USB_HID_TAG_CLASS_GLOBAL, tmp_usage_path->usage_page); … … 513 513 514 514 usb_hid_report_path_free(report_item->usage_path); 515 list_remove (item_link); 515 list_initialize(&report_item->usage_path->link); 516 list_remove (stack.next); 516 517 517 518 break; … … 609 610 610 611 /* store collection atributes */ 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; 612 path_item = list_get_instance(usage_path->head.prev, 613 usb_hid_report_usage_path_t, link); 614 path_item->flags = *data; 614 615 615 616 /* set last item */ … … 900 901 * @return void 901 902 */ 902 void usb_hid_descriptor_print_list(li st_t *list)903 void usb_hid_descriptor_print_list(link_t *head) 903 904 { 904 905 usb_hid_report_field_t *report_item; 905 906 if(list == NULL || list_empty(list)) { 906 link_t *item; 907 908 909 if(head == NULL || list_empty(head)) { 907 910 usb_log_debug("\tempty\n"); 908 911 return; 909 912 } 910 911 list_foreach(*list, item) { 912 report_item = list_get_instance(item, usb_hid_report_field_t, 913 ritems_link); 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); 914 918 915 919 usb_log_debug("\t\tOFFSET: %X\n", report_item->offset); 916 920 usb_log_debug("\t\tSIZE: %zu\n", report_item->size); 917 usb_log_debug("\t\tLOGMIN: %d\n", 921 usb_log_debug("\t\tLOGMIN: %d\n", 918 922 report_item->logical_minimum); 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", 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", 926 930 report_item->usage_minimum); 927 931 usb_log_debug("\t\tUSAGEMAX: %X\n", 928 932 report_item->usage_maximum); 929 usb_log_debug("\t\tUSAGES COUNT: %zu\n", 933 usb_log_debug("\t\tUSAGES COUNT: %zu\n", 930 934 report_item->usages_count); 931 935 … … 933 937 usb_log_debug("\t\ttUSAGE: %X\n", report_item->usage); 934 938 usb_log_debug("\t\tUSAGE PAGE: %X\n", report_item->usage_page); 935 939 936 940 usb_hid_print_usage_path(report_item->collection_path); 937 941 938 usb_log_debug("\n"); 942 usb_log_debug("\n"); 939 943 940 944 } … … 955 959 } 956 960 961 link_t *report_it = report->reports.next; 957 962 usb_hid_report_description_t *report_des; 958 963 959 list_foreach(report->reports, report_it) {960 report_des = list_get_instance(report_it, 961 usb_hid_report_description_t, reports_link);964 while(report_it != &report->reports) { 965 report_des = list_get_instance(report_it, 966 usb_hid_report_description_t, link); 962 967 usb_log_debug("Report ID: %d\n", report_des->report_id); 963 968 usb_log_debug("\tType: %d\n", report_des->type); 964 usb_log_debug("\tLength: %zu\n", report_des->bit_length); 969 usb_log_debug("\tLength: %zu\n", report_des->bit_length); 965 970 usb_log_debug("\tB Size: %zu\n", 966 usb_hid_report_byte_size(report, 967 report_des->report_id, 971 usb_hid_report_byte_size(report, 972 report_des->report_id, 968 973 report_des->type)); 969 usb_log_debug("\tItems: %zu\n", report_des->item_length); 974 usb_log_debug("\tItems: %zu\n", report_des->item_length); 970 975 971 976 usb_hid_descriptor_print_list(&report_des->report_items); 977 978 report_it = report_it->next; 972 979 } 973 980 } … … 977 984 * Releases whole linked list of report items 978 985 * 979 * @param list List of report descriptor items (usb_hid_report_item_t)986 * @param head Head of list of report descriptor items (usb_hid_report_item_t) 980 987 * @return void 981 988 */ 982 void usb_hid_free_report_list(li st_t *list)989 void usb_hid_free_report_list(link_t *head) 983 990 { 984 return; /* XXX What's this? */985 986 /*usb_hid_report_item_t *report_item;991 return; 992 993 usb_hid_report_item_t *report_item; 987 994 link_t *next; 988 995 989 if( list == NULL || list_empty(list)) {996 if(head == NULL || list_empty(head)) { 990 997 return; 991 998 } 992 999 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);1000 next = head->next; 1001 while(next != head) { 1002 1003 report_item = list_get_instance(next, usb_hid_report_item_t, link); 997 1004 998 1005 while(!list_empty(&report_item->usage_path->link)) { 999 1006 usb_hid_report_remove_last_item(report_item->usage_path); 1000 1007 } 1001 1008 … … 1007 1014 1008 1015 return; 1009 */1016 1010 1017 } 1011 1018 /*---------------------------------------------------------------------------*/ … … 1023 1030 1024 1031 // free collection paths 1025 link_t *path_link;1026 1032 usb_hid_report_path_t *path; 1027 1033 while(!list_empty(&report->collection_paths)) { 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); 1034 path = list_get_instance(report->collection_paths.next, 1035 usb_hid_report_path_t, link); 1036 1037 usb_hid_report_path_free(path); 1034 1038 } 1035 1039 … … 1038 1042 usb_hid_report_field_t *field; 1039 1043 while(!list_empty(&report->reports)) { 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);1044 report_des = list_get_instance(report->reports.next, 1045 usb_hid_report_description_t, link); 1046 1047 list_remove(&report_des->link); 1044 1048 1045 1049 while(!list_empty(&report_des->report_items)) { 1046 1050 field = list_get_instance( 1047 list_first(&report_des->report_items),1048 usb_hid_report_field_t, ritems_link);1049 1050 list_remove(&field-> ritems_link);1051 report_des->report_items.next, 1052 usb_hid_report_field_t, link); 1053 1054 list_remove(&field->link); 1051 1055 1052 1056 free(field);
Note:
See TracChangeset
for help on using the changeset viewer.