Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified uspace/lib/usbhid/src/hidpath.c

    r07525cd r9d58539  
    4141#include <assert.h>
    4242
    43 
     43/*---------------------------------------------------------------------------*/
    4444/**
    4545 * Compares two usages if they are same or not or one of the usages is not
     
    6363        ((page1 == page2) || (page1 == 0) || (page2 == 0))
    6464
    65 
     65/*---------------------------------------------------------------------------*/
    6666/**
    6767 * Appends one item (couple of usage_path and usage) into the usage path
     
    9393}
    9494
    95 
     95/*---------------------------------------------------------------------------*/
    9696/**
    9797 * Removes last item from the usage path structure
     
    114114}
    115115
    116 
     116/*---------------------------------------------------------------------------*/
    117117/**
    118118 * Nulls last item of the usage path structure.
     
    133133}
    134134
    135 
     135/*---------------------------------------------------------------------------*/
    136136/**
    137137 * Modifies last item of usage path structure by given usage page or usage
     
    164164}
    165165
    166 
     166/*---------------------------------------------------------------------------*/
    167167/**
    168168 *
     
    176176        usb_log_debug("\tLENGTH: %d\n", path->depth);
    177177
    178         list_foreach(path->items, rpath_items_link,
    179             usb_hid_report_usage_path_t, path_item) {
     178        usb_hid_report_usage_path_t *path_item;
     179
     180        list_foreach(path->items, item) {
     181                path_item = list_get_instance(item, usb_hid_report_usage_path_t,
     182                        rpath_items_link);
    180183
    181184                usb_log_debug("\tUSAGE_PAGE: %X\n", path_item->usage_page);
     
    185188}
    186189
    187 
     190/*---------------------------------------------------------------------------*/
    188191/**
    189192 * Compares two usage paths structures
     
    234237                        usb_hid_report_usage_path_t, rpath_items_link);
    235238
    236                 list_foreach(report_path->items, rpath_items_link,
    237                     usb_hid_report_usage_path_t, report_item) {
    238 
    239                         if (USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    240                                 path_item->usage_page)) {
     239                list_foreach(report_path->items, report_link) {
     240                        report_item = list_get_instance(report_link,
     241                                usb_hid_report_usage_path_t, rpath_items_link);
    241242                               
    242                                 if (only_page == 0) {
    243                                         if (USB_HID_SAME_USAGE(report_item->usage,
    244                                             path_item->usage))
     243                        if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
     244                                path_item->usage_page)){
     245                                       
     246                                if(only_page == 0){
     247                                        if(USB_HID_SAME_USAGE(
     248                                                report_item->usage,
     249                                                path_item->usage)) {
     250                                                       
    245251                                                return EOK;
     252                                        }
    246253                                }
    247254                                else {
     
    259266                        return 1;
    260267                }
    261 
     268               
    262269        /* path is prefix of the report_path */
    263270        case USB_HID_PATH_COMPARE_BEGIN:
    264 
     271       
    265272                report_link = report_path->items.head.next;
    266273                path_link = path->items.head.next;
    267                
    268                 while ((report_link != &report_path->items.head) &&
    269                     (path_link != &path->items.head)) {
    270274                       
     275                while((report_link != &report_path->items.head) &&
     276                      (path_link != &path->items.head)) {
     277                                         
    271278                        report_item = list_get_instance(report_link,
    272                             usb_hid_report_usage_path_t, rpath_items_link);
    273                        
     279                                usb_hid_report_usage_path_t, rpath_items_link);
     280                                         
    274281                        path_item = list_get_instance(path_link,
    275282                                usb_hid_report_usage_path_t, rpath_items_link);
    276283
    277                         if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    278                             path_item->usage_page) || ((only_page == 0) &&
     284                        if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
     285                                path_item->usage_page) || ((only_page == 0) &&
    279286                            !USB_HID_SAME_USAGE(report_item->usage,
    280                             path_item->usage))) {
     287                                path_item->usage))) {
     288                       
    281289                                return 1;
    282                         } else {
     290                        }
     291                        else {
    283292                                report_link = report_link->next;
    284                                 path_link = path_link->next;
     293                                path_link = path_link->next;                   
    285294                        }
    286                 }
    287 
    288                 if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) &&
    289                     (path_link == &path->items.head)) ||
    290                     ((report_link == &report_path->items.head) &&
    291                     (path_link == &path->items.head))) {
     295                       
     296                }
     297
     298                if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) &&
     299                        (path_link == &path->items.head)) ||
     300                   ((report_link == &report_path->items.head) &&
     301                        (path_link == &path->items.head))) {
     302                               
    292303                        return EOK;
    293                 } else {
     304                }
     305                else {
    294306                        return 1;
    295                 }
     307                }                                               
    296308                break;
    297309
     
    342354}
    343355
    344 
     356/*---------------------------------------------------------------------------*/
    345357/**
    346358 * Allocates and initializes new usage path structure.
     
    364376}
    365377
    366 
     378/*---------------------------------------------------------------------------*/
    367379/**
    368380 * Releases given usage path structure.
     
    383395}
    384396
    385 
     397/*---------------------------------------------------------------------------*/
    386398/**
    387399 * Clone content of given usage path to the new one
     
    393405        usb_hid_report_path_t *usage_path)
    394406{
     407        usb_hid_report_usage_path_t *path_item;
    395408        usb_hid_report_usage_path_t *new_path_item;
    396409        usb_hid_report_path_t *new_usage_path = usb_hid_report_path ();
     
    406419        }
    407420
    408         list_foreach(usage_path->items, rpath_items_link,
    409             usb_hid_report_usage_path_t, path_item) {
     421        list_foreach(usage_path->items, path_link) {
     422                path_item = list_get_instance(path_link,
     423                        usb_hid_report_usage_path_t, rpath_items_link);
    410424
    411425                new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
     
    427441}
    428442
    429 
     443/*---------------------------------------------------------------------------*/
    430444/**
    431445 * Sets report id in usage path structure
Note: See TracChangeset for help on using the changeset viewer.