Changes in uspace/lib/usbhid/src/hidpath.c [b72efe8:dcb7d7cd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hidpath.c
rb72efe8 rdcb7d7cd 81 81 return ENOMEM; 82 82 } 83 li nk_initialize(&item->rpath_items_link);83 list_initialize(&item->link); 84 84 85 85 item->usage = usage; … … 87 87 item->flags = 0; 88 88 89 list_append (&item-> rpath_items_link, &usage_path->items);89 list_append (&item->link, &usage_path->head); 90 90 usage_path->depth++; 91 91 return EOK; … … 100 100 void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path) 101 101 { 102 link_t *item_link;103 102 usb_hid_report_usage_path_t *item; 104 103 105 if(!list_empty(&usage_path->items)){ 106 item_link = list_last(&usage_path->items); 107 item = list_get_instance(item_link, 108 usb_hid_report_usage_path_t, rpath_items_link); 109 list_remove(item_link); 104 if(!list_empty(&usage_path->head)){ 105 item = list_get_instance(usage_path->head.prev, 106 usb_hid_report_usage_path_t, link); 107 list_remove(usage_path->head.prev); 110 108 usage_path->depth--; 111 109 free(item); … … 124 122 usb_hid_report_usage_path_t *item; 125 123 126 if(!list_empty(&usage_path-> items)){127 item = list_get_instance( list_last(&usage_path->items),128 usb_hid_report_usage_path_t, rpath_items_link);124 if(!list_empty(&usage_path->head)){ 125 item = list_get_instance(usage_path->head.prev, 126 usb_hid_report_usage_path_t, link); 129 127 130 128 memset(item, 0, sizeof(usb_hid_report_usage_path_t)); … … 147 145 usb_hid_report_usage_path_t *item; 148 146 149 if(!list_empty(&usage_path-> items)){150 item = list_get_instance( list_last(&usage_path->items),151 usb_hid_report_usage_path_t, rpath_items_link);147 if(!list_empty(&usage_path->head)){ 148 item = list_get_instance(usage_path->head.prev, 149 usb_hid_report_usage_path_t, link); 152 150 153 151 switch(tag) { … … 175 173 usb_log_debug("\tLENGTH: %d\n", path->depth); 176 174 175 link_t *item = path->head.next; 177 176 usb_hid_report_usage_path_t *path_item; 178 179 list_foreach(path->items, item) { 180 path_item = list_get_instance(item, usb_hid_report_usage_path_t, 181 rpath_items_link);177 while(item != &path->head) { 178 179 path_item = list_get_instance(item, usb_hid_report_usage_path_t, 180 link); 182 181 183 182 usb_log_debug("\tUSAGE_PAGE: %X\n", path_item->usage_page); 184 183 usb_log_debug("\tUSAGE: %X\n", path_item->usage); 185 usb_log_debug("\tFLAGS: %d\n", path_item->flags); 184 usb_log_debug("\tFLAGS: %d\n", path_item->flags); 185 186 item = item->next; 186 187 } 187 188 } … … 232 233 } 233 234 234 path_link = list_first(&path->items); 235 path_item = list_get_instance(path_link, 236 usb_hid_report_usage_path_t, rpath_items_link); 237 238 list_foreach(report_path->items, report_link) { 239 report_item = list_get_instance(report_link, 240 usb_hid_report_usage_path_t, rpath_items_link); 235 report_link = report_path->head.next; 236 path_link = path->head.next; 237 path_item = list_get_instance(path_link, 238 usb_hid_report_usage_path_t, link); 239 240 while(report_link != &report_path->head) { 241 report_item = list_get_instance(report_link, 242 usb_hid_report_usage_path_t, link); 241 243 242 if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 244 if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 243 245 path_item->usage_page)){ 244 246 … … 255 257 } 256 258 } 259 260 report_link = report_link->next; 257 261 } 258 262 … … 269 273 case USB_HID_PATH_COMPARE_BEGIN: 270 274 271 report_link = report_path-> items.head.next;272 path_link = path-> items.head.next;275 report_link = report_path->head.next; 276 path_link = path->head.next; 273 277 274 while((report_link != &report_path-> items.head) &&275 (path_link != &path-> items.head)) {278 while((report_link != &report_path->head) && 279 (path_link != &path->head)) { 276 280 277 281 report_item = list_get_instance(report_link, 278 usb_hid_report_usage_path_t, rpath_items_link);282 usb_hid_report_usage_path_t, link); 279 283 280 284 path_item = list_get_instance(path_link, 281 usb_hid_report_usage_path_t, rpath_items_link);285 usb_hid_report_usage_path_t, link); 282 286 283 287 if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, … … 293 297 } 294 298 295 }299 } 296 300 297 301 if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 298 (path_link == &path-> items.head)) ||299 ((report_link == &report_path-> items.head) &&300 (path_link == &path-> items.head))) {302 (path_link == &path->head)) || 303 ((report_link == &report_path->head) && 304 (path_link == &path->head))) { 301 305 302 306 return EOK; … … 310 314 case USB_HID_PATH_COMPARE_END: 311 315 312 report_link = report_path-> items.head.prev;313 path_link = path-> items.head.prev;314 315 if(list_empty(&path-> items)){316 report_link = report_path->head.prev; 317 path_link = path->head.prev; 318 319 if(list_empty(&path->head)){ 316 320 return EOK; 317 321 } 318 322 319 while((report_link != &report_path-> items.head) &&320 (path_link != &path-> items.head)) {323 while((report_link != &report_path->head) && 324 (path_link != &path->head)) { 321 325 322 report_item = list_get_instance(report_link, 323 usb_hid_report_usage_path_t, rpath_items_link);326 report_item = list_get_instance(report_link, 327 usb_hid_report_usage_path_t, link); 324 328 325 329 path_item = list_get_instance(path_link, 326 usb_hid_report_usage_path_t, rpath_items_link);330 usb_hid_report_usage_path_t, link); 327 331 328 332 if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, … … 339 343 } 340 344 341 if(path_link == &path-> items.head) {345 if(path_link == &path->head) { 342 346 return EOK; 343 347 } … … 369 373 path->depth = 0; 370 374 path->report_id = 0; 371 li nk_initialize(&path->cpath_link);372 list_initialize(&path-> items);375 list_initialize(&path->link); 376 list_initialize(&path->head); 373 377 return path; 374 378 } … … 384 388 void usb_hid_report_path_free(usb_hid_report_path_t *path) 385 389 { 386 while(!list_empty(&path-> items)){390 while(!list_empty(&path->head)){ 387 391 usb_hid_report_remove_last_item(path); 388 392 } 389 393 390 assert_link_not_used(&path->cpath_link);394 list_remove(&path->link); 391 395 free(path); 392 396 } … … 402 406 usb_hid_report_path_t *usage_path) 403 407 { 408 link_t *path_link; 404 409 usb_hid_report_usage_path_t *path_item; 405 410 usb_hid_report_usage_path_t *new_path_item; … … 412 417 new_usage_path->report_id = usage_path->report_id; 413 418 414 if(list_empty(&usage_path-> items)){419 if(list_empty(&usage_path->head)){ 415 420 return new_usage_path; 416 421 } 417 422 418 list_foreach(usage_path->items, path_link) { 419 path_item = list_get_instance(path_link, 420 usb_hid_report_usage_path_t, rpath_items_link); 423 path_link = usage_path->head.next; 424 while(path_link != &usage_path->head) { 425 path_item = list_get_instance(path_link, 426 usb_hid_report_usage_path_t, link); 421 427 422 428 new_path_item = malloc(sizeof(usb_hid_report_usage_path_t)); … … 425 431 } 426 432 427 li nk_initialize(&new_path_item->rpath_items_link);433 list_initialize (&new_path_item->link); 428 434 new_path_item->usage_page = path_item->usage_page; 429 435 new_path_item->usage = path_item->usage; 430 436 new_path_item->flags = path_item->flags; 431 437 432 list_append(&new_path_item->rpath_items_link, 433 &new_usage_path->items); 438 list_append(&new_path_item->link, &new_usage_path->head); 434 439 new_usage_path->depth++; 440 441 path_link = path_link->next; 435 442 } 436 443
Note:
See TracChangeset
for help on using the changeset viewer.