Changeset a35b458 in mainline for uspace/drv/hid


Ignore:
Timestamp:
2018-03-02T20:10:49Z (8 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:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

Location:
uspace/drv/hid
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/hid/atkbd/atkbd.c

    r3061bc1 ra35b458  
    205205        size_t nwr;
    206206        errno_t rc;
    207        
     207
    208208        while (true) {
    209209                uint8_t code = 0;
     
    211211                if (rc != EOK)
    212212                        return EIO;
    213                
     213
    214214                const unsigned int *map;
    215215                size_t map_size;
    216                
     216
    217217                if (code == KBD_SCANCODE_SET_EXTENDED) {
    218218                        map = scanmap_e0;
    219219                        map_size = sizeof(scanmap_e0) / sizeof(unsigned int);
    220                        
     220
    221221                        rc = chardev_read(kbd->chardev, &code, 1, &nwr);
    222222                        if (rc != EOK)
     
    270270                        map_size = sizeof(scanmap_simple) / sizeof(unsigned int);
    271271                }
    272                
     272
    273273                kbd_event_type_t type;
    274274                if (code == KBD_SCANCODE_KEY_RELEASE) {
     
    280280                        type = KEY_PRESS;
    281281                }
    282                
     282
    283283                const unsigned int key = (code < map_size) ? map[code] : 0;
    284                
     284
    285285                if (key != 0)
    286286                        push_event(kbd->client_sess, type, key);
     
    315315                async_sess_t *sess =
    316316                    async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
    317                
     317
    318318                /* Probably ENOMEM error, try again. */
    319319                if (sess == NULL) {
     
    323323                        break;
    324324                }
    325                
     325
    326326                if (kbd->client_sess == NULL) {
    327327                        kbd->client_sess = sess;
     
    332332                        async_answer_0(icallid, ELIMIT);
    333333                }
    334                
     334
    335335                break;
    336336        }
     
    359359        async_sess_t *parent_sess;
    360360        errno_t rc;
    361        
     361
    362362        assert(kbd);
    363363        assert(dev);
    364        
     364
    365365        kbd->client_sess = NULL;
    366366        parent_sess = ddf_dev_parent_sess_get(dev);
     
    370370                goto error;
    371371        }
    372        
     372
    373373        rc = chardev_open(parent_sess, &kbd->chardev);
    374374        if (rc != EOK) {
     
    376376                return EIO;
    377377        }
    378        
     378
    379379        kbd->kbd_fun = ddf_fun_create(dev, fun_exposed, "kbd");
    380380        if (!kbd->kbd_fun) {
     
    382382                return ENOMEM;
    383383        }
    384        
     384
    385385        ddf_fun_set_ops(kbd->kbd_fun, &kbd_ops);
    386        
     386
    387387        errno_t ret = ddf_fun_bind(kbd->kbd_fun);
    388388        if (ret != EOK) {
     
    391391                return EEXIST;
    392392        }
    393        
     393
    394394        ret = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard");
    395395        if (ret != EOK) {
     
    400400                return ENOMEM;
    401401        }
    402        
     402
    403403        kbd->polling_fibril = fibril_create(polling, kbd);
    404404        if (!kbd->polling_fibril) {
     
    408408                return ENOMEM;
    409409        }
    410        
     410
    411411        fibril_add_ready(kbd->polling_fibril);
    412412        return EOK;
  • uspace/drv/hid/usbhid/blink1/blink1.c

    r3061bc1 ra35b458  
    6767                return EINVAL;
    6868        }
    69        
     69
    7070        blink1_report_t report;
    71        
     71
    7272        report.id = BLINK1_REPORT_ID;
    7373        report.command = BLINK1_COMMAND_SET;
     
    7878        report.arg4 = 0;
    7979        report.arg5 = 0;
    80        
     80
    8181        return usbhid_req_set_report(
    8282            usb_device_get_default_pipe(blink1_dev->hid_dev->usb_dev),
     
    100100                return EINVAL;
    101101        }
    102        
     102
    103103        /* Create the exposed function. */
    104104        ddf_fun_t *fun = usb_device_ddf_fun_create(hid_dev->usb_dev,
     
    109109                return ENOMEM;
    110110        }
    111        
     111
    112112        usb_blink1_t *blink1_dev = (usb_blink1_t *)
    113113            ddf_fun_data_alloc(fun, sizeof(usb_blink1_t));
     
    118118                return ENOMEM;
    119119        }
    120        
     120
    121121        ddf_fun_set_ops(fun, &blink1_ops);
    122        
     122
    123123        errno_t rc = ddf_fun_bind(fun);
    124124        if (rc != EOK) {
     
    128128                return rc;
    129129        }
    130        
     130
    131131        rc = ddf_fun_add_to_category(fun, HID_BLINK1_CATEGORY);
    132132        if (rc != EOK) {
    133133                usb_log_error("Could not add DDF function to category %s: %s.",
    134134                    HID_BLINK1_CATEGORY, str_error(rc));
    135                
     135
    136136                rc = ddf_fun_unbind(fun);
    137137                if (rc != EOK) {
     
    140140                        return rc;
    141141                }
    142                
     142
    143143                ddf_fun_destroy(fun);
    144144                return rc;
    145145        }
    146        
     146
    147147        blink1_dev->fun = fun;
    148148        blink1_dev->hid_dev = hid_dev;
    149149        *data = blink1_dev;
    150        
     150
    151151        return EOK;
    152152}
     
    156156        if (data == NULL)
    157157                return;
    158        
     158
    159159        usb_blink1_t *blink1_dev = (usb_blink1_t *) data;
    160        
     160
    161161        errno_t rc = ddf_fun_unbind(blink1_dev->fun);
    162162        if (rc != EOK) {
     
    165165                return;
    166166        }
    167        
     167
    168168        ddf_fun_destroy(blink1_dev->fun);
    169169}
  • uspace/drv/hid/usbhid/blink1/blink1.h

    r3061bc1 ra35b458  
    4444        /** DDF blink(1) function */
    4545        ddf_fun_t *fun;
    46        
     46
    4747        /** USB HID device */
    4848        usb_hid_dev_t *hid_dev;
  • uspace/drv/hid/usbhid/kbd/kbddev.h

    r3061bc1 ra35b458  
    6363        /** Link to HID device structure */
    6464        usb_hid_dev_t *hid_dev;
    65        
     65
    6666        /** Previously pressed keys (not translated to key codes). */
    6767        int32_t *keys_old;
     
    7272        /** Currently pressed modifiers (bitmap). */
    7373        uint8_t modifiers;
    74        
     74
    7575        /** Currently active modifiers including locks. Sent to the console. */
    7676        unsigned int mods;
    77        
     77
    7878        /** Currently active lock keys. */
    7979        unsigned int lock_keys;
    80        
     80
    8181        /** IPC session to client (for sending key events). */
    8282        async_sess_t *client_sess;
    83        
     83
    8484        /** Information for auto-repeat of keys. */
    8585        usb_kbd_repeat_t repeat;
    86        
     86
    8787        /** Mutex for accessing the information about auto-repeat. */
    8888        fibril_mutex_t repeat_mtx;
    89        
     89
    9090        uint8_t *output_buffer;
    91        
     91
    9292        size_t output_size;
    93        
     93
    9494        size_t led_output_size;
    95        
     95
    9696        usb_hid_report_path_t *led_path;
    97        
     97
    9898        int32_t *led_data;
    99        
     99
    100100        /** State of the structure (for checking before use).
    101101         *
     
    105105         */
    106106        int initialized;
    107        
     107
    108108        /** DDF function */
    109109        ddf_fun_t *fun;
  • uspace/drv/hid/usbhid/mouse/mousedev.h

    r3061bc1 ra35b458  
    4545        /** IPC session to consumer. */
    4646        async_sess_t *mouse_sess;
    47        
     47
    4848        /** Mouse buttons statuses. */
    4949        int32_t *buttons;
    5050        size_t buttons_count;
    51        
     51
    5252        /** DDF mouse function */
    5353        ddf_fun_t *mouse_fun;
  • uspace/drv/hid/usbhid/multimedia/keymap.c

    r3061bc1 ra35b458  
    8686        /*! @todo What if the usage is not in the table? */
    8787        key = map[usage];
    88        
     88
    8989        return key;
    9090}
  • uspace/drv/hid/usbhid/subdrivers.h

    r3061bc1 ra35b458  
    6161         */
    6262        const usb_hid_subdriver_usage_t *usage_path;
    63        
     63
    6464        /** Report ID for which the path should apply. */
    6565        int report_id;
    66        
     66
    6767        /** Compare type for the usage path. */
    6868        int compare;
    69        
     69
    7070        /** Vendor ID (set to -1 if not specified). */
    7171        int vendor_id;
    72        
     72
    7373        /** Product ID (set to -1 if not specified). */
    7474        int product_id;
    75        
     75
    7676        /** Subdriver for controlling this device. */
    7777        const usb_hid_subdriver_t subdriver;
  • uspace/drv/hid/xtkbd/xtkbd.c

    r3061bc1 ra35b458  
    4747static const unsigned int scanmap_simple[] = {
    4848        [0x29] = KC_BACKTICK,
    49        
     49
    5050        [0x02] = KC_1,
    5151        [0x03] = KC_2,
     
    5858        [0x0a] = KC_9,
    5959        [0x0b] = KC_0,
    60        
     60
    6161        [0x0c] = KC_MINUS,
    6262        [0x0d] = KC_EQUALS,
    6363        [0x0e] = KC_BACKSPACE,
    64        
     64
    6565        [0x0f] = KC_TAB,
    66        
     66
    6767        [0x10] = KC_Q,
    6868        [0x11] = KC_W,
     
    7575        [0x18] = KC_O,
    7676        [0x19] = KC_P,
    77        
     77
    7878        [0x1a] = KC_LBRACKET,
    7979        [0x1b] = KC_RBRACKET,
    80        
     80
    8181        [0x3a] = KC_CAPS_LOCK,
    82        
     82
    8383        [0x1e] = KC_A,
    8484        [0x1f] = KC_S,
     
    9090        [0x25] = KC_K,
    9191        [0x26] = KC_L,
    92        
     92
    9393        [0x27] = KC_SEMICOLON,
    9494        [0x28] = KC_QUOTE,
    9595        [0x2b] = KC_BACKSLASH,
    96        
     96
    9797        [0x2a] = KC_LSHIFT,
    98        
     98
    9999        [0x2c] = KC_Z,
    100100        [0x2d] = KC_X,
     
    104104        [0x31] = KC_N,
    105105        [0x32] = KC_M,
    106        
     106
    107107        [0x33] = KC_COMMA,
    108108        [0x34] = KC_PERIOD,
    109109        [0x35] = KC_SLASH,
    110        
     110
    111111        [0x36] = KC_RSHIFT,
    112        
     112
    113113        [0x1d] = KC_LCTRL,
    114114        [0x38] = KC_LALT,
    115115        [0x39] = KC_SPACE,
    116        
     116
    117117        [0x01] = KC_ESCAPE,
    118        
     118
    119119        [0x3b] = KC_F1,
    120120        [0x3c] = KC_F2,
     
    124124        [0x40] = KC_F6,
    125125        [0x41] = KC_F7,
    126        
     126
    127127        [0x42] = KC_F8,
    128128        [0x43] = KC_F9,
    129129        [0x44] = KC_F10,
    130        
     130
    131131        [0x57] = KC_F11,
    132132        [0x58] = KC_F12,
    133        
     133
    134134        [0x46] = KC_SCROLL_LOCK,
    135        
     135
    136136        [0x1c] = KC_ENTER,
    137        
     137
    138138        [0x45] = KC_NUM_LOCK,
    139139        [0x37] = KC_NTIMES,
     
    162162        [0x38] = KC_RALT,
    163163        [0x1d] = KC_RCTRL,
    164        
     164
    165165        [0x37] = KC_SYSREQ,
    166        
     166
    167167        [0x52] = KC_INSERT,
    168168        [0x47] = KC_HOME,
    169169        [0x49] = KC_PAGE_UP,
    170        
     170
    171171        [0x53] = KC_DELETE,
    172172        [0x4f] = KC_END,
    173173        [0x51] = KC_PAGE_DOWN,
    174        
     174
    175175        [0x48] = KC_UP,
    176176        [0x4b] = KC_LEFT,
    177177        [0x50] = KC_DOWN,
    178178        [0x4d] = KC_RIGHT,
    179        
     179
    180180        [0x35] = KC_NSLASH,
    181181        [0x1c] = KC_NENTER
     
    210210        size_t nread;
    211211        errno_t rc;
    212        
     212
    213213        while (true) {
    214214                const unsigned int *map = scanmap_simple;
    215215                size_t map_size = sizeof(scanmap_simple) / sizeof(unsigned int);
    216                
     216
    217217                uint8_t code = 0;
    218218                rc = chardev_read(kbd->chardev, &code, 1, &nread);
    219219                if (rc != EOK)
    220220                        return EIO;
    221                
     221
    222222                /* Ignore AT command reply */
    223223                if ((code == KBD_ACK) || (code == KBD_RESEND))
    224224                        continue;
    225                
     225
    226226                /* Extended set */
    227227                if (code == KBD_SCANCODE_SET_EXTENDED) {
    228228                        map = scanmap_e0;
    229229                        map_size = sizeof(scanmap_e0) / sizeof(unsigned int);
    230                        
    231                         rc = chardev_read(kbd->chardev, &code, 1, &nread);
    232                         if (rc != EOK)
    233                                 return EIO;
    234                        
     230
     231                        rc = chardev_read(kbd->chardev, &code, 1, &nread);
     232                        if (rc != EOK)
     233                                return EIO;
     234
    235235                        /* Handle really special keys */
    236                        
     236
    237237                        if (code == 0x2a) {  /* Print Screen */
    238238                                rc = chardev_read(kbd->chardev, &code, 1, &nread);
    239239                                if (rc != EOK)
    240240                                        return EIO;
    241                                
     241
    242242                                if (code != 0xe0)
    243243                                        continue;
    244                                
     244
    245245                                rc = chardev_read(kbd->chardev, &code, 1, &nread);
    246246                                if (rc != EOK)
    247247                                        return EIO;
    248                                
     248
    249249                                if (code == 0x37)
    250250                                        push_event(kbd->client_sess, KEY_PRESS, KC_PRTSCR);
    251                                
     251
    252252                                continue;
    253253                        }
    254                        
     254
    255255                        if (code == 0x46) {  /* Break */
    256256                                rc = chardev_read(kbd->chardev, &code, 1, &nread);
    257257                                if (rc != EOK)
    258258                                        return EIO;
    259                                
     259
    260260                                if (code != 0xe0)
    261261                                        continue;
    262                                
     262
    263263                                rc = chardev_read(kbd->chardev, &code, 1, &nread);
    264264                                if (rc != EOK)
    265265                                        return EIO;
    266                                
     266
    267267                                if (code == 0xc6)
    268268                                        push_event(kbd->client_sess, KEY_PRESS, KC_BREAK);
    269                                
     269
    270270                                continue;
    271271                        }
    272272                }
    273                
     273
    274274                /* Extended special set */
    275275                if (code == KBD_SCANCODE_SET_EXTENDED_SPECIAL) {
     
    277277                        if (rc != EOK)
    278278                                return EIO;
    279                        
     279
    280280                        if (code != 0x1d)
    281281                                continue;
    282                        
    283                         rc = chardev_read(kbd->chardev, &code, 1, &nread);
    284                         if (rc != EOK)
    285                                 return EIO;
    286                        
     282
     283                        rc = chardev_read(kbd->chardev, &code, 1, &nread);
     284                        if (rc != EOK)
     285                                return EIO;
     286
    287287                        if (code != 0x45)
    288288                                continue;
    289                        
    290                         rc = chardev_read(kbd->chardev, &code, 1, &nread);
    291                         if (rc != EOK)
    292                                 return EIO;
    293                        
     289
     290                        rc = chardev_read(kbd->chardev, &code, 1, &nread);
     291                        if (rc != EOK)
     292                                return EIO;
     293
    294294                        if (code != 0xe1)
    295295                                continue;
    296                        
    297                         rc = chardev_read(kbd->chardev, &code, 1, &nread);
    298                         if (rc != EOK)
    299                                 return EIO;
    300                        
     296
     297                        rc = chardev_read(kbd->chardev, &code, 1, &nread);
     298                        if (rc != EOK)
     299                                return EIO;
     300
    301301                        if (code != 0x9d)
    302302                                continue;
    303                        
    304                         rc = chardev_read(kbd->chardev, &code, 1, &nread);
    305                         if (rc != EOK)
    306                                 return EIO;
    307                        
     303
     304                        rc = chardev_read(kbd->chardev, &code, 1, &nread);
     305                        if (rc != EOK)
     306                                return EIO;
     307
    308308                        if (code == 0xc5)
    309309                                push_event(kbd->client_sess, KEY_PRESS, KC_PAUSE);
    310                        
     310
    311311                        continue;
    312312                }
    313                
     313
    314314                /* Bit 7 indicates press/release */
    315315                const kbd_event_type_t type =
    316316                    (code & 0x80) ? KEY_RELEASE : KEY_PRESS;
    317317                code &= ~0x80;
    318                
     318
    319319                const unsigned int key = (code < map_size) ? map[code] : 0;
    320                
     320
    321321                if (key != 0)
    322322                        push_event(kbd->client_sess, type, key);
     
    351351                    ((mods & KM_SCROLL_LOCK) ? LI_SCROLL : 0);
    352352                uint8_t cmds[] = { KBD_CMD_SET_LEDS, status };
    353                
     353
    354354                size_t nwr;
    355355                errno_t rc = chardev_write(kbd->chardev, &cmds[0], 1, &nwr);
     
    370370                async_sess_t *sess =
    371371                    async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
    372                
     372
    373373                /* Probably ENOMEM error, try again. */
    374374                if (sess == NULL) {
     
    378378                        break;
    379379                }
    380                
     380
    381381                if (kbd->client_sess == NULL) {
    382382                        kbd->client_sess = sess;
     
    387387                        async_answer_0(icallid, ELIMIT);
    388388                }
    389                
     389
    390390                break;
    391391        }
     
    415415        bool bound = false;
    416416        errno_t rc;
    417        
     417
    418418        kbd->client_sess = NULL;
    419        
     419
    420420        parent_sess = ddf_dev_parent_sess_get(dev);
    421421        if (parent_sess == NULL) {
     
    424424                goto error;
    425425        }
    426        
     426
    427427        rc = chardev_open(parent_sess, &kbd->chardev);
    428428        if (rc != EOK) {
     
    430430                goto error;
    431431        }
    432        
     432
    433433        kbd->kbd_fun = ddf_fun_create(dev, fun_exposed, "kbd");
    434434        if (kbd->kbd_fun == NULL) {
     
    437437                goto error;
    438438        }
    439        
     439
    440440        ddf_fun_set_ops(kbd->kbd_fun, &kbd_ops);
    441        
     441
    442442        rc = ddf_fun_bind(kbd->kbd_fun);
    443443        if (rc != EOK) {
     
    445445                goto error;
    446446        }
    447        
     447
    448448        rc = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard");
    449449        if (rc != EOK) {
     
    452452                goto error;
    453453        }
    454        
     454
    455455        kbd->polling_fibril = fibril_create(polling, kbd);
    456456        if (kbd->polling_fibril == 0) {
     
    459459                goto error;
    460460        }
    461        
     461
    462462        fibril_add_ready(kbd->polling_fibril);
    463463        return EOK;
Note: See TracChangeset for help on using the changeset viewer.