Changeset e141281 in mainline


Ignore:
Timestamp:
2017-05-04T22:17:36Z (7 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
31a30fa
Parents:
dc12262
Message:

cstyle (no change in functionality)

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/ohci_rh.c

    rdc12262 re141281  
    393393        TEST_SIZE_INIT(0, port, hub);
    394394        const unsigned feature = uint16_usb2host(setup_packet->value);
     395       
    395396        switch (feature) {
    396397        case USB_HUB_FEATURE_PORT_POWER:   /*8*/
    397         {
    398                 const uint32_t rhda = OHCI_RD(hub->registers->rh_desc_a);
    399                 /* No power switching */
    400                 if (rhda & RHDA_NPS_FLAG)
    401                         return EOK;
    402                 /* Ganged power switching, one port powers all */
    403                 if (!(rhda & RHDA_PSM_FLAG)) {
    404                         OHCI_WR(hub->registers->rh_status,RHS_SET_GLOBAL_POWER);
    405                         return EOK;
     398                {
     399                        const uint32_t rhda = OHCI_RD(hub->registers->rh_desc_a);
     400                       
     401                        /* No power switching */
     402                        if (rhda & RHDA_NPS_FLAG)
     403                                return EOK;
     404                       
     405                        /* Ganged power switching, one port powers all */
     406                        if (!(rhda & RHDA_PSM_FLAG)) {
     407                                OHCI_WR(hub->registers->rh_status,RHS_SET_GLOBAL_POWER);
     408                                return EOK;
     409                        }
    406410                }
    407         }
    408         /* Fall through, for per port power */
    409         /* Fallthrough */
     411                /* Fall through, for per port power */
     412                /* Fallthrough */
    410413        case USB_HUB_FEATURE_PORT_ENABLE:  /*1*/
    411414        case USB_HUB_FEATURE_PORT_SUSPEND: /*2*/
  • uspace/lib/c/generic/io/printf_core.c

    rdc12262 re141281  
    12211221                precision = (precision < 0) ? 6 : precision;
    12221222                return print_double_fixed(g, precision, width, flags, ps);
    1223 
     1223       
    12241224        case 'E':
    12251225                flags |= __PRINTF_FLAG_BIGCHARS;
     
    12281228                precision = (precision < 0) ? 6 : precision;
    12291229                return print_double_scientific(g, precision, width, flags, ps);
    1230 
     1230       
    12311231        case 'G':
    12321232                flags |= __PRINTF_FLAG_BIGCHARS;
     
    12341234        case 'g':
    12351235                return print_double_generic(g, precision, width, flags, ps);
    1236 
     1236       
    12371237        default:
    12381238                assert(false);
  • uspace/lib/usbhid/src/hiddescriptor.c

    rdc12262 re141281  
    737737 * @return Error code
    738738 */
    739 int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, 
    740         size_t item_size, usb_hid_report_item_t *report_item,
    741         usb_hid_report_path_t *usage_path)
     739int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data,
     740    size_t item_size, usb_hid_report_item_t *report_item,
     741    usb_hid_report_path_t *usage_path)
    742742{
    743743        int32_t extended_usage;
    744744       
    745         switch(tag) {
     745        switch (tag) {
    746746        case USB_HID_REPORT_TAG_USAGE:
    747                 switch(report_item->in_delimiter) {
     747                switch (report_item->in_delimiter) {
    748748                case INSIDE_DELIMITER_SET:
    749                         /* nothing to do
    750                          * we catch only the first one
     749                        /*
     750                         * Nothing to do.
     751                         * We catch only the first one
    751752                         */
    752753                        break;
    753        
     754                       
    754755                case START_DELIMITER_SET:
    755756                        report_item->in_delimiter = INSIDE_DELIMITER_SET;
     
    757758                case OUTSIDE_DELIMITER_SET:
    758759                        extended_usage = ((report_item->usage_page) << 16);
    759                         extended_usage += usb_hid_report_tag_data_uint32(
    760                                 data,item_size);
    761 
    762                         report_item->usages[report_item->usages_count] = 
    763                                 extended_usage;
    764 
     760                        extended_usage +=
     761                            usb_hid_report_tag_data_uint32(data, item_size);
     762                       
     763                        report_item->usages[report_item->usages_count] =
     764                            extended_usage;
     765                       
    765766                        report_item->usages_count++;
    766767                        break;
     
    768769                break;
    769770               
    770         case USB_HID_REPORT_TAG_USAGE_MINIMUM:                 
     771        case USB_HID_REPORT_TAG_USAGE_MINIMUM:
    771772                if (item_size == 3) {
    772                         // usage extended usages
    773                         report_item->extended_usage_page =
     773                        /* Usage extended usages */
     774                        report_item->extended_usage_page =
     775                            USB_HID_EXTENDED_USAGE_PAGE(
     776                            usb_hid_report_tag_data_uint32(data, item_size));
     777                       
     778                       
     779                        report_item->usage_minimum =
     780                            USB_HID_EXTENDED_USAGE(
     781                            usb_hid_report_tag_data_uint32(data, item_size));
     782                } else {
     783                        report_item->usage_minimum =
     784                            usb_hid_report_tag_data_uint32(data, item_size);
     785                }
     786                break;
     787               
     788        case USB_HID_REPORT_TAG_USAGE_MAXIMUM:
     789                if (item_size == 3) {
     790                        if (report_item->extended_usage_page !=
     791                            USB_HID_EXTENDED_USAGE_PAGE(
     792                            usb_hid_report_tag_data_uint32(data, item_size))) {
     793                                return EINVAL;
     794                        }
     795                       
     796                        /* Usage extended usages */
     797                        report_item->extended_usage_page =
    774798                            USB_HID_EXTENDED_USAGE_PAGE(
    775799                            usb_hid_report_tag_data_uint32(data,item_size));
    776                            
    777 
    778                         report_item->usage_minimum =
     800                       
     801                        report_item->usage_maximum =
    779802                            USB_HID_EXTENDED_USAGE(
    780803                            usb_hid_report_tag_data_uint32(data,item_size));
    781                 }
    782                 else {
    783                         report_item->usage_minimum =
     804                } else {
     805                        report_item->usage_maximum =
    784806                            usb_hid_report_tag_data_uint32(data,item_size);
    785807                }
    786                 break;
    787        
    788         case USB_HID_REPORT_TAG_USAGE_MAXIMUM:
    789                 if (item_size == 3) {
    790                         if(report_item->extended_usage_page !=
    791                             USB_HID_EXTENDED_USAGE_PAGE(       
    792                             usb_hid_report_tag_data_uint32(data,item_size))) {
    793                                
    794                                 return EINVAL;
    795                         }
    796                                
    797                         // usage extended usages
    798                         report_item->extended_usage_page =
    799                                 USB_HID_EXTENDED_USAGE_PAGE(
    800                                 usb_hid_report_tag_data_uint32(data,item_size));
    801 
    802                         report_item->usage_maximum =
    803                                 USB_HID_EXTENDED_USAGE(
    804                                 usb_hid_report_tag_data_uint32(data,item_size));
    805                 }
    806                 else {
    807                         report_item->usage_maximum =
    808                                 usb_hid_report_tag_data_uint32(data,item_size);
    809                 }
    810 
    811                 // vlozit zaznamy do pole usages
    812                 int32_t i;
    813                 for(i = report_item->usage_minimum;
     808               
     809                /* Put the records into the usages array */
     810                for (int32_t i = report_item->usage_minimum;
    814811                    i <= report_item->usage_maximum; i++) {
    815 
    816                         if(report_item->extended_usage_page) {
    817                             report_item->usages[report_item->usages_count++] =
    818                                 (report_item->extended_usage_page << 16) + i;
    819                         }
    820                         else {                 
    821                             report_item->usages[report_item->usages_count++] =
    822                                 (report_item->usage_page << 16) + i;
     812                       
     813                        if (report_item->extended_usage_page) {
     814                                report_item->usages[report_item->usages_count++] =
     815                                    (report_item->extended_usage_page << 16) + i;
     816                        } else {
     817                                report_item->usages[report_item->usages_count++] =
     818                                    (report_item->usage_page << 16) + i;
    823819                        }
    824820                }
    825821                report_item->extended_usage_page = 0;
    826                        
     822               
    827823                break;
    828824               
    829825        case USB_HID_REPORT_TAG_DESIGNATOR_INDEX:
    830                 report_item->designator_index = 
    831                         usb_hid_report_tag_data_uint32(data,item_size);
     826                report_item->designator_index =
     827                    usb_hid_report_tag_data_uint32(data, item_size);
    832828                break;
    833829       
    834830        case USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM:
    835                 report_item->designator_minimum = 
    836                         usb_hid_report_tag_data_uint32(data,item_size);
    837                 break;
    838 
     831                report_item->designator_minimum =
     832                    usb_hid_report_tag_data_uint32(data, item_size);
     833                break;
     834       
    839835        case USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM:
    840                 report_item->designator_maximum = 
    841                         usb_hid_report_tag_data_uint32(data,item_size);
    842                 break;
    843 
     836                report_item->designator_maximum =
     837                    usb_hid_report_tag_data_uint32(data, item_size);
     838                break;
     839       
    844840        case USB_HID_REPORT_TAG_STRING_INDEX:
    845                 report_item->string_index = 
    846                         usb_hid_report_tag_data_uint32(data,item_size);
    847                 break;
    848 
     841                report_item->string_index =
     842                    usb_hid_report_tag_data_uint32(data, item_size);
     843                break;
     844       
    849845        case USB_HID_REPORT_TAG_STRING_MINIMUM:
    850                 report_item->string_minimum = 
    851                         usb_hid_report_tag_data_uint32(data,item_size);
    852                 break;
    853 
     846                report_item->string_minimum =
     847                    usb_hid_report_tag_data_uint32(data, item_size);
     848                break;
     849       
    854850        case USB_HID_REPORT_TAG_STRING_MAXIMUM:
    855                 report_item->string_maximum = 
    856                         usb_hid_report_tag_data_uint32(data,item_size);
    857                 break;                 
    858 
     851                report_item->string_maximum =
     852                    usb_hid_report_tag_data_uint32(data, item_size);
     853                break;
     854       
    859855        case USB_HID_REPORT_TAG_DELIMITER:
    860                 report_item->in_delimiter = 
    861                         usb_hid_report_tag_data_uint32(data,item_size);
    862                 break;
    863 
     856                report_item->in_delimiter =
     857                    usb_hid_report_tag_data_uint32(data, item_size);
     858                break;
     859       
    864860        default:
    865861                return USB_HID_NO_ACTION;
    866862        }
    867 
     863       
    868864        return EOK;
    869865}
    870 
    871866
    872867/**
  • uspace/lib/usbhid/src/hidpath.c

    rdc12262 re141281  
    185185}
    186186
    187 
    188 /**
    189  * Compares two usage paths structures
    190  *
    191  *
    192  * @param report_path usage path structure to compare with @path
    193  * @param path usage patrh structure to compare
    194  * @param flags Flags determining the mode of comparison
     187/** Compare two usage paths structures
     188 *
     189 * @param report_path Usage path structure to compare with @path
     190 * @param path        Usage patrh structure to compare
     191 * @param flags       Flags determining the mode of comparison
     192 *
    195193 * @return EOK if both paths are identical, non zero number otherwise
    196  */
    197 int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path,
    198                                       usb_hid_report_path_t *path,
    199                                       int flags)
     194 *
     195 */
     196int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path,
     197    usb_hid_report_path_t *path, int flags)
    200198{
    201199        usb_hid_report_usage_path_t *report_item;
    202200        usb_hid_report_usage_path_t *path_item;
    203 
     201       
    204202        link_t *report_link;
    205203        link_t *path_link;
    206 
     204       
    207205        int only_page;
    208 
    209         if(report_path->report_id != path->report_id) {
    210                 if(path->report_id != 0) {
     206       
     207        if (report_path->report_id != path->report_id) {
     208                if (path->report_id != 0) {
    211209                        return 1;
    212210                }
    213211        }
    214 
     212       
    215213        // Empty path match all others
    216         if(path->depth == 0){
     214        if (path->depth == 0) {
    217215                return EOK;
    218216        }
    219 
    220 
    221         if((only_page = flags & USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY) != 0){
     217       
     218        if ((only_page = flags & USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY) != 0) {
    222219                flags -= USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY;
    223220        }
    224221       
    225         switch(flags){
    226         /* path is somewhere in report_path */
     222        switch (flags) {
     223        /* Path is somewhere in report_path */
    227224        case USB_HID_PATH_COMPARE_ANYWHERE:
    228                 if(path->depth != 1){
     225                if (path->depth != 1) {
    229226                        return 1;
    230227                }
    231 
     228               
    232229                path_link = list_first(&path->items);
    233230                path_item = list_get_instance(path_link,
    234                         usb_hid_report_usage_path_t, rpath_items_link);
    235 
     231                    usb_hid_report_usage_path_t, rpath_items_link);
     232               
    236233                list_foreach(report_path->items, rpath_items_link,
    237234                    usb_hid_report_usage_path_t, report_item) {
    238 
    239235                        if (USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    240                                 path_item->usage_page)) {
     236                            path_item->usage_page)) {
    241237                               
    242238                                if (only_page == 0) {
     
    244240                                            path_item->usage))
    245241                                                return EOK;
    246                                 }
    247                                 else {
     242                                } else {
    248243                                        return EOK;
    249244                                }
    250245                        }
    251246                }
    252 
     247               
    253248                return 1;
    254249                break;
    255 
    256         /* the paths must be identical */
     250       
     251        /* The paths must be identical */
    257252        case USB_HID_PATH_COMPARE_STRICT:
    258                 if(report_path->depth != path->depth){
     253                if (report_path->depth != path->depth) {
    259254                        return 1;
    260255                }
    261256                /* Fallthrough */
    262 
    263         /* path is prefix of the report_path */
     257       
     258        /* Path is prefix of the report_path */
    264259        case USB_HID_PATH_COMPARE_BEGIN:
    265 
    266260                report_link = report_path->items.head.next;
    267261                path_link = path->items.head.next;
     
    270264                    (path_link != &path->items.head)) {
    271265                       
    272                         report_item = list_get_instance(report_link, 
     266                        report_item = list_get_instance(report_link,
    273267                            usb_hid_report_usage_path_t, rpath_items_link);
    274268                       
    275269                        path_item = list_get_instance(path_link,
    276                                 usb_hid_report_usage_path_t, rpath_items_link);
    277 
    278                         if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
    279                             path_item->usage_page) || ((only_page == 0) && 
    280                             !USB_HID_SAME_USAGE(report_item->usage, 
     270                            usb_hid_report_usage_path_t, rpath_items_link);
     271                       
     272                        if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
     273                            path_item->usage_page) || ((only_page == 0) &&
     274                            !USB_HID_SAME_USAGE(report_item->usage,
    281275                            path_item->usage))) {
    282276                                return 1;
     
    286280                        }
    287281                }
    288 
    289                 if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 
    290                     (path_link == &path->items.head)) || 
    291                     ((report_link == &report_path->items.head) && 
     282               
     283                if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) &&
     284                    (path_link == &path->items.head)) ||
     285                    ((report_link == &report_path->items.head) &&
    292286                    (path_link == &path->items.head))) {
    293287                        return EOK;
     
    296290                }
    297291                break;
    298 
    299         /* path is suffix of report_path */
     292       
     293        /* Path is suffix of report_path */
    300294        case USB_HID_PATH_COMPARE_END:
    301 
    302295                report_link = report_path->items.head.prev;
    303296                path_link = path->items.head.prev;
    304 
    305                 if(list_empty(&path->items)){
     297               
     298                if (list_empty(&path->items)) {
    306299                        return EOK;
    307300                }
     301               
     302                while ((report_link != &report_path->items.head) &&
     303                      (path_link != &path->items.head)) {
     304                        report_item = list_get_instance(report_link,
     305                            usb_hid_report_usage_path_t, rpath_items_link);
    308306                       
    309                 while((report_link != &report_path->items.head) &&
    310                       (path_link != &path->items.head)) {
    311                                                  
    312                         report_item = list_get_instance(report_link,
    313                                 usb_hid_report_usage_path_t, rpath_items_link);
    314 
    315                         path_item = list_get_instance(path_link,
    316                                 usb_hid_report_usage_path_t, rpath_items_link);
    317                                                  
    318                         if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    319                                 path_item->usage_page) || ((only_page == 0) &&
    320                             !USB_HID_SAME_USAGE(report_item->usage,
    321                                 path_item->usage))) {
    322                                                
    323                                         return 1;
     307                        path_item = list_get_instance(path_link,
     308                            usb_hid_report_usage_path_t, rpath_items_link);
     309                       
     310                        if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
     311                            path_item->usage_page) || ((only_page == 0) &&
     312                            !USB_HID_SAME_USAGE(report_item->usage,
     313                            path_item->usage))) {
     314                                return 1;
    324315                        } else {
    325316                                report_link = report_link->prev;
    326                                 path_link = path_link->prev;                   
     317                                path_link = path_link->prev;
    327318                        }
    328 
    329                 }
    330 
    331                 if(path_link == &path->items.head) {
     319                }
     320               
     321                if (path_link == &path->items.head) {
    332322                        return EOK;
    333                 }
    334                 else {
     323                } else {
    335324                        return 1;
    336                 }                                               
    337                        
     325                }
    338326                break;
    339 
     327       
    340328        default:
    341329                return EINVAL;
    342330        }
    343331}
    344 
    345332
    346333/**
  • uspace/srv/net/slip/slip.c

    rdc12262 re141281  
    256256
    257257                                /*
    258                                  * The RFC suggests to simply insert the wrongly
    259                                  * escaped character into the packet so we fall
    260                                  * through.
    261                                  */
     258                                 * The RFC suggests to simply insert the wrongly
     259                                 * escaped character into the packet so we fall
     260                                 * through.
     261                                 */
    262262                                /* Fallthrough */
    263  
     263
    264264                        default:
    265265                                recv_final[sdu.size++] = ch;
Note: See TracChangeset for help on using the changeset viewer.